diff options
author | yukawa@chromium.org <yukawa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 13:02:05 +0000 |
---|---|---|
committer | yukawa@chromium.org <yukawa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 13:02:05 +0000 |
commit | 740c674579ba83f2f1195f5e2c2b885f2d444592 (patch) | |
tree | bbc97fafaa01beacc9005dbd538593f879742c77 /ui/gfx/render_text.h | |
parent | 1dbea2c0b3f0b06b829a40256bd4568931ddf3de (diff) | |
download | chromium_src-740c674579ba83f2f1195f5e2c2b885f2d444592.zip chromium_src-740c674579ba83f2f1195f5e2c2b885f2d444592.tar.gz chromium_src-740c674579ba83f2f1195f5e2c2b885f2d444592.tar.bz2 |
Adjust |index| into cursorable position in NativeTextfieldViews::GetCompositionCharacterBounds
RenderText::GetCursorBounds expects that that |caret| parameter is placed at somewhere cursorable so far. In fact, tt has a DCHECK like this: DCHECK(IsCursorablePosition(caret_pos)).
On the other hand, currently NativeTextfieldViews::GetCompositionCharacterBounds(index, ...) is implemented by calling RenderText::GetCursorBounds with |index| and |index + 1|. This may cause DCHECK failure because neither |index| nor |index + 1| is guaranteed to be cursorable position.
This CL updates NativeTextfieldViews::GetCompositionCharacterBounds to make sure that RenderText::GetCursorBounds is called with cursorable position.
This CL also fixes a comment bug in RenderText::GetCursorBounds().
BUG=325083
TEST=views_unitetest --gtest_filter=NativeTextfieldViewsTest.*
Review URL: https://codereview.chromium.org/101603002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238686 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/render_text.h')
-rw-r--r-- | ui/gfx/render_text.h | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h index bafe6af..8696d69 100644 --- a/ui/gfx/render_text.h +++ b/ui/gfx/render_text.h @@ -354,12 +354,19 @@ class GFX_EXPORT RenderText { // Gets the SelectionModel from a visual point in local coordinates. virtual SelectionModel FindCursorPosition(const Point& point) = 0; - // Get the visual bounds of a cursor at |selection|. These bounds typically - // represent a vertical line, but if |insert_mode| is true they contain the - // bounds of the associated glyph. These bounds are in local coordinates, but - // may be outside the visible region if the text is longer than the textfield. - // Subsequent text, cursor, or bounds changes may invalidate returned values. - Rect GetCursorBounds(const SelectionModel& selection, bool insert_mode); + // Return true if cursor can appear in front of the character at |position|, + // which means it is a grapheme boundary or the first character in the text. + virtual bool IsCursorablePosition(size_t position) = 0; + + // Get the visual bounds of a cursor at |caret|. These bounds typically + // represent a vertical line if |insert_mode| is true. Pass false for + // |insert_mode| to retrieve the bounds of the associated glyph. These bounds + // are in local coordinates, but may be outside the visible region if the text + // is longer than the textfield. Subsequent text, cursor, or bounds changes + // may invalidate returned values. Note that |caret| must be placed at + // grapheme boundary, that is, |IsCursorablePosition(caret.caret_pos())| must + // return true. + Rect GetCursorBounds(const SelectionModel& caret, bool insert_mode); // Compute the current cursor bounds, panning the text to show the cursor in // the display rect if necessary. These bounds are in local coordinates. @@ -473,10 +480,6 @@ class GFX_EXPORT RenderText { virtual size_t TextIndexToLayoutIndex(size_t index) const = 0; virtual size_t LayoutIndexToTextIndex(size_t index) const = 0; - // Return true if cursor can appear in front of the character at |position|, - // which means it is a grapheme boundary or the first character in the text. - virtual bool IsCursorablePosition(size_t position) = 0; - // Reset the layout to be invalid. virtual void ResetLayout() = 0; |