Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Side by Side Diff: webkit/glue/webview_impl.cc

Issue 254002: Fix cmd-up/cmd-down. (Closed)
Patch Set: Fix typo found by suzhe Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« webkit/glue/webframe_impl.cc ('K') | « webkit/glue/webview_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2007-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2007-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 MSVC_PUSH_WARNING_LEVEL(0); 9 MSVC_PUSH_WARNING_LEVEL(0);
10 #include "CSSStyleSelector.h" 10 #include "CSSStyleSelector.h"
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 break; 855 break;
856 } 856 }
857 857
858 default: 858 default:
859 break; 859 break;
860 } 860 }
861 return false; 861 return false;
862 } 862 }
863 863
864 bool WebViewImpl::ScrollViewWithKeyboard(int key_code, int modifiers) { 864 bool WebViewImpl::ScrollViewWithKeyboard(int key_code, int modifiers) {
865 Frame* frame = GetFocusedWebCoreFrame();
866 if (!frame)
867 return false;
868
869 ScrollDirection scroll_direction; 865 ScrollDirection scroll_direction;
870 ScrollGranularity scroll_granularity; 866 ScrollGranularity scroll_granularity;
871 867
872 switch (key_code) { 868 switch (key_code) {
873 case VKEY_LEFT: 869 case VKEY_LEFT:
874 scroll_direction = ScrollLeft; 870 scroll_direction = ScrollLeft;
875 scroll_granularity = ScrollByLine; 871 scroll_granularity = ScrollByLine;
876 break; 872 break;
877 case VKEY_RIGHT: 873 case VKEY_RIGHT:
878 scroll_direction = ScrollRight; 874 scroll_direction = ScrollRight;
879 scroll_granularity = ScrollByLine; 875 scroll_granularity = ScrollByLine;
880 break; 876 break;
881 case VKEY_UP: 877 case VKEY_UP:
882 scroll_direction = ScrollUp; 878 scroll_direction = ScrollUp;
883 #if defined(OS_MACOSX)
884 // Many Mac applications (such as TextEdit, Safari, Firefox, etc.) scroll
885 // to the beginning of a page when typing command+up keys. It is better
886 // for Mac Chrome to emulate this behavior to improve compatibility with
887 // these applications.
888 scroll_granularity = (modifiers == WebInputEvent::MetaKey) ?
889 ScrollByDocument : ScrollByLine;
890 #else
891 scroll_granularity = ScrollByLine; 879 scroll_granularity = ScrollByLine;
892 #endif
893 break; 880 break;
894 case VKEY_DOWN: 881 case VKEY_DOWN:
895 scroll_direction = ScrollDown; 882 scroll_direction = ScrollDown;
896 #if defined(OS_MACOSX)
897 // Many Mac applications (such as TextEdit, Safari, Firefox, etc.) scroll
898 // to the end of a page when typing command+down keys. It is better
899 // for Mac Chrome to emulate this behavior to improve compatibility with
900 // these applications.
901 scroll_granularity = (modifiers == WebInputEvent::MetaKey) ?
902 ScrollByDocument : ScrollByLine;
903 #else
904 scroll_granularity = ScrollByLine; 883 scroll_granularity = ScrollByLine;
905 #endif
906 break; 884 break;
907 case VKEY_HOME: 885 case VKEY_HOME:
908 scroll_direction = ScrollUp; 886 scroll_direction = ScrollUp;
909 scroll_granularity = ScrollByDocument; 887 scroll_granularity = ScrollByDocument;
910 break; 888 break;
911 case VKEY_END: 889 case VKEY_END:
912 scroll_direction = ScrollDown; 890 scroll_direction = ScrollDown;
913 scroll_granularity = ScrollByDocument; 891 scroll_granularity = ScrollByDocument;
914 break; 892 break;
915 case VKEY_PRIOR: // page up 893 case VKEY_PRIOR: // page up
916 scroll_direction = ScrollUp; 894 scroll_direction = ScrollUp;
917 scroll_granularity = ScrollByPage; 895 scroll_granularity = ScrollByPage;
918 break; 896 break;
919 case VKEY_NEXT: // page down 897 case VKEY_NEXT: // page down
920 scroll_direction = ScrollDown; 898 scroll_direction = ScrollDown;
921 scroll_granularity = ScrollByPage; 899 scroll_granularity = ScrollByPage;
922 break; 900 break;
923 default: 901 default:
924 return false; 902 return false;
925 } 903 }
926 904
905 return PropagateScroll(scroll_direction, scroll_granularity);
906 }
907
908 bool WebViewImpl::PropagateScroll(
909 WebCore::ScrollDirection scroll_direction,
910 WebCore::ScrollGranularity scroll_granularity) {
911
912 Frame* frame = GetFocusedWebCoreFrame();
913 if (!frame)
914 return false;
915
927 bool scroll_handled = 916 bool scroll_handled =
928 frame->eventHandler()->scrollOverflow(scroll_direction, 917 frame->eventHandler()->scrollOverflow(scroll_direction,
929 scroll_granularity); 918 scroll_granularity);
930 Frame* current_frame = frame; 919 Frame* current_frame = frame;
931 while (!scroll_handled && current_frame) { 920 while (!scroll_handled && current_frame) {
932 scroll_handled = current_frame->view()->scroll(scroll_direction, 921 scroll_handled = current_frame->view()->scroll(scroll_direction,
933 scroll_granularity); 922 scroll_granularity);
934 current_frame = current_frame->tree()->parent(); 923 current_frame = current_frame->tree()->parent();
935 } 924 }
936 return scroll_handled; 925 return scroll_handled;
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 return spelling_panel_is_visible_; 1924 return spelling_panel_is_visible_;
1936 } 1925 }
1937 1926
1938 void WebViewImpl::SetTabsToLinks(bool enable) { 1927 void WebViewImpl::SetTabsToLinks(bool enable) {
1939 tabs_to_links_ = enable; 1928 tabs_to_links_ = enable;
1940 } 1929 }
1941 1930
1942 bool WebViewImpl::GetTabsToLinks() const { 1931 bool WebViewImpl::GetTabsToLinks() const {
1943 return tabs_to_links_; 1932 return tabs_to_links_;
1944 } 1933 }
OLDNEW
« webkit/glue/webframe_impl.cc ('K') | « webkit/glue/webview_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698