diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-13 06:03:39 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-13 06:03:39 +0000 |
commit | eab4c71093435dda84d09645370e9767eb70ac52 (patch) | |
tree | 3b42508b0b00ad866da6b4da1cf72ecb94a7e03e /webkit/glue/webview_impl.cc | |
parent | a2cf8049dab2715b71f9050ea971dc6dc2340c03 (diff) | |
download | chromium_src-eab4c71093435dda84d09645370e9767eb70ac52.zip chromium_src-eab4c71093435dda84d09645370e9767eb70ac52.tar.gz chromium_src-eab4c71093435dda84d09645370e9767eb70ac52.tar.bz2 |
A quick fix for Issue 18844.
This change checks if the modifier flag is a WebInputEvent::MetaKey flag to switch the scroll granularity when a user types a up/down key.
Editor::Commands ("MoveToBeginningOfDocument" and "MoveToEndOfDocument") works only in an editable control, such as <textarea>. On the other hand, this WebViewImpl::ScrollViewWithKeyboard() is for scrolling a page.
BUG=18844 "Apple (command) key + down arrow is not working"
TEST=Type command+down keys in a web page which contains a scroll bar, and verify Chrome scrolls the page to its end.
Review URL: http://codereview.chromium.org/164309
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23285 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webview_impl.cc')
-rw-r--r-- | webkit/glue/webview_impl.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 6d8f05a..17db403 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -807,7 +807,7 @@ bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) { if (event.windowsKeyCode == VKEY_SPACE) { int key_code = ((event.modifiers & WebInputEvent::ShiftKey) ? VKEY_PRIOR : VKEY_NEXT); - return ScrollViewWithKeyboard(key_code); + return ScrollViewWithKeyboard(key_code, event.modifiers); } break; } @@ -834,7 +834,7 @@ bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) { } } if (!event.isSystemKey) { - return ScrollViewWithKeyboard(event.windowsKeyCode); + return ScrollViewWithKeyboard(event.windowsKeyCode, event.modifiers); } break; } @@ -845,7 +845,7 @@ bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) { return false; } -bool WebViewImpl::ScrollViewWithKeyboard(int key_code) { +bool WebViewImpl::ScrollViewWithKeyboard(int key_code, int modifiers) { Frame* frame = GetFocusedWebCoreFrame(); if (!frame) return false; @@ -864,11 +864,29 @@ bool WebViewImpl::ScrollViewWithKeyboard(int key_code) { break; case VKEY_UP: scroll_direction = ScrollUp; +#if defined(OS_MACOSX) + // Many Mac applications (such as TextEdit, Safari, Firefox, etc.) scroll + // to the beginning of a page when typing command+up keys. It is better + // for Mac Chrome to emulate this behavior to improve compatibility with + // these applications. + scroll_granularity = (modifiers == WebInputEvent::MetaKey) ? + ScrollByDocument : ScrollByLine; +#else scroll_granularity = ScrollByLine; +#endif break; case VKEY_DOWN: scroll_direction = ScrollDown; +#if defined(OS_MACOSX) + // Many Mac applications (such as TextEdit, Safari, Firefox, etc.) scroll + // to the end of a page when typing command+down keys. It is better + // for Mac Chrome to emulate this behavior to improve compatibility with + // these applications. + scroll_granularity = (modifiers == WebInputEvent::MetaKey) ? + ScrollByDocument : ScrollByLine; +#else scroll_granularity = ScrollByLine; +#endif break; case VKEY_HOME: scroll_direction = ScrollUp; |