diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-02 21:59:46 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-02 21:59:46 +0000 |
commit | edef258aa295277055742ac573fab885512fa801 (patch) | |
tree | 77c73032c9cff7dab0fcb836ff950ba324965c8f /ui/views | |
parent | 4ef2de0e99609cafa71be8c1a168eb95e305e75a (diff) | |
download | chromium_src-edef258aa295277055742ac573fab885512fa801.zip chromium_src-edef258aa295277055742ac573fab885512fa801.tar.gz chromium_src-edef258aa295277055742ac573fab885512fa801.tar.bz2 |
Fix RenderText offset issue with trailing cursors.
The text display offset is unstable with a cursor at the end.
Some text moves by 1px when setting a trailing cursor, etc.
The -1 and >= from xji's http://crrev.com/99998 were okay at the time.
Since then, GetContentWidth has accounted for the cursor width.
Remove the OBO error in offset calculation to fix this.
No-op when (cursor.right == display.right), it's visible.
The text I tested is stable and still shows trailing cursors.
BUG=104150,131660,239635,266826
TEST=Long Views Textfield text doesn't jiggle by 1px with a trailing cursor/selection.
R=asvitkine@chromium.org,ckocagil@chromium.org
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/20912004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215377 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r-- | ui/views/controls/textfield/native_textfield_views_unittest.cc | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/ui/views/controls/textfield/native_textfield_views_unittest.cc b/ui/views/controls/textfield/native_textfield_views_unittest.cc index dd9eef9..a56905c 100644 --- a/ui/views/controls/textfield/native_textfield_views_unittest.cc +++ b/ui/views/controls/textfield/native_textfield_views_unittest.cc @@ -1680,16 +1680,6 @@ TEST_F(NativeTextfieldViewsTest, HitOutsideTextAreaInRTLTest) { base::i18n::SetICUDefaultLocale(locale); } -// This verifies that |bound| is contained by |display|. |bound|'s right edge -// must be less than |diaplay|'s right edge. -void OverflowCursorBoundTestVerifier(const gfx::Rect& display, - const gfx::Rect& bound) { - EXPECT_LE(display.x(), bound.x()); - EXPECT_GT(display.right(), bound.right()); - EXPECT_LE(display.y(), bound.y()); - EXPECT_GE(display.bottom(), bound.bottom()); -} - TEST_F(NativeTextfieldViewsTest, OverflowTest) { InitTextfield(Textfield::STYLE_DEFAULT); @@ -1697,12 +1687,10 @@ TEST_F(NativeTextfieldViewsTest, OverflowTest) { for (int i = 0; i < 500; ++i) SendKeyEvent('a'); SendKeyEvent(kHebrewLetterSamekh); - gfx::Rect bound = GetCursorBounds(); - gfx::Rect display = GetDisplayRect(); - OverflowCursorBoundTestVerifier(display, bound); + EXPECT_TRUE(GetDisplayRect().Contains(GetCursorBounds())); // Test mouse pointing. - MouseClick(bound, -1); + MouseClick(GetCursorBounds(), -1); EXPECT_EQ(500U, textfield_->GetCursorPosition()); // Clear text. @@ -1712,11 +1700,9 @@ TEST_F(NativeTextfieldViewsTest, OverflowTest) { for (int i = 0; i < 500; ++i) SendKeyEvent(kHebrewLetterSamekh); SendKeyEvent('a'); - bound = GetCursorBounds(); - display = GetDisplayRect(); - OverflowCursorBoundTestVerifier(display, bound); + EXPECT_TRUE(GetDisplayRect().Contains(GetCursorBounds())); - MouseClick(bound, -1); + MouseClick(GetCursorBounds(), -1); EXPECT_EQ(501U, textfield_->GetCursorPosition()); } @@ -1730,11 +1716,9 @@ TEST_F(NativeTextfieldViewsTest, OverflowInRTLTest) { for (int i = 0; i < 500; ++i) SendKeyEvent('a'); SendKeyEvent(kHebrewLetterSamekh); - gfx::Rect bound = GetCursorBounds(); - gfx::Rect display = GetDisplayRect(); - OverflowCursorBoundTestVerifier(display, bound); + EXPECT_TRUE(GetDisplayRect().Contains(GetCursorBounds())); - MouseClick(bound, 1); + MouseClick(GetCursorBounds(), 1); EXPECT_EQ(501U, textfield_->GetCursorPosition()); // Clear text. @@ -1744,21 +1728,10 @@ TEST_F(NativeTextfieldViewsTest, OverflowInRTLTest) { for (int i = 0; i < 500; ++i) SendKeyEvent(kHebrewLetterSamekh); SendKeyEvent('a'); - bound = GetCursorBounds(); - display = GetDisplayRect(); - OverflowCursorBoundTestVerifier(display, bound); - - -#if !defined(OS_WIN) - // TODO(jennyz): NonClientMouseClick() does not work for os_win builds; - // see crbug.com/104150. The mouse click in the next test will be confused - // as a double click, which breaks the test. Disable the test until the - // issue is fixed. - NonClientMouseClick(); + EXPECT_TRUE(GetDisplayRect().Contains(GetCursorBounds())); - MouseClick(bound, 1); + MouseClick(GetCursorBounds(), 1); EXPECT_EQ(500U, textfield_->GetCursorPosition()); -#endif // !defined(OS_WIN) // Reset locale. base::i18n::SetICUDefaultLocale(locale); |