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

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

Issue 2541313002: RenderTextHarfBuzz: Add support for multi line text selection. (Closed)
Patch Set: Fix test. Created 3 years, 12 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
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/gfx/render_text_harfbuzz.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
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 the width of the given |char_range| handling grapheme boundaries
59 bool HasMissingGlyphs() const; 60 // within glyphs.
61 float GetGraphemeWidthForCharRange(RenderTextHarfBuzz* render_text,
62 const Range& char_range) const;
60 63
61 // Returns the glyph width for the given character range. |char_range| is in 64 // Returns the glyph width for the given character range. |char_range| is in
62 // text-space (0 corresponds to |GetDisplayText()[0]|). 65 // text-space (0 corresponds to |GetDisplayText()[0]|).
63 SkScalar GetGlyphWidthForCharRange(const Range& char_range) const; 66 SkScalar GetGlyphWidthForCharRange(const Range& char_range) const;
64 67
65 float width; 68 float width;
66 float preceding_run_widths; 69 float preceding_run_widths;
67 Range range; 70 Range range;
68 bool is_rtl; 71 bool is_rtl;
69 UBiDiLevel level; 72 UBiDiLevel level;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Specify the width of a glyph for test. The width of glyphs is very 189 // Specify the width of a glyph for test. The width of glyphs is very
187 // platform-dependent and environment-dependent. Otherwise multiline test 190 // platform-dependent and environment-dependent. Otherwise multiline test
188 // will become really flaky. 191 // will become really flaky.
189 void set_glyph_width_for_test(float test_width) { 192 void set_glyph_width_for_test(float test_width) {
190 glyph_width_for_test_ = test_width; 193 glyph_width_for_test_ = test_width;
191 } 194 }
192 195
193 // Return the run index that contains the argument; or the length of the 196 // Return the run index that contains the argument; or the length of the
194 // |runs_| vector if argument exceeds the text length or width. 197 // |runs_| vector if argument exceeds the text length or width.
195 size_t GetRunContainingCaret(const SelectionModel& caret); 198 size_t GetRunContainingCaret(const SelectionModel& caret);
196 size_t GetRunContainingXCoord(float x, float* offset) const; 199
200 // Returns the line index for the given argument. |text_y| is relative to
201 // the text bounds. Returns -1 if |text_y| is above the text and
202 // lines().size() if |text_y| is below it.
203 int GetLineContainingYCoord(float text_y);
204
205 // Returns the line segment index for the |line|, |text_x| pair. |text_x| is
206 // relative to text in the given line. Returns -1 if |text_x| is to the left
207 // of text in the line and |line|.segments.size() if it's to the right.
208 // |offset_relative_segment| will contain the offset of |text_x| relative to
209 // the start of the segment it is contained in.
210 int GetLineSegmentContainingXCoord(const internal::Line& line,
211 float text_x,
212 float* offset_relative_segment);
197 213
198 // Given a |run|, returns the SelectionModel that contains the logical first 214 // Given a |run|, returns the SelectionModel that contains the logical first
199 // or last caret position inside (not at a boundary of) the run. 215 // or last caret position inside (not at a boundary of) the run.
200 // The returned value represents a cursor/caret position without a selection. 216 // The returned value represents a cursor/caret position without a selection.
201 SelectionModel FirstSelectionModelInsideRun( 217 SelectionModel FirstSelectionModelInsideRun(
202 const internal::TextRunHarfBuzz* run); 218 const internal::TextRunHarfBuzz* run);
203 SelectionModel LastSelectionModelInsideRun( 219 SelectionModel LastSelectionModelInsideRun(
204 const internal::TextRunHarfBuzz* run); 220 const internal::TextRunHarfBuzz* run);
205 221
206 // Break the text into logical runs and populate the visual <-> logical maps 222 // Break the text into logical runs and populate the visual <-> logical maps
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 280
265 // Fixed width of glyphs. This should only be set in test environments. 281 // Fixed width of glyphs. This should only be set in test environments.
266 float glyph_width_for_test_; 282 float glyph_width_for_test_;
267 283
268 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); 284 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz);
269 }; 285 };
270 286
271 } // namespace gfx 287 } // namespace gfx
272 288
273 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ 289 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_
OLDNEW
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/gfx/render_text_harfbuzz.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698