summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webview_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue/webview_impl.cc')
-rw-r--r--webkit/glue/webview_impl.cc24
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;