Index: ui/gfx/render_text_harfbuzz.h |
diff --git a/ui/gfx/render_text_harfbuzz.h b/ui/gfx/render_text_harfbuzz.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0f8274cd4e89f19cc33dc0b6ba6d2ba94d754f65 |
--- /dev/null |
+++ b/ui/gfx/render_text_harfbuzz.h |
@@ -0,0 +1,90 @@ |
+// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
+#define UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "third_party/harfbuzz-ng/src/hb.h" |
+#include "third_party/icu/source/common/unicode/ubidi.h" |
+#include "ui/gfx/render_text.h" |
+ |
+namespace gfx { |
+ |
+namespace internal { |
+ |
+struct TextRunHarfBuzz { |
+ TextRunHarfBuzz(); |
+ ~TextRunHarfBuzz(); |
+ |
+ UBiDiDirection direction; |
+ Range range; |
+ scoped_ptr<uint16[]> glyphs; |
+ scoped_ptr<SkPoint[]> positions; |
+ scoped_ptr<uint32[]> glyph_to_char; |
+ size_t glyph_count; |
+ int width; |
+ SkTypeface* skia_face; |
+ int font_size; |
+}; |
+ |
+} // namespace internal |
+ |
+class RenderTextHarfBuzz : public RenderText { |
+ public: |
+ RenderTextHarfBuzz(); |
+ virtual ~RenderTextHarfBuzz(); |
+ |
+ // Overridden from RenderText. |
+ virtual Size GetStringSize() OVERRIDE; |
+ virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; |
+ virtual bool IsCursorablePosition(size_t position) OVERRIDE; |
+ virtual std::vector<FontSpan> GetFontSpansForTesting() OVERRIDE; |
+ |
+ protected: |
+ // Overridden from RenderText. |
+ virtual int GetLayoutTextBaseline() OVERRIDE; |
+ virtual SelectionModel AdjacentCharSelectionModel( |
+ const SelectionModel& selection, |
+ VisualCursorDirection direction) OVERRIDE; |
+ virtual SelectionModel AdjacentWordSelectionModel( |
+ const SelectionModel& selection, |
+ VisualCursorDirection direction) OVERRIDE; |
+ virtual Range GetGlyphBounds(size_t index) OVERRIDE; |
+ virtual std::vector<Rect> GetSubstringBounds(const Range& range) OVERRIDE; |
+ virtual size_t TextIndexToLayoutIndex(size_t index) const OVERRIDE; |
+ virtual size_t LayoutIndexToTextIndex(size_t index) const OVERRIDE; |
+ virtual void ResetLayout() OVERRIDE; |
+ virtual void EnsureLayout() OVERRIDE; |
+ virtual void DrawVisualText(Canvas* canvas) OVERRIDE; |
+ |
+ void ShapeRun(Range range, |
+ UBiDiDirection direction, |
+ internal::TextRunHarfBuzz* run); |
+ |
+ size_t GetRunContainingCaret(const SelectionModel& caret) const; |
+ |
+ // Returns the X coordinate of the leading or |trailing| edge of the glyph |
+ // starting at |index|, relative to the left of the text (not the view). |
+ int GetGlyphXBoundary(size_t run_index, size_t text_index, bool trailing); |
+ |
+ SelectionModel RenderTextHarfBuzz::FirstSelectionModelInsideRun( |
+ const internal::TextRunHarfBuzz* run); |
+ |
+ SelectionModel RenderTextHarfBuzz::LastSelectionModelInsideRun( |
+ const internal::TextRunHarfBuzz* run); |
+ |
+ size_t GetRunContainingXCoord(int x, int* offset) const; |
+ |
+ private: |
+ // Text runs in visual order. |
+ scoped_ptr<internal::TextRunHarfBuzz[]> runs_; |
+ size_t num_runs_; |
+ |
+ bool needs_layout_; |
+}; |
+ |
+} // namespace gfx |
+ |
+#endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |