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

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

Issue 164309: A quick fix for Issue 18844.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « 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 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) { 803 bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) {
804 Frame* frame = GetFocusedWebCoreFrame(); 804 Frame* frame = GetFocusedWebCoreFrame();
805 if (!frame) 805 if (!frame)
806 return false; 806 return false;
807 807
808 switch (event.type) { 808 switch (event.type) {
809 case WebInputEvent::Char: { 809 case WebInputEvent::Char: {
810 if (event.windowsKeyCode == VKEY_SPACE) { 810 if (event.windowsKeyCode == VKEY_SPACE) {
811 int key_code = ((event.modifiers & WebInputEvent::ShiftKey) ? 811 int key_code = ((event.modifiers & WebInputEvent::ShiftKey) ?
812 VKEY_PRIOR : VKEY_NEXT); 812 VKEY_PRIOR : VKEY_NEXT);
813 return ScrollViewWithKeyboard(key_code); 813 return ScrollViewWithKeyboard(key_code, event.modifiers);
814 } 814 }
815 break; 815 break;
816 } 816 }
817 817
818 case WebInputEvent::RawKeyDown: { 818 case WebInputEvent::RawKeyDown: {
819 if (event.modifiers == WebInputEvent::ControlKey) { 819 if (event.modifiers == WebInputEvent::ControlKey) {
820 switch (event.windowsKeyCode) { 820 switch (event.windowsKeyCode) {
821 case 'A': 821 case 'A':
822 GetFocusedFrame()->selectAll(); 822 GetFocusedFrame()->selectAll();
823 return true; 823 return true;
824 case VKEY_INSERT: 824 case VKEY_INSERT:
825 case 'C': 825 case 'C':
826 GetFocusedFrame()->executeCommand(WebString::fromUTF8("Copy")); 826 GetFocusedFrame()->executeCommand(WebString::fromUTF8("Copy"));
827 return true; 827 return true;
828 // Match FF behavior in the sense that Ctrl+home/end are the only Ctrl 828 // Match FF behavior in the sense that Ctrl+home/end are the only Ctrl
829 // key combinations which affect scrolling. Safari is buggy in the 829 // key combinations which affect scrolling. Safari is buggy in the
830 // sense that it scrolls the page for all Ctrl+scrolling key 830 // sense that it scrolls the page for all Ctrl+scrolling key
831 // combinations. For e.g. Ctrl+pgup/pgdn/up/down, etc. 831 // combinations. For e.g. Ctrl+pgup/pgdn/up/down, etc.
832 case VKEY_HOME: 832 case VKEY_HOME:
833 case VKEY_END: 833 case VKEY_END:
834 break; 834 break;
835 default: 835 default:
836 return false; 836 return false;
837 } 837 }
838 } 838 }
839 if (!event.isSystemKey) { 839 if (!event.isSystemKey) {
840 return ScrollViewWithKeyboard(event.windowsKeyCode); 840 return ScrollViewWithKeyboard(event.windowsKeyCode, event.modifiers);
841 } 841 }
842 break; 842 break;
843 } 843 }
844 844
845 default: 845 default:
846 break; 846 break;
847 } 847 }
848 return false; 848 return false;
849 } 849 }
850 850
851 bool WebViewImpl::ScrollViewWithKeyboard(int key_code) { 851 bool WebViewImpl::ScrollViewWithKeyboard(int key_code, int modifiers) {
852 Frame* frame = GetFocusedWebCoreFrame(); 852 Frame* frame = GetFocusedWebCoreFrame();
853 if (!frame) 853 if (!frame)
854 return false; 854 return false;
855 855
856 ScrollDirection scroll_direction; 856 ScrollDirection scroll_direction;
857 ScrollGranularity scroll_granularity; 857 ScrollGranularity scroll_granularity;
858 858
859 switch (key_code) { 859 switch (key_code) {
860 case VKEY_LEFT: 860 case VKEY_LEFT:
861 scroll_direction = ScrollLeft; 861 scroll_direction = ScrollLeft;
862 scroll_granularity = ScrollByLine; 862 scroll_granularity = ScrollByLine;
863 break; 863 break;
864 case VKEY_RIGHT: 864 case VKEY_RIGHT:
865 scroll_direction = ScrollRight; 865 scroll_direction = ScrollRight;
866 scroll_granularity = ScrollByLine; 866 scroll_granularity = ScrollByLine;
867 break; 867 break;
868 case VKEY_UP: 868 case VKEY_UP:
869 scroll_direction = ScrollUp; 869 scroll_direction = ScrollUp;
870 #if defined(OS_MACOSX)
871 // Many Mac applications (such as TextEdit, Safari, Firefox, etc.) scroll
872 // to the beginning of a page when typing command+up keys. It is better
873 // for Mac Chrome to emulate this behavior to improve compatibility with
874 // these applications.
875 scroll_granularity = (modifiers == WebInputEvent::MetaKey) ?
876 ScrollByDocument : ScrollByLine;
877 #else
870 scroll_granularity = ScrollByLine; 878 scroll_granularity = ScrollByLine;
879 #endif
871 break; 880 break;
872 case VKEY_DOWN: 881 case VKEY_DOWN:
873 scroll_direction = ScrollDown; 882 scroll_direction = ScrollDown;
883 #if defined(OS_MACOSX)
884 // Many Mac applications (such as TextEdit, Safari, Firefox, etc.) scroll
885 // to the end of a page when typing command+down 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
874 scroll_granularity = ScrollByLine; 891 scroll_granularity = ScrollByLine;
892 #endif
875 break; 893 break;
876 case VKEY_HOME: 894 case VKEY_HOME:
877 scroll_direction = ScrollUp; 895 scroll_direction = ScrollUp;
878 scroll_granularity = ScrollByDocument; 896 scroll_granularity = ScrollByDocument;
879 break; 897 break;
880 case VKEY_END: 898 case VKEY_END:
881 scroll_direction = ScrollDown; 899 scroll_direction = ScrollDown;
882 scroll_granularity = ScrollByDocument; 900 scroll_granularity = ScrollByDocument;
883 break; 901 break;
884 case VKEY_PRIOR: // page up 902 case VKEY_PRIOR: // page up
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 1968
1951 return document->focusedNode(); 1969 return document->focusedNode();
1952 } 1970 }
1953 1971
1954 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { 1972 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) {
1955 IntPoint doc_point( 1973 IntPoint doc_point(
1956 page_->mainFrame()->view()->windowToContents(pos)); 1974 page_->mainFrame()->view()->windowToContents(pos));
1957 return page_->mainFrame()->eventHandler()-> 1975 return page_->mainFrame()->eventHandler()->
1958 hitTestResultAtPoint(doc_point, false); 1976 hitTestResultAtPoint(doc_point, false);
1959 } 1977 }
OLDNEW
« no previous file with comments | « webkit/glue/webview_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698