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

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

Issue 252563003: Fix Views inline autocomplete with multi-char graphemes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Consolidate IsValidLogicalIndex implementations. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/gfx/render_text.cc » ('j') | ui/gfx/render_text.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 8 #include <algorithm>
9 #include <cstring> 9 #include <cstring>
10 #include <string> 10 #include <string>
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 int GetBaseline(); 371 int GetBaseline();
372 372
373 void Draw(Canvas* canvas); 373 void Draw(Canvas* canvas);
374 374
375 // Draws a cursor at |position|. 375 // Draws a cursor at |position|.
376 void DrawCursor(Canvas* canvas, const SelectionModel& position); 376 void DrawCursor(Canvas* canvas, const SelectionModel& position);
377 377
378 // Gets the SelectionModel from a visual point in local coordinates. 378 // Gets the SelectionModel from a visual point in local coordinates.
379 virtual SelectionModel FindCursorPosition(const Point& point) = 0; 379 virtual SelectionModel FindCursorPosition(const Point& point) = 0;
380 380
381 // Return true if cursor can appear in front of the character at |position|, 381 // Return true if cursor can appear in front of the character at |index|,
382 // which means it is a grapheme boundary or the first character in the text. 382 // which means it is a grapheme boundary or the first character in the text.
383 virtual bool IsCursorablePosition(size_t position) = 0; 383 virtual bool IsValidCursorIndex(size_t index) = 0;
384
385 // Return true if the position is a valid logical index. Here, positions amid
386 // multi-character graphemes may be allowed, unlike in IsValidCursorIndex.
Alexei Svitkine (slow) 2014/04/30 19:53:24 Can these comments clarify whether the indexes the
msw 2014/05/01 20:40:04 Done.
387 virtual bool IsValidLogicalIndex(size_t index);
384 388
385 // Get the visual bounds of a cursor at |caret|. These bounds typically 389 // Get the visual bounds of a cursor at |caret|. These bounds typically
386 // represent a vertical line if |insert_mode| is true. Pass false for 390 // represent a vertical line if |insert_mode| is true. Pass false for
387 // |insert_mode| to retrieve the bounds of the associated glyph. These bounds 391 // |insert_mode| to retrieve the bounds of the associated glyph. These bounds
388 // are in local coordinates, but may be outside the visible region if the text 392 // are in local coordinates, but may be outside the visible region if the text
389 // is longer than the textfield. Subsequent text, cursor, or bounds changes 393 // is longer than the textfield. Subsequent text, cursor, or bounds changes
390 // may invalidate returned values. Note that |caret| must be placed at 394 // may invalidate returned values. Note that |caret| must be placed at
391 // grapheme boundary, that is, |IsCursorablePosition(caret.caret_pos())| must 395 // grapheme boundary, i.e. caret.caret_pos() must be a cursorable position.
392 // return true.
393 Rect GetCursorBounds(const SelectionModel& caret, bool insert_mode); 396 Rect GetCursorBounds(const SelectionModel& caret, bool insert_mode);
394 397
395 // Compute the current cursor bounds, panning the text to show the cursor in 398 // Compute the current cursor bounds, panning the text to show the cursor in
396 // the display rect if necessary. These bounds are in local coordinates. 399 // the display rect if necessary. These bounds are in local coordinates.
397 // Subsequent text, cursor, or bounds changes may invalidate returned values. 400 // Subsequent text, cursor, or bounds changes may invalidate returned values.
398 const Rect& GetUpdatedCursorBounds(); 401 const Rect& GetUpdatedCursorBounds();
399 402
400 // Given an |index| in text(), return the next or previous grapheme boundary 403 // Given an |index| in text(), return the next or previous grapheme boundary
401 // in logical order (that is, the nearest index for which 404 // in logical order (i.e. the nearest cursorable index). The return value is
402 // |IsCursorablePosition(index)| returns true). The return value is in the 405 // in the range 0 to text().length() inclusive (the input is clamped if it is
403 // range 0 to text().length() inclusive (the input is clamped if it is out of 406 // out of that range). Always moves by at least one character index unless the
404 // that range). Always moves by at least one character index unless the
405 // supplied index is already at the boundary of the string. 407 // supplied index is already at the boundary of the string.
406 size_t IndexOfAdjacentGrapheme(size_t index, 408 size_t IndexOfAdjacentGrapheme(size_t index,
407 LogicalCursorDirection direction); 409 LogicalCursorDirection direction);
408 410
409 // Return a SelectionModel with the cursor at the current selection's start. 411 // Return a SelectionModel with the cursor at the current selection's start.
410 // The returned value represents a cursor/caret position without a selection. 412 // The returned value represents a cursor/caret position without a selection.
411 SelectionModel GetSelectionModelForSelectionStart(); 413 SelectionModel GetSelectionModelForSelectionStart();
412 414
413 // Sets shadows to drawn with text. 415 // Sets shadows to drawn with text.
414 void SetTextShadows(const ShadowValues& shadows); 416 void SetTextShadows(const ShadowValues& shadows);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 // Lines computed by EnsureLayout. These should be invalidated with 708 // Lines computed by EnsureLayout. These should be invalidated with
707 // ResetLayout and on |display_rect_| changes. 709 // ResetLayout and on |display_rect_| changes.
708 std::vector<internal::Line> lines_; 710 std::vector<internal::Line> lines_;
709 711
710 DISALLOW_COPY_AND_ASSIGN(RenderText); 712 DISALLOW_COPY_AND_ASSIGN(RenderText);
711 }; 713 };
712 714
713 } // namespace gfx 715 } // namespace gfx
714 716
715 #endif // UI_GFX_RENDER_TEXT_H_ 717 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/render_text.cc » ('j') | ui/gfx/render_text.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698