From 3db4da761ef830846c8a1f6b62e9c0d91392a28c Mon Sep 17 00:00:00 2001 From: "finnur@chromium.org" Date: Tue, 14 Apr 2009 20:14:24 +0000 Subject: A fix for the Find box forwarding scroll messages to the page when it shouldn't. TEST=Open Find on a page with scrollbars, type in 'nomatch', scroll to the middle of the page, set the cursor at the end of the Find text field and add '!', '(' and ')' to the search string. Make sure the page doesn't scroll. BUG=10509 Review URL: http://codereview.chromium.org/67135 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13696 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/views/find_bar_win.cc | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'chrome/browser/views/find_bar_win.cc') diff --git a/chrome/browser/views/find_bar_win.cc b/chrome/browser/views/find_bar_win.cc index a1d01a9..d85c2ef 100644 --- a/chrome/browser/views/find_bar_win.cc +++ b/chrome/browser/views/find_bar_win.cc @@ -232,10 +232,30 @@ void FindBarWin::MoveWindowIfNecessary(const gfx::Rect& selection_rect, view_->SchedulePaint(); } -void FindBarWin::ForwardKeystrokeToWebpage(TCHAR key) { +bool FindBarWin::MaybeForwardKeystrokeToWebpage( + UINT message, TCHAR key, UINT flags) { + // We specifically ignore WM_CHAR. See http://crbug.com/10509. + if (message != WM_KEYDOWN && message != WM_KEYUP) + return false; + + switch (key) { + case VK_HOME: + case VK_END: + // Ctrl+Home and Ctrl+End should be forwarded to the page. + if (GetKeyState(VK_CONTROL) >= 0) + return false; // Ctrl not pressed: Abort. Otherwise fall through. + case VK_UP: + case VK_DOWN: + case VK_PRIOR: // Page up + case VK_NEXT: // Page down + break; // The keys above are the ones we want to forward to the page. + default: + return false; + } + WebContents* contents = find_bar_controller_->web_contents(); if (!contents) - return; + return false; RenderViewHost* render_view_host = contents->render_view_host(); @@ -245,9 +265,8 @@ void FindBarWin::ForwardKeystrokeToWebpage(TCHAR key) { HWND hwnd = contents->GetContentNativeView(); render_view_host->ForwardKeyboardEvent( - NativeWebKeyboardEvent(hwnd, WM_KEYDOWN, key, 0)); - render_view_host->ForwardKeyboardEvent( - NativeWebKeyboardEvent(hwnd, WM_KEYUP, key, 0)); + NativeWebKeyboardEvent(hwnd, message, key, 0)); + return true; } //////////////////////////////////////////////////////////////////////////////// -- cgit v1.1