Commit 5014480e authored by Matt Giuca's avatar Matt Giuca Committed by Commit Bot

Views Omnibox: Fixed text being selected even after blur event.

This regressed in r473830 (blurring the Omnibox then mouse-overing
resulted in an arrow cursor, not an I-beam). Now it properly deselects,
so the cursor shows as an I-beam again.

Bug: 740008
Change-Id: Ice2b4fdb21acf642bdf928c07c40beec5639274f
Reviewed-on: https://chromium-review.googlesource.com/563143
Commit-Queue: Matt Giuca <mgiuca@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487386}
parent 6500b0c3
......@@ -796,6 +796,9 @@ void OmniboxViewViews::OnBlur() {
// Tell the model to reset itself.
model()->OnKillFocus();
// Deselect the text. Ensures the cursor is an I-beam.
SelectRange(gfx::Range(0));
// When deselected, elide and reset scroll position. After eliding, the old
// scroll offset is meaningless (since the string is guaranteed to fit within
// the view). The scroll must be reset or the text may be rendered partly or
......
......@@ -149,9 +149,10 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, SelectAllOnClick) {
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
EXPECT_TRUE(omnibox_view->IsSelectAll());
// Clicking in another view should clear focus.
// Clicking in another view should clear focus and the selection.
ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter());
EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
EXPECT_FALSE(omnibox_view->IsSelectAll());
// Clicking in the omnibox again should take focus and select all text again.
ASSERT_NO_FATAL_FAILURE(Click(ui_controls::LEFT,
......@@ -244,6 +245,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, SelectAllOnTap) {
// Take the focus away from the omnibox.
ASSERT_NO_FATAL_FAILURE(TapBrowserWindowCenter());
EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
EXPECT_FALSE(omnibox_view->IsSelectAll());
// Tapping in the omnibox should take focus and select all text.
const gfx::Rect omnibox_bounds = BrowserView::GetBrowserViewForBrowser(
......@@ -253,9 +255,10 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, SelectAllOnTap) {
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
EXPECT_TRUE(omnibox_view->IsSelectAll());
// Tapping in another view should clear focus.
// Tapping in another view should clear focus and the selection.
ASSERT_NO_FATAL_FAILURE(TapBrowserWindowCenter());
EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
EXPECT_FALSE(omnibox_view->IsSelectAll());
// Tapping in the omnibox again should take focus and select all text again.
ASSERT_NO_FATAL_FAILURE(Tap(tap_location, tap_location));
......
......@@ -329,6 +329,8 @@ TEST_F(OmniboxViewViewsTest, OnBlur) {
// the entire domain fits in 60 pixels. However, 60px is so small it should
// never happen with any font.
EXPECT_GT(0, render_text->GetUpdatedDisplayOffset().x());
omnibox_view()->SelectAll(false);
EXPECT_TRUE(omnibox_view()->IsSelectAll());
// Now enter blurred mode, where the text should be elided to 60px. This means
// the string itself is truncated. Scrolling would therefore mean the text is
......@@ -336,6 +338,7 @@ TEST_F(OmniboxViewViewsTest, OnBlur) {
omnibox_view()->OnBlur();
EXPECT_EQ(gfx::ELIDE_TAIL, render_text->elide_behavior());
EXPECT_EQ(0, render_text->GetUpdatedDisplayOffset().x());
EXPECT_FALSE(omnibox_view()->IsSelectAll());
}
TEST_F(OmniboxViewViewsTest, Emphasis) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment