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 175 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 | 186 // Specify the width of a glyph for test. The width of glyphs is very |
187 // platform-dependent and environment-dependent. Otherwise multiline test | 187 // platform-dependent and environment-dependent. Otherwise multiline test |
188 // will become really flaky. | 188 // will become really flaky. |
189 void set_glyph_width_for_test(float test_width) { | 189 void set_glyph_width_for_test(float test_width) { |
190 glyph_width_for_test_ = test_width; | 190 glyph_width_for_test_ = test_width; |
191 } | 191 } |
192 | 192 |
193 // Return the run index that contains the argument; or the length of the | 193 // Return the run index that contains the argument; or the length of the |
194 // |runs_| vector if argument exceeds the text length or width. | 194 // |runs_| vector if argument exceeds the text length or width. |
195 size_t GetRunContainingCaret(const SelectionModel& caret); | 195 size_t GetRunContainingCaret(const SelectionModel& caret); |
196 size_t GetRunContainingXCoord(float x, float* offset) const; | 196 |
| 197 // Returns the line index for the given argument. |text_y| is relative to |
| 198 // the text bounds. Returns -1 if |text_y| is above the text and |
| 199 // lines().size() if |text_y| is below it. |
| 200 int GetLineContainingYCoord(float text_y); |
| 201 |
| 202 // Returns the line segment index for the |line|, |text_x| pair. |text_x| is |
| 203 // relative to text in the given line. Returns -1 if |text_x| is to the left |
| 204 // of text in the line and |line|.segments.size() if it's to the right. |
| 205 // |offset_relative_segment| will contain the offset of |text_x| relative to |
| 206 // the start of the segment it is contained in. |
| 207 int GetLineSegmentContainingXCoord(const internal::Line& line, |
| 208 float text_x, |
| 209 float* offset_relative_segment); |
197 | 210 |
198 // Given a |run|, returns the SelectionModel that contains the logical first | 211 // Given a |run|, returns the SelectionModel that contains the logical first |
199 // or last caret position inside (not at a boundary of) the run. | 212 // or last caret position inside (not at a boundary of) the run. |
200 // The returned value represents a cursor/caret position without a selection. | 213 // The returned value represents a cursor/caret position without a selection. |
201 SelectionModel FirstSelectionModelInsideRun( | 214 SelectionModel FirstSelectionModelInsideRun( |
202 const internal::TextRunHarfBuzz* run); | 215 const internal::TextRunHarfBuzz* run); |
203 SelectionModel LastSelectionModelInsideRun( | 216 SelectionModel LastSelectionModelInsideRun( |
204 const internal::TextRunHarfBuzz* run); | 217 const internal::TextRunHarfBuzz* run); |
205 | 218 |
206 // Break the text into logical runs and populate the visual <-> logical maps | 219 // 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 | 277 |
265 // Fixed width of glyphs. This should only be set in test environments. | 278 // Fixed width of glyphs. This should only be set in test environments. |
266 float glyph_width_for_test_; | 279 float glyph_width_for_test_; |
267 | 280 |
268 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); | 281 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); |
269 }; | 282 }; |
270 | 283 |
271 } // namespace gfx | 284 } // namespace gfx |
272 | 285 |
273 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 286 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
OLD | NEW |