summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-17 03:20:10 +0000
committerhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-17 03:20:10 +0000
commitfc9384590f192b79b4f6f071a5b1fc3257f45c28 (patch)
treedcb9b9a292e3354bb5848f1cea57190f4dcaceac /webkit/glue
parent4855b874911cb79535e0bc275dbb51dd13bf6390 (diff)
downloadchromium_src-fc9384590f192b79b4f6f071a5b1fc3257f45c28.zip
chromium_src-fc9384590f192b79b4f6f071a5b1fc3257f45c28.tar.gz
chromium_src-fc9384590f192b79b4f6f071a5b1fc3257f45c28.tar.bz2
A quick fix for Issue 18844 (Take 2).
This is the same change as <http://codereview.chromium.org/164309> that I reverted to investigate a test_shell_test failure (Issue 19263). 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/165523 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/webview_impl.cc24
-rw-r--r--webkit/glue/webview_impl.h2
2 files changed, 22 insertions, 4 deletions
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 0b66f06..e94baac 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -811,7 +811,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;
}
@@ -838,7 +838,7 @@ bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) {
}
}
if (!event.isSystemKey) {
- return ScrollViewWithKeyboard(event.windowsKeyCode);
+ return ScrollViewWithKeyboard(event.windowsKeyCode, event.modifiers);
}
break;
}
@@ -849,7 +849,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;
@@ -868,11 +868,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;
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index 275faed..17b139b 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -282,7 +282,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
void RefreshAutofillPopup();
// Returns true if the view was scrolled.
- bool ScrollViewWithKeyboard(int key_code);
+ bool ScrollViewWithKeyboard(int key_code, int modifiers);
// Removes fetcher from the set of pending image fetchers and deletes it.
// This is invoked after the download is completed (or fails).