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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 // value is in run-space (0 corresponds to the first glyph in the run). | 46 // value is in run-space (0 corresponds to the first glyph in the run). |
47 Range CharRangeToGlyphRange(const Range& range) const; | 47 Range CharRangeToGlyphRange(const Range& range) const; |
48 | 48 |
49 // Returns the number of missing glyphs in the shaped text run. | 49 // Returns the number of missing glyphs in the shaped text run. |
50 size_t CountMissingGlyphs() const; | 50 size_t CountMissingGlyphs() const; |
51 | 51 |
52 // Writes the character and glyph ranges of the cluster containing |pos|. | 52 // Writes the character and glyph ranges of the cluster containing |pos|. |
53 void GetClusterAt(size_t pos, Range* chars, Range* glyphs) const; | 53 void GetClusterAt(size_t pos, Range* chars, Range* glyphs) const; |
54 | 54 |
55 // Returns the grapheme bounds at |text_index|. Handles multi-grapheme glyphs. | 55 // Returns the grapheme bounds at |text_index|. Handles multi-grapheme glyphs. |
56 RangeF GetGraphemeBounds(RenderTextHarfBuzz* render_text, size_t text_index); | 56 RangeF GetGraphemeBounds(RenderTextHarfBuzz* render_text, |
57 size_t text_index) const; | |
57 | 58 |
58 // Returns whether the given shaped run contains any missing glyphs. | 59 // Returns whether the given shaped run contains any missing glyphs. |
59 bool HasMissingGlyphs() const; | 60 bool HasMissingGlyphs() const; |
60 | 61 |
62 // Returns the width of the given |char_range| handling grapheme boundaries | |
msw
2016/12/19 22:27:43
nit: it'd be nice if this were adjacent to GetGrap
karandeepb
2016/12/21 14:23:44
Now they are adjacent. Removed HasMissingGlyphs wh
| |
63 // within glyphs. | |
64 float GetGraphemeWidthForCharRange(RenderTextHarfBuzz* render_text, | |
65 const Range& char_range) const; | |
66 | |
61 // Returns the glyph width for the given character range. |char_range| is in | 67 // Returns the glyph width for the given character range. |char_range| is in |
62 // text-space (0 corresponds to |GetDisplayText()[0]|). | 68 // text-space (0 corresponds to |GetDisplayText()[0]|). |
63 SkScalar GetGlyphWidthForCharRange(const Range& char_range) const; | 69 SkScalar GetGlyphWidthForCharRange(const Range& char_range) const; |
64 | 70 |
65 float width; | 71 float width; |
66 float preceding_run_widths; | 72 float preceding_run_widths; |
67 Range range; | 73 Range range; |
68 bool is_rtl; | 74 bool is_rtl; |
69 UBiDiLevel level; | 75 UBiDiLevel level; |
70 UScriptCode script; | 76 UScriptCode script; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 // Specify the width of a glyph for test. The width of glyphs is very | 192 // Specify the width of a glyph for test. The width of glyphs is very |
187 // platform-dependent and environment-dependent. Otherwise multiline test | 193 // platform-dependent and environment-dependent. Otherwise multiline test |
188 // will become really flaky. | 194 // will become really flaky. |
189 void set_glyph_width_for_test(float test_width) { | 195 void set_glyph_width_for_test(float test_width) { |
190 glyph_width_for_test_ = test_width; | 196 glyph_width_for_test_ = test_width; |
191 } | 197 } |
192 | 198 |
193 // Return the run index that contains the argument; or the length of the | 199 // Return the run index that contains the argument; or the length of the |
194 // |runs_| vector if argument exceeds the text length or width. | 200 // |runs_| vector if argument exceeds the text length or width. |
195 size_t GetRunContainingCaret(const SelectionModel& caret); | 201 size_t GetRunContainingCaret(const SelectionModel& caret); |
196 size_t GetRunContainingXCoord(float x, float* offset) const; | 202 |
203 // Returns the line index for the given argument. |text_y| is relative to | |
204 // the text bounds. Returns -1 if |text_y| is above the text and | |
205 // lines().size() if |text_y| is below it. | |
206 int GetLineContainingYCoord(float text_y); | |
207 | |
208 // Returns the line segment index for the |line|, |text_x| pair. |text_x| is | |
209 // relative to text in the given line. Returns -1 if |text_x| is to the left | |
210 // of text in the line and |line|.segments.size() if it's to the right. | |
211 // |offset_relative_segment| will contain the offset of |text_x| relative to | |
212 // the start of the segment it is contained in. | |
213 int GetLineSegmentContainingXCoord(const internal::Line& line, | |
214 float text_x, | |
215 float* offset_relative_segment); | |
197 | 216 |
198 // Given a |run|, returns the SelectionModel that contains the logical first | 217 // Given a |run|, returns the SelectionModel that contains the logical first |
199 // or last caret position inside (not at a boundary of) the run. | 218 // or last caret position inside (not at a boundary of) the run. |
200 // The returned value represents a cursor/caret position without a selection. | 219 // The returned value represents a cursor/caret position without a selection. |
201 SelectionModel FirstSelectionModelInsideRun( | 220 SelectionModel FirstSelectionModelInsideRun( |
202 const internal::TextRunHarfBuzz* run); | 221 const internal::TextRunHarfBuzz* run); |
203 SelectionModel LastSelectionModelInsideRun( | 222 SelectionModel LastSelectionModelInsideRun( |
204 const internal::TextRunHarfBuzz* run); | 223 const internal::TextRunHarfBuzz* run); |
205 | 224 |
206 // Break the text into logical runs and populate the visual <-> logical maps | 225 // Break the text into logical runs and populate the visual <-> logical maps |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 | 283 |
265 // Fixed width of glyphs. This should only be set in test environments. | 284 // Fixed width of glyphs. This should only be set in test environments. |
266 float glyph_width_for_test_; | 285 float glyph_width_for_test_; |
267 | 286 |
268 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); | 287 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); |
269 }; | 288 }; |
270 | 289 |
271 } // namespace gfx | 290 } // namespace gfx |
272 | 291 |
273 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 292 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
OLD | NEW |