summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-14 20:14:24 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-14 20:14:24 +0000
commit3db4da761ef830846c8a1f6b62e9c0d91392a28c (patch)
tree895f96d25f496e01d7d2e55a4933844a16a9e44f /chrome
parent7bea1c588a1951e65f525cdab0e99c0839be691c (diff)
downloadchromium_src-3db4da761ef830846c8a1f6b62e9c0d91392a28c.zip
chromium_src-3db4da761ef830846c8a1f6b62e9c0d91392a28c.tar.gz
chromium_src-3db4da761ef830846c8a1f6b62e9c0d91392a28c.tar.bz2
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
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/find_bar_view.cc20
-rw-r--r--chrome/browser/views/find_bar_win.cc29
-rw-r--r--chrome/browser/views/find_bar_win.h9
3 files changed, 35 insertions, 23 deletions
diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc
index 888c4f6..f348c29 100644
--- a/chrome/browser/views/find_bar_view.cc
+++ b/chrome/browser/views/find_bar_view.cc
@@ -479,6 +479,12 @@ bool FindBarView::HandleKeystroke(views::TextField* sender, UINT message,
if (!container_->IsVisible())
return false;
+ // TODO(port): Handle this for other platforms.
+ #if defined(OS_WIN)
+ if (container_->MaybeForwardKeystrokeToWebpage(message, key, flags))
+ return true; // Handled, we are done!
+ #endif
+
switch (key) {
case VK_RETURN: {
// Pressing Return/Enter starts the search (unless text box is empty).
@@ -491,20 +497,6 @@ bool FindBarView::HandleKeystroke(views::TextField* sender, UINT message,
}
break;
}
-#if defined(OS_WIN)
- // TODO(port): Handle this for other platforms.
- 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
- container_->ForwardKeystrokeToWebpage(key);
- return true; // Message has been handled. No further processing needed.
-#endif
}
return false;
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;
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/find_bar_win.h b/chrome/browser/views/find_bar_win.h
index d2f84fa..81e9176 100644
--- a/chrome/browser/views/find_bar_win.h
+++ b/chrome/browser/views/find_bar_win.h
@@ -59,10 +59,11 @@ class FindBarWin : public views::FocusChangeListener,
// new |parent_hwnd|.
void SetFocusChangeListener(HWND parent_hwnd);
- // Forwards keystrokes to the renderer. This is useful to make sure that
- // arrow keys and PageUp and PageDown result in scrolling, instead of
- // being eaten because the FindBar has focus.
- void ForwardKeystrokeToWebpage(TCHAR key);
+ // Forwards selected keystrokes to the renderer. This is useful to make sure
+ // that arrow keys and PageUp and PageDown result in scrolling, instead of
+ // being eaten because the FindBar has focus. Returns true if the keystroke
+ // was forwarded, false if not.
+ bool MaybeForwardKeystrokeToWebpage(UINT message, TCHAR key, UINT flags);
// FindBar implementation:
virtual FindBarController* GetFindBarController() const {