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

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

Issue 2408623002: Views: Extract text selection code from Textfield. (Closed)
Patch Set: Rebase. Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_H_ 5 #ifndef UI_GFX_RENDER_TEXT_H_
6 #define UI_GFX_RENDER_TEXT_H_ 6 #define UI_GFX_RENDER_TEXT_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 VisualCursorDirection direction, 334 VisualCursorDirection direction,
335 SelectionBehavior selection_behavior); 335 SelectionBehavior selection_behavior);
336 336
337 // Set the selection_model_ to the value of |selection|. 337 // Set the selection_model_ to the value of |selection|.
338 // The selection range is clamped to text().length() if out of range. 338 // The selection range is clamped to text().length() if out of range.
339 // Returns true if the cursor position or selection range changed. 339 // Returns true if the cursor position or selection range changed.
340 // If any index in |selection_model| is not a cursorable position (not on a 340 // If any index in |selection_model| is not a cursorable position (not on a
341 // grapheme boundary), it is a no-op and returns false. 341 // grapheme boundary), it is a no-op and returns false.
342 bool MoveCursorTo(const SelectionModel& selection_model); 342 bool MoveCursorTo(const SelectionModel& selection_model);
343 343
344 // Moves the cursor to the text index corresponding to |point|. If |select| is
345 // true, a selection is made with the current selection start index.
346 bool MoveCursorTo(const gfx::Point& point, bool select);
347
344 // Set the selection_model_ based on |range|. 348 // Set the selection_model_ based on |range|.
345 // If the |range| start or end is greater than text length, it is modified 349 // If the |range| start or end is greater than text length, it is modified
346 // to be the text length. 350 // to be the text length.
347 // If the |range| start or end is not a cursorable position (not on grapheme 351 // If the |range| start or end is not a cursorable position (not on grapheme
348 // boundary), it is a NO-OP and returns false. Otherwise, returns true. 352 // boundary), it is a NO-OP and returns false. Otherwise, returns true.
349 bool SelectRange(const Range& range); 353 bool SelectRange(const Range& range);
350 354
351 // Returns true if the local point is over selected text. 355 // Returns true if the local point is over selected text.
352 bool IsPointInSelection(const Point& point); 356 bool IsPointInSelection(const Point& point);
353 357
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 // Lines computed by EnsureLayout. These should be invalidated upon 846 // Lines computed by EnsureLayout. These should be invalidated upon
843 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. 847 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls.
844 std::vector<internal::Line> lines_; 848 std::vector<internal::Line> lines_;
845 849
846 DISALLOW_COPY_AND_ASSIGN(RenderText); 850 DISALLOW_COPY_AND_ASSIGN(RenderText);
847 }; 851 };
848 852
849 } // namespace gfx 853 } // namespace gfx
850 854
851 #endif // UI_GFX_RENDER_TEXT_H_ 855 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698