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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 bool IsValidCursorIndex(size_t index) override; | 157 bool IsValidCursorIndex(size_t index) override; |
158 void OnLayoutTextAttributeChanged(bool text_changed) override; | 158 void OnLayoutTextAttributeChanged(bool text_changed) override; |
159 void OnDisplayTextAttributeChanged() override; | 159 void OnDisplayTextAttributeChanged() override; |
160 void EnsureLayout() override; | 160 void EnsureLayout() override; |
161 void DrawVisualText(Canvas* canvas) override; | 161 void DrawVisualText(Canvas* canvas) override; |
162 | 162 |
163 private: | 163 private: |
164 friend class RenderTextTest; | 164 friend class RenderTextTest; |
165 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_NormalWidth); | 165 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_NormalWidth); |
166 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_RunDirection); | 166 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_RunDirection); |
| 167 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_HorizontalPositions); |
| 168 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, |
| 169 HarfBuzz_TextPositionWithFractionalSize); |
167 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks); | 170 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks); |
168 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByEmoji); | 171 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByEmoji); |
169 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases); | 172 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases); |
170 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemePartition); | 173 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemePartition); |
171 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_NonExistentFont); | 174 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_NonExistentFont); |
172 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); | 175 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); |
173 | 176 |
174 // Specify the width of a glyph for test. The width of glyphs is very | 177 // Specify the width of a glyph for test. The width of glyphs is very |
175 // platform-dependent and environment-dependent. Otherwise multiline test | 178 // platform-dependent and environment-dependent. Otherwise multiline test |
176 // will become really flaky. | 179 // will become really flaky. |
177 void set_glyph_width_for_test(uint8 test_width) { | 180 void set_glyph_width_for_test(float test_width) { |
178 glyph_width_for_test_ = test_width; | 181 glyph_width_for_test_ = test_width; |
179 } | 182 } |
180 | 183 |
| 184 // The actual implementation of the text drawing. |
| 185 void DrawVisualTextInternal(internal::SkiaTextRenderer* renderer); |
| 186 |
181 // Return the run index that contains the argument; or the length of the | 187 // Return the run index that contains the argument; or the length of the |
182 // |runs_| vector if argument exceeds the text length or width. | 188 // |runs_| vector if argument exceeds the text length or width. |
183 size_t GetRunContainingCaret(const SelectionModel& caret); | 189 size_t GetRunContainingCaret(const SelectionModel& caret); |
184 size_t GetRunContainingXCoord(float x, float* offset) const; | 190 size_t GetRunContainingXCoord(float x, float* offset) const; |
185 | 191 |
186 // Given a |run|, returns the SelectionModel that contains the logical first | 192 // Given a |run|, returns the SelectionModel that contains the logical first |
187 // or last caret position inside (not at a boundary of) the run. | 193 // or last caret position inside (not at a boundary of) the run. |
188 // The returned value represents a cursor/caret position without a selection. | 194 // The returned value represents a cursor/caret position without a selection. |
189 SelectionModel FirstSelectionModelInsideRun( | 195 SelectionModel FirstSelectionModelInsideRun( |
190 const internal::TextRunHarfBuzz* run); | 196 const internal::TextRunHarfBuzz* run); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 bool update_display_text_ : 1; | 255 bool update_display_text_ : 1; |
250 | 256 |
251 // ICU grapheme iterator for the layout text. Use GetGraphemeIterator() | 257 // ICU grapheme iterator for the layout text. Use GetGraphemeIterator() |
252 // to access the iterator. | 258 // to access the iterator. |
253 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_; | 259 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_; |
254 | 260 |
255 // The total size of the layouted text. | 261 // The total size of the layouted text. |
256 SizeF total_size_; | 262 SizeF total_size_; |
257 | 263 |
258 // Fixed width of glyphs. This should only be set in test environments. | 264 // Fixed width of glyphs. This should only be set in test environments. |
259 uint8 glyph_width_for_test_; | 265 float glyph_width_for_test_; |
260 | 266 |
261 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); | 267 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); |
262 }; | 268 }; |
263 | 269 |
264 } // namespace gfx | 270 } // namespace gfx |
265 | 271 |
266 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 272 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
OLD | NEW |