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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 std::vector<Rect> GetSubstringBounds(const Range& range) override; | 106 std::vector<Rect> GetSubstringBounds(const Range& range) override; |
107 size_t TextIndexToLayoutIndex(size_t index) const override; | 107 size_t TextIndexToLayoutIndex(size_t index) const override; |
108 size_t LayoutIndexToTextIndex(size_t index) const override; | 108 size_t LayoutIndexToTextIndex(size_t index) const override; |
109 bool IsValidCursorIndex(size_t index) override; | 109 bool IsValidCursorIndex(size_t index) override; |
110 void ResetLayout() override; | 110 void ResetLayout() override; |
111 void EnsureLayout() override; | 111 void EnsureLayout() override; |
112 void DrawVisualText(Canvas* canvas) override; | 112 void DrawVisualText(Canvas* canvas) override; |
113 | 113 |
114 private: | 114 private: |
115 friend class RenderTextTest; | 115 friend class RenderTextTest; |
116 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_NormalWidth); | |
116 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_RunDirection); | 117 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_RunDirection); |
117 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks); | 118 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks); |
118 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByEmoji); | 119 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByEmoji); |
119 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases); | 120 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases); |
120 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemePartition); | 121 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemePartition); |
121 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_NonExistentFont); | 122 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_NonExistentFont); |
122 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); | 123 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); |
123 | 124 |
125 // Specify the width of a glyph for test. The width of glyphs is very | |
126 // platform-dependent and environment-dependent. Otherwise multiline test | |
127 // will become really flaky. | |
128 void set_glyph_width_for_test(uint8 test_width) { | |
129 glyph_width_for_test_ = test_width; | |
130 } | |
131 | |
124 // Return the run index that contains the argument; or the length of the | 132 // Return the run index that contains the argument; or the length of the |
125 // |runs_| vector if argument exceeds the text length or width. | 133 // |runs_| vector if argument exceeds the text length or width. |
126 size_t GetRunContainingCaret(const SelectionModel& caret) const; | 134 size_t GetRunContainingCaret(const SelectionModel& caret) const; |
127 size_t GetRunContainingXCoord(float x, float* offset) const; | 135 size_t GetRunContainingXCoord(float x, float* offset) const; |
128 | 136 |
129 // Given a |run|, returns the SelectionModel that contains the logical first | 137 // Given a |run|, returns the SelectionModel that contains the logical first |
130 // or last caret position inside (not at a boundary of) the run. | 138 // or last caret position inside (not at a boundary of) the run. |
131 // The returned value represents a cursor/caret position without a selection. | 139 // The returned value represents a cursor/caret position without a selection. |
132 SelectionModel FirstSelectionModelInsideRun( | 140 SelectionModel FirstSelectionModelInsideRun( |
133 const internal::TextRunHarfBuzz* run); | 141 const internal::TextRunHarfBuzz* run); |
(...skipping 27 matching lines...) Expand all Loading... | |
161 // Maps visual run indices to logical run indices and vice versa. | 169 // Maps visual run indices to logical run indices and vice versa. |
162 std::vector<int32_t> visual_to_logical_; | 170 std::vector<int32_t> visual_to_logical_; |
163 std::vector<int32_t> logical_to_visual_; | 171 std::vector<int32_t> logical_to_visual_; |
164 | 172 |
165 bool needs_layout_; | 173 bool needs_layout_; |
166 | 174 |
167 // ICU grapheme iterator for the layout text. Valid when |!needs_layout_|. Can | 175 // ICU grapheme iterator for the layout text. Valid when |!needs_layout_|. Can |
168 // be NULL in case of an error. | 176 // be NULL in case of an error. |
169 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_; | 177 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_; |
170 | 178 |
179 // The total size of the layouted text. | |
180 SizeF total_size_; | |
181 | |
182 // Fixed width of glyphs. This should only be set in test environments. | |
183 uint8 glyph_width_for_test_; | |
oshima
2015/02/05 21:29:40
instead of adding this to every instance, can you
msw
2015/02/05 21:50:58
That goes against my recommendation at:
https://co
Jun Mukai
2015/02/05 22:21:48
One thing actually I was a bit worried about is th
oshima
2015/02/05 22:42:44
How about defining virtual function that gets the
Jun Mukai
2015/02/05 23:28:00
Rather than that, I would think that exposing the
oshima
2015/02/05 23:48:25
I'm fine as long as we can eliminate test only mem
| |
184 | |
171 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); | 185 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); |
172 }; | 186 }; |
173 | 187 |
174 } // namespace gfx | 188 } // namespace gfx |
175 | 189 |
176 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 190 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
OLD | NEW |