OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
6 #define UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 6 #define UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "third_party/harfbuzz-ng/src/hb.h" | 10 #include "third_party/harfbuzz-ng/src/hb.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 virtual void ResetLayout() OVERRIDE; | 100 virtual void ResetLayout() OVERRIDE; |
101 virtual void EnsureLayout() OVERRIDE; | 101 virtual void EnsureLayout() OVERRIDE; |
102 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; | 102 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; |
103 | 103 |
104 private: | 104 private: |
105 friend class RenderTextTest; | 105 friend class RenderTextTest; |
106 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_RunDirection); | 106 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_RunDirection); |
107 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks); | 107 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks); |
108 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases); | 108 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases); |
109 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemePartition); | 109 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemePartition); |
| 110 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_NonExistentFont); |
110 | 111 |
111 // Return the run index that contains the argument; or the length of the | 112 // Return the run index that contains the argument; or the length of the |
112 // |runs_| vector if argument exceeds the text length or width. | 113 // |runs_| vector if argument exceeds the text length or width. |
113 size_t GetRunContainingCaret(const SelectionModel& caret) const; | 114 size_t GetRunContainingCaret(const SelectionModel& caret) const; |
114 size_t GetRunContainingXCoord(int x, int* offset) const; | 115 size_t GetRunContainingXCoord(int x, int* offset) const; |
115 | 116 |
116 // Given a |run|, returns the SelectionModel that contains the logical first | 117 // Given a |run|, returns the SelectionModel that contains the logical first |
117 // or last caret position inside (not at a boundary of) the run. | 118 // or last caret position inside (not at a boundary of) the run. |
118 // The returned value represents a cursor/caret position without a selection. | 119 // The returned value represents a cursor/caret position without a selection. |
119 SelectionModel FirstSelectionModelInsideRun( | 120 SelectionModel FirstSelectionModelInsideRun( |
120 const internal::TextRunHarfBuzz* run); | 121 const internal::TextRunHarfBuzz* run); |
121 SelectionModel LastSelectionModelInsideRun( | 122 SelectionModel LastSelectionModelInsideRun( |
122 const internal::TextRunHarfBuzz* run); | 123 const internal::TextRunHarfBuzz* run); |
123 | 124 |
124 // Break the text into logical runs and populate the visual <-> logical maps. | 125 // Break the text into logical runs and populate the visual <-> logical maps. |
125 void ItemizeText(); | 126 void ItemizeText(); |
126 | 127 |
127 // Shape the glyphs needed for the text |run|. | 128 // Shape the glyphs needed for the text |run|. |
128 void ShapeRun(internal::TextRunHarfBuzz* run); | 129 void ShapeRun(internal::TextRunHarfBuzz* run); |
129 void ShapeRunWithFont(internal::TextRunHarfBuzz* run, | 130 bool ShapeRunWithFont(internal::TextRunHarfBuzz* run, |
130 const std::string& font); | 131 const std::string& font); |
131 | 132 |
132 // Text runs in logical order. | 133 // Text runs in logical order. |
133 ScopedVector<internal::TextRunHarfBuzz> runs_; | 134 ScopedVector<internal::TextRunHarfBuzz> runs_; |
134 | 135 |
135 // Maps visual run indices to logical run indices and vice versa. | 136 // Maps visual run indices to logical run indices and vice versa. |
136 std::vector<int32_t> visual_to_logical_; | 137 std::vector<int32_t> visual_to_logical_; |
137 std::vector<int32_t> logical_to_visual_; | 138 std::vector<int32_t> logical_to_visual_; |
138 | 139 |
139 bool needs_layout_; | 140 bool needs_layout_; |
140 | 141 |
141 // ICU grapheme iterator for the layout text. Valid when |!needs_layout_|. Can | 142 // ICU grapheme iterator for the layout text. Valid when |!needs_layout_|. Can |
142 // be NULL in case of an error. | 143 // be NULL in case of an error. |
143 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_; | 144 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_; |
144 | 145 |
145 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); | 146 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); |
146 }; | 147 }; |
147 | 148 |
148 } // namespace gfx | 149 } // namespace gfx |
149 | 150 |
150 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 151 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
OLD | NEW |