Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: ui/gfx/render_text_harfbuzz.h

Issue 924773002: Fix multiline behaviors for RTL text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, Multiline_NormalWidth);
117 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_RunDirection); 117 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_RunDirection);
118 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_RTLDrawingPositions);
119 FRIEND_TEST_ALL_PREFIXES(RenderTextTest,
120 HarfBuzz_TextPositionWithFractionalSize);
118 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks); 121 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks);
119 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByEmoji); 122 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByEmoji);
120 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases); 123 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases);
121 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemePartition); 124 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemePartition);
122 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_NonExistentFont); 125 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_NonExistentFont);
123 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); 126 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback);
124 127
125 // Specify the width of a glyph for test. The width of glyphs is very 128 // Specify the width of a glyph for test. The width of glyphs is very
126 // platform-dependent and environment-dependent. Otherwise multiline test 129 // platform-dependent and environment-dependent. Otherwise multiline test
127 // will become really flaky. 130 // will become really flaky.
128 void set_glyph_width_for_test(uint8 test_width) { 131 void set_glyph_width_for_test(float test_width) {
129 glyph_width_for_test_ = test_width; 132 glyph_width_for_test_ = test_width;
130 } 133 }
131 134
135 // The actual implementation of the text drawing.
136 void DrawVisualTextInternal(internal::SkiaTextRenderer* renderer);
137
132 // Return the run index that contains the argument; or the length of the 138 // Return the run index that contains the argument; or the length of the
133 // |runs_| vector if argument exceeds the text length or width. 139 // |runs_| vector if argument exceeds the text length or width.
134 size_t GetRunContainingCaret(const SelectionModel& caret) const; 140 size_t GetRunContainingCaret(const SelectionModel& caret) const;
135 size_t GetRunContainingXCoord(float x, float* offset) const; 141 size_t GetRunContainingXCoord(float x, float* offset) const;
136 142
137 // Given a |run|, returns the SelectionModel that contains the logical first 143 // Given a |run|, returns the SelectionModel that contains the logical first
138 // or last caret position inside (not at a boundary of) the run. 144 // or last caret position inside (not at a boundary of) the run.
139 // The returned value represents a cursor/caret position without a selection. 145 // The returned value represents a cursor/caret position without a selection.
140 SelectionModel FirstSelectionModelInsideRun( 146 SelectionModel FirstSelectionModelInsideRun(
141 const internal::TextRunHarfBuzz* run); 147 const internal::TextRunHarfBuzz* run);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 bool needs_layout_; 179 bool needs_layout_;
174 180
175 // ICU grapheme iterator for the layout text. Valid when |!needs_layout_|. Can 181 // ICU grapheme iterator for the layout text. Valid when |!needs_layout_|. Can
176 // be NULL in case of an error. 182 // be NULL in case of an error.
177 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_; 183 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_;
178 184
179 // The total size of the layouted text. 185 // The total size of the layouted text.
180 SizeF total_size_; 186 SizeF total_size_;
181 187
182 // Fixed width of glyphs. This should only be set in test environments. 188 // Fixed width of glyphs. This should only be set in test environments.
183 uint8 glyph_width_for_test_; 189 float glyph_width_for_test_;
184 190
185 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); 191 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz);
186 }; 192 };
187 193
188 } // namespace gfx 194 } // namespace gfx
189 195
190 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ 196 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698