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

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

Issue 882643005: Add multiline support to RenderTextHarfBuzz. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: newline 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 character for test. The width of characters is very
msw 2015/02/05 01:09:15 nit: use "glyph" and "glyphs", not "character" and
Jun Mukai 2015/02/05 19:48:32 Done.
126 // platform-dependent and environment-dependent. Otherwise multiline test
127 // will become really flaky.
128 static void SetGlyphWidthForTest(int test_width);
msw 2015/02/05 01:09:15 Make this a non-static value and setter on rthb in
Jun Mukai 2015/02/05 19:48:32 Done.
129
124 // Return the run index that contains the argument; or the length of the 130 // Return the run index that contains the argument; or the length of the
125 // |runs_| vector if argument exceeds the text length or width. 131 // |runs_| vector if argument exceeds the text length or width.
126 size_t GetRunContainingCaret(const SelectionModel& caret) const; 132 size_t GetRunContainingCaret(const SelectionModel& caret) const;
127 size_t GetRunContainingXCoord(float x, float* offset) const; 133 size_t GetRunContainingXCoord(float x, float* offset) const;
128 134
129 // Given a |run|, returns the SelectionModel that contains the logical first 135 // Given a |run|, returns the SelectionModel that contains the logical first
130 // or last caret position inside (not at a boundary of) the run. 136 // or last caret position inside (not at a boundary of) the run.
131 // The returned value represents a cursor/caret position without a selection. 137 // The returned value represents a cursor/caret position without a selection.
132 SelectionModel FirstSelectionModelInsideRun( 138 SelectionModel FirstSelectionModelInsideRun(
133 const internal::TextRunHarfBuzz* run); 139 const internal::TextRunHarfBuzz* run);
(...skipping 27 matching lines...) Expand all
161 // Maps visual run indices to logical run indices and vice versa. 167 // Maps visual run indices to logical run indices and vice versa.
162 std::vector<int32_t> visual_to_logical_; 168 std::vector<int32_t> visual_to_logical_;
163 std::vector<int32_t> logical_to_visual_; 169 std::vector<int32_t> logical_to_visual_;
164 170
165 bool needs_layout_; 171 bool needs_layout_;
166 172
167 // ICU grapheme iterator for the layout text. Valid when |!needs_layout_|. Can 173 // ICU grapheme iterator for the layout text. Valid when |!needs_layout_|. Can
168 // be NULL in case of an error. 174 // be NULL in case of an error.
169 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_; 175 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_;
170 176
177 // The total size of the layouted text.
178 SizeF total_size_;
179
171 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); 180 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz);
172 }; 181 };
173 182
174 } // namespace gfx 183 } // namespace gfx
175 184
176 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ 185 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698