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

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

Issue 1070223004: Stop combining text runs which are connected by 'COMMON' blocks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address mukai@'s comments. Created 5 years, 7 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // Writes the character and glyph ranges of the cluster containing |pos|. 47 // Writes the character and glyph ranges of the cluster containing |pos|.
48 void GetClusterAt(size_t pos, Range* chars, Range* glyphs) const; 48 void GetClusterAt(size_t pos, Range* chars, Range* glyphs) const;
49 49
50 // Returns the grapheme bounds at |text_index|. Handles multi-grapheme glyphs. 50 // Returns the grapheme bounds at |text_index|. Handles multi-grapheme glyphs.
51 RangeF GetGraphemeBounds(base::i18n::BreakIterator* grapheme_iterator, 51 RangeF GetGraphemeBounds(base::i18n::BreakIterator* grapheme_iterator,
52 size_t text_index); 52 size_t text_index);
53 53
54 // Returns whether the given shaped run contains any missing glyphs. 54 // Returns whether the given shaped run contains any missing glyphs.
55 bool HasMissingGlyphs() const; 55 bool HasMissingGlyphs() const;
56 56
57 // Returns the glyph width for the given character range. |char_range| is in
58 // text-space (0 corresponds to |GetDisplayText()[0]|).
59 SkScalar GetGlyphWidthForCharRange(const Range& char_range) const;
60
57 float width; 61 float width;
58 float preceding_run_widths; 62 float preceding_run_widths;
59 Range range; 63 Range range;
60 bool is_rtl; 64 bool is_rtl;
61 UBiDiLevel level; 65 UBiDiLevel level;
62 UScriptCode script; 66 UScriptCode script;
63 67
64 scoped_ptr<uint16[]> glyphs; 68 scoped_ptr<uint16[]> glyphs;
65 scoped_ptr<SkPoint[]> positions; 69 scoped_ptr<SkPoint[]> positions;
66 std::vector<uint32> glyph_to_char; 70 std::vector<uint32> glyph_to_char;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Initialize the index mapping. 112 // Initialize the index mapping.
109 void InitIndexMap(); 113 void InitIndexMap();
110 114
111 // Precomputes the offsets for all runs. 115 // Precomputes the offsets for all runs.
112 void ComputePrecedingRunWidths(); 116 void ComputePrecedingRunWidths();
113 117
114 // Get the total width of runs, as if they were shown on one line. 118 // Get the total width of runs, as if they were shown on one line.
115 // Do not use this when multiline is enabled. 119 // Do not use this when multiline is enabled.
116 float width() const { return width_; } 120 float width() const { return width_; }
117 121
122 // Get the run index applicable to |position| (at or preceeding |position|).
123 size_t GetRunIndexAt(size_t position) const;
124
118 private: 125 private:
119 // Text runs in logical order. 126 // Text runs in logical order.
120 ScopedVector<TextRunHarfBuzz> runs_; 127 ScopedVector<TextRunHarfBuzz> runs_;
121 128
122 // Maps visual run indices to logical run indices and vice versa. 129 // Maps visual run indices to logical run indices and vice versa.
123 std::vector<int32_t> visual_to_logical_; 130 std::vector<int32_t> visual_to_logical_;
124 std::vector<int32_t> logical_to_visual_; 131 std::vector<int32_t> logical_to_visual_;
125 132
126 float width_; 133 float width_;
127 134
(...skipping 30 matching lines...) Expand all
158 size_t TextIndexToDisplayIndex(size_t index) override; 165 size_t TextIndexToDisplayIndex(size_t index) override;
159 size_t DisplayIndexToTextIndex(size_t index) override; 166 size_t DisplayIndexToTextIndex(size_t index) override;
160 bool IsValidCursorIndex(size_t index) override; 167 bool IsValidCursorIndex(size_t index) override;
161 void OnLayoutTextAttributeChanged(bool text_changed) override; 168 void OnLayoutTextAttributeChanged(bool text_changed) override;
162 void OnDisplayTextAttributeChanged() override; 169 void OnDisplayTextAttributeChanged() override;
163 void EnsureLayout() override; 170 void EnsureLayout() override;
164 void DrawVisualText(Canvas* canvas) override; 171 void DrawVisualText(Canvas* canvas) override;
165 172
166 private: 173 private:
167 friend class RenderTextTest; 174 friend class RenderTextTest;
175 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_LineBreakerBehavior);
168 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_HorizontalAlignment); 176 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_HorizontalAlignment);
169 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_NormalWidth); 177 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_NormalWidth);
170 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_WordWrapBehavior); 178 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_WordWrapBehavior);
171 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_RunDirection); 179 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_RunDirection);
172 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_HorizontalPositions); 180 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_HorizontalPositions);
173 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, 181 FRIEND_TEST_ALL_PREFIXES(RenderTextTest,
174 HarfBuzz_TextPositionWithFractionalSize); 182 HarfBuzz_TextPositionWithFractionalSize);
175 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks); 183 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks);
176 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByEmoji); 184 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByEmoji);
177 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases); 185 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 271
264 // Fixed width of glyphs. This should only be set in test environments. 272 // Fixed width of glyphs. This should only be set in test environments.
265 float glyph_width_for_test_; 273 float glyph_width_for_test_;
266 274
267 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); 275 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz);
268 }; 276 };
269 277
270 } // namespace gfx 278 } // namespace gfx
271 279
272 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ 280 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698