diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 23:24:43 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 23:24:43 +0000 |
commit | 2c355c28429a0e9c0b92b93ea95e5d1c0963511e (patch) | |
tree | ca1817802c7ab5091b7cf01af0b266a9d2c60953 /chrome | |
parent | 6f7dc659e8296738804e842129fd1fd61d4daabc (diff) | |
download | chromium_src-2c355c28429a0e9c0b92b93ea95e5d1c0963511e.zip chromium_src-2c355c28429a0e9c0b92b93ea95e5d1c0963511e.tar.gz chromium_src-2c355c28429a0e9c0b92b93ea95e5d1c0963511e.tar.bz2 |
Find box regression: Doesn't move if obscuring. The problem is that we get multiple messages from the renderer about the status of the find operation and some contain the selection rect (others don't). Therefore, we have to use the last known good selection rect if none is passed in.
BUG=12463
TEST=Covered by in-process browser test now.
Review URL: http://codereview.chromium.org/115667
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/find_bar_win_browsertest.cc | 40 | ||||
-rw-r--r-- | chrome/test/data/find_in_page/move_if_obscuring.html | 7 |
3 files changed, 52 insertions, 1 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index c136625..776a5b5 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -2309,10 +2309,14 @@ void TabContents::OnFindReply(int request_id, if (active_match_ordinal == -1) active_match_ordinal = find_result_.active_match_ordinal(); + gfx::Rect selection = selection_rect; + if (selection.IsEmpty()) + selection = find_result_.selection_rect(); + // Notify the UI, automation and any other observers that a find result was // found. find_result_ = FindNotificationDetails(request_id, number_of_matches, - selection_rect, active_match_ordinal, + selection, active_match_ordinal, final_update); NotificationService::current()->Notify( NotificationType::FIND_RESULT_AVAILABLE, diff --git a/chrome/browser/views/find_bar_win_browsertest.cc b/chrome/browser/views/find_bar_win_browsertest.cc index b24f229..2b173da 100644 --- a/chrome/browser/views/find_bar_win_browsertest.cc +++ b/chrome/browser/views/find_bar_win_browsertest.cc @@ -22,6 +22,7 @@ const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html"; const std::wstring kTooFewMatchesPage = L"files/find_in_page/bug_1155639.html"; const std::wstring kEndState = L"files/find_in_page/end_state.html"; const std::wstring kPrematureEnd = L"files/find_in_page/premature_end.html"; +const std::wstring kMoveIfOver = L"files/find_in_page/move_if_obscuring.html"; class FindInPageNotificationObserver : public NotificationObserver { public: @@ -487,3 +488,42 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, EXPECT_FALSE(fully_visible); } +// Make sure Find box moves out of the way if it is obscuring the active match. +IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindMovesWhenObscuring) { + HTTPTestServer* server = StartHTTPServer(); + + GURL url = server->TestServerPageW(kMoveIfOver); + ui_test_utils::NavigateToURL(browser(), url); + + // Open the Find window with animations disabled. + FindBarWin::disable_animations_during_testing_ = true; + browser()->ShowFindBar(); + + gfx::Point start_position; + gfx::Point position; + bool fully_visible = false; + + // Make sure it is open. + GetFindBarWindowInfo(&start_position, &fully_visible); + EXPECT_TRUE(fully_visible); + + // Search for 'dream' which the Find box is obscuring. + int ordinal = 0; + EXPECT_EQ(1, FindInPage(L"dream", FWD, IGNORE_CASE, false, &ordinal)); + EXPECT_EQ(1, ordinal); + + // Make sure Find box has moved. + GetFindBarWindowInfo(&position, &fully_visible); + EXPECT_EQ(start_position.y(), position.y()); + EXPECT_NE(start_position.x(), position.x()); + EXPECT_TRUE(fully_visible); + + // Search for 'Too much' which the Find box is not obscuring. + EXPECT_EQ(1, FindInPage(L"Too much", FWD, IGNORE_CASE, false, &ordinal)); + EXPECT_EQ(1, ordinal); + + // Make sure Find box has moved back to its original location. + GetFindBarWindowInfo(&position, &fully_visible); + EXPECT_EQ(start_position, position); + EXPECT_TRUE(fully_visible); +} diff --git a/chrome/test/data/find_in_page/move_if_obscuring.html b/chrome/test/data/find_in_page/move_if_obscuring.html new file mode 100644 index 0000000..8ca8080 --- /dev/null +++ b/chrome/test/data/find_in_page/move_if_obscuring.html @@ -0,0 +1,7 @@ +<html>
+<body>
+ <div align="right">"All day I dream about Essex."</div>
+<br><br><br>
+"Too much Essex makes your eyes go screwey"
+</body>
+</html>
|