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

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 // That click triggered a page popup that is the same as the one we just 526 // That click triggered a page popup that is the same as the one we just
527 // closed. It needs to be closed. 527 // closed. It needs to be closed.
528 cancelPagePopup(); 528 cancelPagePopup();
529 } 529 }
530 530
531 // Dispatch the contextmenu event regardless of if the click was swallowed. 531 // Dispatch the contextmenu event regardless of if the click was swallowed.
532 if (!page()->settings().getShowContextMenuOnMouseUp()) { 532 if (!page()->settings().getShowContextMenuOnMouseUp()) {
533 #if OS(MACOSX) 533 #if OS(MACOSX)
534 if (event.button == WebMouseEvent::Button::Right || 534 if (event.button == WebMouseEvent::Button::Right ||
535 (event.button == WebMouseEvent::Button::Left && 535 (event.button == WebMouseEvent::Button::Left &&
536 event.modifiers & WebMouseEvent::ControlKey)) 536 event.modifiers() & WebMouseEvent::ControlKey))
537 mouseContextMenu(event); 537 mouseContextMenu(event);
538 #else 538 #else
539 if (event.button == WebMouseEvent::Button::Right) 539 if (event.button == WebMouseEvent::Button::Right)
540 mouseContextMenu(event); 540 mouseContextMenu(event);
541 #endif 541 #endif
542 } 542 }
543 } 543 }
544 544
545 void WebViewImpl::setDisplayMode(WebDisplayMode mode) { 545 void WebViewImpl::setDisplayMode(WebDisplayMode mode) {
546 m_displayMode = mode; 546 m_displayMode = mode;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 691
692 WebInputEventResult WebViewImpl::handleGestureEvent( 692 WebInputEventResult WebViewImpl::handleGestureEvent(
693 const WebGestureEvent& event) { 693 const WebGestureEvent& event) {
694 if (!m_client) 694 if (!m_client)
695 return WebInputEventResult::NotHandled; 695 return WebInputEventResult::NotHandled;
696 696
697 WebInputEventResult eventResult = WebInputEventResult::NotHandled; 697 WebInputEventResult eventResult = WebInputEventResult::NotHandled;
698 bool eventCancelled = false; // for disambiguation 698 bool eventCancelled = false; // for disambiguation
699 699
700 // Special handling for slow-path fling gestures. 700 // Special handling for slow-path fling gestures.
701 switch (event.type) { 701 switch (event.type()) {
702 case WebInputEvent::GestureFlingStart: { 702 case WebInputEvent::GestureFlingStart: {
703 if (mainFrameImpl() 703 if (mainFrameImpl()
704 ->frame() 704 ->frame()
705 ->eventHandler() 705 ->eventHandler()
706 .isScrollbarHandlingGestures()) 706 .isScrollbarHandlingGestures())
707 break; 707 break;
708 endActiveFlingAnimation(); 708 endActiveFlingAnimation();
709 m_client->cancelScheduledContentIntents(); 709 m_client->cancelScheduledContentIntents();
710 m_positionOnFlingStart = WebPoint(event.x, event.y); 710 m_positionOnFlingStart = WebPoint(event.x, event.y);
711 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); 711 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY);
712 m_flingModifier = event.modifiers; 712 m_flingModifier = event.modifiers();
713 m_flingSourceDevice = event.sourceDevice; 713 m_flingSourceDevice = event.sourceDevice;
714 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized); 714 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized);
715 std::unique_ptr<WebGestureCurve> flingCurve = 715 std::unique_ptr<WebGestureCurve> flingCurve =
716 WTF::wrapUnique(Platform::current()->createFlingAnimationCurve( 716 WTF::wrapUnique(Platform::current()->createFlingAnimationCurve(
717 event.sourceDevice, 717 event.sourceDevice,
718 WebFloatPoint(event.data.flingStart.velocityX, 718 WebFloatPoint(event.data.flingStart.velocityX,
719 event.data.flingStart.velocityY), 719 event.data.flingStart.velocityY),
720 WebSize())); 720 WebSize()));
721 DCHECK(flingCurve); 721 DCHECK(flingCurve);
722 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart( 722 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(
(...skipping 21 matching lines...) Expand all
744 return eventResult; 744 return eventResult;
745 default: 745 default:
746 break; 746 break;
747 } 747 }
748 748
749 WebGestureEvent scaledEvent = 749 WebGestureEvent scaledEvent =
750 TransformWebGestureEvent(mainFrameImpl()->frameView(), event); 750 TransformWebGestureEvent(mainFrameImpl()->frameView(), event);
751 751
752 // Special handling for double tap and scroll events as we don't want to 752 // Special handling for double tap and scroll events as we don't want to
753 // hit test for them. 753 // hit test for them.
754 switch (event.type) { 754 switch (event.type()) {
755 case WebInputEvent::GestureDoubleTap: 755 case WebInputEvent::GestureDoubleTap:
756 if (m_webSettings->doubleTapToZoomEnabled() && 756 if (m_webSettings->doubleTapToZoomEnabled() &&
757 minimumPageScaleFactor() != maximumPageScaleFactor()) { 757 minimumPageScaleFactor() != maximumPageScaleFactor()) {
758 m_client->cancelScheduledContentIntents(); 758 m_client->cancelScheduledContentIntents();
759 animateDoubleTapZoom( 759 animateDoubleTapZoom(
760 flooredIntPoint(scaledEvent.positionInRootFrame())); 760 flooredIntPoint(scaledEvent.positionInRootFrame()));
761 } 761 }
762 // GestureDoubleTap is currently only used by Android for zooming. For 762 // GestureDoubleTap is currently only used by Android for zooming. For
763 // WebCore, GestureTap with tap count = 2 is used instead. So we drop 763 // WebCore, GestureTap with tap count = 2 is used instead. So we drop
764 // GestureDoubleTap here. 764 // GestureDoubleTap here.
(...skipping 24 matching lines...) Expand all
789 } 789 }
790 790
791 // Hit test across all frames and do touch adjustment as necessary for the 791 // Hit test across all frames and do touch adjustment as necessary for the
792 // event type. 792 // event type.
793 GestureEventWithHitTestResults targetedEvent = 793 GestureEventWithHitTestResults targetedEvent =
794 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent( 794 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(
795 scaledEvent); 795 scaledEvent);
796 796
797 // Handle link highlighting outside the main switch to avoid getting lost in 797 // Handle link highlighting outside the main switch to avoid getting lost in
798 // the complicated set of cases handled below. 798 // the complicated set of cases handled below.
799 switch (event.type) { 799 switch (event.type()) {
800 case WebInputEvent::GestureShowPress: 800 case WebInputEvent::GestureShowPress:
801 // Queue a highlight animation, then hand off to regular handler. 801 // Queue a highlight animation, then hand off to regular handler.
802 enableTapHighlightAtPoint(targetedEvent); 802 enableTapHighlightAtPoint(targetedEvent);
803 break; 803 break;
804 case WebInputEvent::GestureTapCancel: 804 case WebInputEvent::GestureTapCancel:
805 case WebInputEvent::GestureTap: 805 case WebInputEvent::GestureTap:
806 case WebInputEvent::GestureLongPress: 806 case WebInputEvent::GestureLongPress:
807 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 807 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
808 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); 808 m_linkHighlights[i]->startHighlightAnimationIfNeeded();
809 break; 809 break;
810 default: 810 default:
811 break; 811 break;
812 } 812 }
813 813
814 switch (event.type) { 814 switch (event.type()) {
815 case WebInputEvent::GestureTap: { 815 case WebInputEvent::GestureTap: {
816 m_client->cancelScheduledContentIntents(); 816 m_client->cancelScheduledContentIntents();
817 if (detectContentOnTouch(targetedEvent)) { 817 if (detectContentOnTouch(targetedEvent)) {
818 eventResult = WebInputEventResult::HandledSystem; 818 eventResult = WebInputEventResult::HandledSystem;
819 break; 819 break;
820 } 820 }
821 821
822 // Don't trigger a disambiguation popup on sites designed for mobile 822 // Don't trigger a disambiguation popup on sites designed for mobile
823 // devices. Instead, assume that the page has been designed with big 823 // devices. Instead, assume that the page has been designed with big
824 // enough buttons and links. Don't trigger a disambiguation popup when 824 // enough buttons and links. Don't trigger a disambiguation popup when
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 break; 922 break;
923 } 923 }
924 default: { NOTREACHED(); } 924 default: { NOTREACHED(); }
925 } 925 }
926 m_client->didHandleGestureEvent(event, eventCancelled); 926 m_client->didHandleGestureEvent(event, eventCancelled);
927 return eventResult; 927 return eventResult;
928 } 928 }
929 929
930 WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent( 930 WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(
931 const WebGestureEvent& pinchEvent) { 931 const WebGestureEvent& pinchEvent) {
932 DCHECK_EQ(pinchEvent.type, WebInputEvent::GesturePinchUpdate); 932 DCHECK_EQ(pinchEvent.type(), WebInputEvent::GesturePinchUpdate);
933 933
934 // For pinch gesture events, match typical trackpad behavior on Windows by 934 // For pinch gesture events, match typical trackpad behavior on Windows by
935 // sending fake wheel events with the ctrl modifier set when we see trackpad 935 // sending fake wheel events with the ctrl modifier set when we see trackpad
936 // pinch gestures. Ideally we'd someday get a platform 'pinch' event and 936 // pinch gestures. Ideally we'd someday get a platform 'pinch' event and
937 // send that instead. 937 // send that instead.
938 WebMouseWheelEvent wheelEvent( 938 WebMouseWheelEvent wheelEvent(
939 WebInputEvent::MouseWheel, 939 WebInputEvent::MouseWheel,
940 pinchEvent.modifiers | WebInputEvent::ControlKey, 940 pinchEvent.modifiers() | WebInputEvent::ControlKey,
941 pinchEvent.timeStampSeconds); 941 pinchEvent.timeStampSeconds());
942 wheelEvent.windowX = wheelEvent.x = pinchEvent.x; 942 wheelEvent.windowX = wheelEvent.x = pinchEvent.x;
943 wheelEvent.windowY = wheelEvent.y = pinchEvent.y; 943 wheelEvent.windowY = wheelEvent.y = pinchEvent.y;
944 wheelEvent.globalX = pinchEvent.globalX; 944 wheelEvent.globalX = pinchEvent.globalX;
945 wheelEvent.globalY = pinchEvent.globalY; 945 wheelEvent.globalY = pinchEvent.globalY;
946 wheelEvent.deltaX = 0; 946 wheelEvent.deltaX = 0;
947 947
948 // The function to convert scales to deltaY values is designed to be 948 // The function to convert scales to deltaY values is designed to be
949 // compatible with websites existing use of wheel events, and with existing 949 // compatible with websites existing use of wheel events, and with existing
950 // Windows trackpad behavior. In particular, we want: 950 // Windows trackpad behavior. In particular, we want:
951 // - deltas should accumulate via addition: f(s1*s2)==f(s1)+f(s2) 951 // - deltas should accumulate via addition: f(s1*s2)==f(s1)+f(s2)
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 1087
1088 float WebViewImpl::expensiveBackgroundThrottlingMaxBudget() { 1088 float WebViewImpl::expensiveBackgroundThrottlingMaxBudget() {
1089 return settingsImpl()->expensiveBackgroundThrottlingMaxBudget(); 1089 return settingsImpl()->expensiveBackgroundThrottlingMaxBudget();
1090 } 1090 }
1091 1091
1092 float WebViewImpl::expensiveBackgroundThrottlingMaxDelay() { 1092 float WebViewImpl::expensiveBackgroundThrottlingMaxDelay() {
1093 return settingsImpl()->expensiveBackgroundThrottlingMaxDelay(); 1093 return settingsImpl()->expensiveBackgroundThrottlingMaxDelay();
1094 } 1094 }
1095 1095
1096 WebInputEventResult WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) { 1096 WebInputEventResult WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) {
1097 DCHECK((event.type == WebInputEvent::RawKeyDown) || 1097 DCHECK((event.type() == WebInputEvent::RawKeyDown) ||
1098 (event.type == WebInputEvent::KeyDown) || 1098 (event.type() == WebInputEvent::KeyDown) ||
1099 (event.type == WebInputEvent::KeyUp)); 1099 (event.type() == WebInputEvent::KeyUp));
1100 TRACE_EVENT2("input", "WebViewImpl::handleKeyEvent", "type", 1100 TRACE_EVENT2("input", "WebViewImpl::handleKeyEvent", "type",
1101 WebInputEvent::GetName(event.type), "text", 1101 WebInputEvent::GetName(event.type()), "text",
1102 String(event.text).utf8()); 1102 String(event.text).utf8());
1103 1103
1104 // Halt an in-progress fling on a key event. 1104 // Halt an in-progress fling on a key event.
1105 endActiveFlingAnimation(); 1105 endActiveFlingAnimation();
1106 1106
1107 // Please refer to the comments explaining the m_suppressNextKeypressEvent 1107 // Please refer to the comments explaining the m_suppressNextKeypressEvent
1108 // member. 1108 // member.
1109 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by 1109 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by
1110 // Webkit. A keyDown event is typically associated with a keyPress(char) 1110 // Webkit. A keyDown event is typically associated with a keyPress(char)
1111 // event and a keyUp event. We reset this flag here as this is a new keyDown 1111 // event and a keyUp event. We reset this flag here as this is a new keyDown
1112 // event. 1112 // event.
1113 m_suppressNextKeypressEvent = false; 1113 m_suppressNextKeypressEvent = false;
1114 1114
1115 // If there is a popup, it should be the one processing the event, not the 1115 // If there is a popup, it should be the one processing the event, not the
1116 // page. 1116 // page.
1117 if (m_pagePopup) { 1117 if (m_pagePopup) {
1118 m_pagePopup->handleKeyEvent(event); 1118 m_pagePopup->handleKeyEvent(event);
1119 // We need to ignore the next Char event after this otherwise pressing 1119 // We need to ignore the next Char event after this otherwise pressing
1120 // enter when selecting an item in the popup will go to the page. 1120 // enter when selecting an item in the popup will go to the page.
1121 if (WebInputEvent::RawKeyDown == event.type) 1121 if (WebInputEvent::RawKeyDown == event.type())
1122 m_suppressNextKeypressEvent = true; 1122 m_suppressNextKeypressEvent = true;
1123 return WebInputEventResult::HandledSystem; 1123 return WebInputEventResult::HandledSystem;
1124 } 1124 }
1125 1125
1126 Frame* focusedFrame = focusedCoreFrame(); 1126 Frame* focusedFrame = focusedCoreFrame();
1127 if (focusedFrame && focusedFrame->isRemoteFrame()) { 1127 if (focusedFrame && focusedFrame->isRemoteFrame()) {
1128 WebRemoteFrameImpl* webFrame = 1128 WebRemoteFrameImpl* webFrame =
1129 WebRemoteFrameImpl::fromFrame(*toRemoteFrame(focusedFrame)); 1129 WebRemoteFrameImpl::fromFrame(*toRemoteFrame(focusedFrame));
1130 webFrame->client()->forwardInputEvent(&event); 1130 webFrame->client()->forwardInputEvent(&event);
1131 return WebInputEventResult::HandledSystem; 1131 return WebInputEventResult::HandledSystem;
1132 } 1132 }
1133 1133
1134 if (!focusedFrame || !focusedFrame->isLocalFrame()) 1134 if (!focusedFrame || !focusedFrame->isLocalFrame())
1135 return WebInputEventResult::NotHandled; 1135 return WebInputEventResult::NotHandled;
1136 1136
1137 LocalFrame* frame = toLocalFrame(focusedFrame); 1137 LocalFrame* frame = toLocalFrame(focusedFrame);
1138 1138
1139 WebInputEventResult result = frame->eventHandler().keyEvent(event); 1139 WebInputEventResult result = frame->eventHandler().keyEvent(event);
1140 if (result != WebInputEventResult::NotHandled) { 1140 if (result != WebInputEventResult::NotHandled) {
1141 if (WebInputEvent::RawKeyDown == event.type) { 1141 if (WebInputEvent::RawKeyDown == event.type()) {
1142 // Suppress the next keypress event unless the focused node is a plugin 1142 // Suppress the next keypress event unless the focused node is a plugin
1143 // node. (Flash needs these keypress events to handle non-US keyboards.) 1143 // node. (Flash needs these keypress events to handle non-US keyboards.)
1144 Element* element = focusedElement(); 1144 Element* element = focusedElement();
1145 if (element && element->layoutObject() && 1145 if (element && element->layoutObject() &&
1146 element->layoutObject()->isEmbeddedObject()) { 1146 element->layoutObject()->isEmbeddedObject()) {
1147 if (event.windowsKeyCode == VKEY_TAB) { 1147 if (event.windowsKeyCode == VKEY_TAB) {
1148 // If the plugin supports keyboard focus then we should not send a tab 1148 // If the plugin supports keyboard focus then we should not send a tab
1149 // keypress event. 1149 // keypress event.
1150 Widget* widget = toLayoutPart(element->layoutObject())->widget(); 1150 Widget* widget = toLayoutPart(element->layoutObject())->widget();
1151 if (widget && widget->isPluginContainer()) { 1151 if (widget && widget->isPluginContainer()) {
(...skipping 13 matching lines...) Expand all
1165 const WebInputEvent::Type contextMenuKeyTriggeringEventType = 1165 const WebInputEvent::Type contextMenuKeyTriggeringEventType =
1166 #if OS(WIN) 1166 #if OS(WIN)
1167 WebInputEvent::KeyUp; 1167 WebInputEvent::KeyUp;
1168 #else 1168 #else
1169 WebInputEvent::RawKeyDown; 1169 WebInputEvent::RawKeyDown;
1170 #endif 1170 #endif
1171 const WebInputEvent::Type shiftF10TriggeringEventType = 1171 const WebInputEvent::Type shiftF10TriggeringEventType =
1172 WebInputEvent::RawKeyDown; 1172 WebInputEvent::RawKeyDown;
1173 1173
1174 bool isUnmodifiedMenuKey = 1174 bool isUnmodifiedMenuKey =
1175 !(event.modifiers & WebInputEvent::InputModifiers) && 1175 !(event.modifiers() & WebInputEvent::InputModifiers) &&
1176 event.windowsKeyCode == VKEY_APPS; 1176 event.windowsKeyCode == VKEY_APPS;
1177 bool isShiftF10 = (event.modifiers & WebInputEvent::InputModifiers) == 1177 bool isShiftF10 = (event.modifiers() & WebInputEvent::InputModifiers) ==
1178 WebInputEvent::ShiftKey && 1178 WebInputEvent::ShiftKey &&
1179 event.windowsKeyCode == VKEY_F10; 1179 event.windowsKeyCode == VKEY_F10;
1180 if ((isUnmodifiedMenuKey && 1180 if ((isUnmodifiedMenuKey &&
1181 event.type == contextMenuKeyTriggeringEventType) || 1181 event.type() == contextMenuKeyTriggeringEventType) ||
1182 (isShiftF10 && event.type == shiftF10TriggeringEventType)) { 1182 (isShiftF10 && event.type() == shiftF10TriggeringEventType)) {
1183 sendContextMenuEvent(event); 1183 sendContextMenuEvent(event);
1184 return WebInputEventResult::HandledSystem; 1184 return WebInputEventResult::HandledSystem;
1185 } 1185 }
1186 #endif // !OS(MACOSX) 1186 #endif // !OS(MACOSX)
1187 1187
1188 return WebInputEventResult::NotHandled; 1188 return WebInputEventResult::NotHandled;
1189 } 1189 }
1190 1190
1191 WebInputEventResult WebViewImpl::handleCharEvent( 1191 WebInputEventResult WebViewImpl::handleCharEvent(
1192 const WebKeyboardEvent& event) { 1192 const WebKeyboardEvent& event) {
1193 DCHECK_EQ(event.type, WebInputEvent::Char); 1193 DCHECK_EQ(event.type(), WebInputEvent::Char);
1194 TRACE_EVENT1("input", "WebViewImpl::handleCharEvent", "text", 1194 TRACE_EVENT1("input", "WebViewImpl::handleCharEvent", "text",
1195 String(event.text).utf8()); 1195 String(event.text).utf8());
1196 1196
1197 // Please refer to the comments explaining the m_suppressNextKeypressEvent 1197 // Please refer to the comments explaining the m_suppressNextKeypressEvent
1198 // member. The m_suppressNextKeypressEvent is set if the KeyDown is 1198 // member. The m_suppressNextKeypressEvent is set if the KeyDown is
1199 // handled by Webkit. A keyDown event is typically associated with a 1199 // handled by Webkit. A keyDown event is typically associated with a
1200 // keyPress(char) event and a keyUp event. We reset this flag here as it 1200 // keyPress(char) event and a keyUp event. We reset this flag here as it
1201 // only applies to the current keyPress event. 1201 // only applies to the current keyPress event.
1202 bool suppress = m_suppressNextKeypressEvent; 1202 bool suppress = m_suppressNextKeypressEvent;
1203 m_suppressNextKeypressEvent = false; 1203 m_suppressNextKeypressEvent = false;
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 2118
2119 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient(); 2119 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient();
2120 UserGestureNotifier notifier(this); 2120 UserGestureNotifier notifier(this);
2121 // On the first input event since page load, |notifier| instructs the 2121 // On the first input event since page load, |notifier| instructs the
2122 // autofill client to unblock values of password input fields of any forms 2122 // autofill client to unblock values of password input fields of any forms
2123 // on the page. There is a single input event, GestureTap, which can both 2123 // on the page. There is a single input event, GestureTap, which can both
2124 // be the first event after page load, and cause a form submission. In that 2124 // be the first event after page load, and cause a form submission. In that
2125 // case, the form submission happens before the autofill client is told 2125 // case, the form submission happens before the autofill client is told
2126 // to unblock the password values, and so the password values are not 2126 // to unblock the password values, and so the password values are not
2127 // submitted. To avoid that, GestureTap is handled explicitly: 2127 // submitted. To avoid that, GestureTap is handled explicitly:
2128 if (inputEvent.type == WebInputEvent::GestureTap && autofillClient) { 2128 if (inputEvent.type() == WebInputEvent::GestureTap && autofillClient) {
2129 m_userGestureObserved = true; 2129 m_userGestureObserved = true;
2130 autofillClient->firstUserGestureObserved(); 2130 autofillClient->firstUserGestureObserved();
2131 } 2131 }
2132 2132
2133 page()->frameHost().visualViewport().startTrackingPinchStats(); 2133 page()->frameHost().visualViewport().startTrackingPinchStats();
2134 2134
2135 TRACE_EVENT1("input,rail", "WebViewImpl::handleInputEvent", "type", 2135 TRACE_EVENT1("input,rail", "WebViewImpl::handleInputEvent", "type",
2136 WebInputEvent::GetName(inputEvent.type)); 2136 WebInputEvent::GetName(inputEvent.type()));
2137 2137
2138 // If a drag-and-drop operation is in progress, ignore input events. 2138 // If a drag-and-drop operation is in progress, ignore input events.
2139 if (mainFrameImpl()->frameWidget()->doingDragAndDrop()) 2139 if (mainFrameImpl()->frameWidget()->doingDragAndDrop())
2140 return WebInputEventResult::HandledSuppressed; 2140 return WebInputEventResult::HandledSuppressed;
2141 2141
2142 if (m_devToolsEmulator->handleInputEvent(inputEvent)) 2142 if (m_devToolsEmulator->handleInputEvent(inputEvent))
2143 return WebInputEventResult::HandledSuppressed; 2143 return WebInputEventResult::HandledSuppressed;
2144 2144
2145 if (InspectorOverlay* overlay = inspectorOverlay()) { 2145 if (InspectorOverlay* overlay = inspectorOverlay()) {
2146 if (overlay->handleInputEvent(inputEvent)) 2146 if (overlay->handleInputEvent(inputEvent))
2147 return WebInputEventResult::HandledSuppressed; 2147 return WebInputEventResult::HandledSuppressed;
2148 } 2148 }
2149 2149
2150 // Report the event to be NOT processed by WebKit, so that the browser can 2150 // Report the event to be NOT processed by WebKit, so that the browser can
2151 // handle it appropriately. 2151 // handle it appropriately.
2152 if (WebFrameWidgetBase::ignoreInputEvents()) 2152 if (WebFrameWidgetBase::ignoreInputEvents())
2153 return WebInputEventResult::NotHandled; 2153 return WebInputEventResult::NotHandled;
2154 2154
2155 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent, 2155 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent,
2156 &inputEvent); 2156 &inputEvent);
2157 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld(); 2157 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld();
2158 2158
2159 bool isPointerLocked = false; 2159 bool isPointerLocked = false;
2160 if (WebFrameWidgetBase* widget = mainFrameImpl()->frameWidget()) { 2160 if (WebFrameWidgetBase* widget = mainFrameImpl()->frameWidget()) {
2161 if (WebWidgetClient* client = widget->client()) 2161 if (WebWidgetClient* client = widget->client())
2162 isPointerLocked = client->isPointerLocked(); 2162 isPointerLocked = client->isPointerLocked();
2163 } 2163 }
2164 2164
2165 if (isPointerLocked && WebInputEvent::isMouseEventType(inputEvent.type)) { 2165 if (isPointerLocked && WebInputEvent::isMouseEventType(inputEvent.type())) {
2166 pointerLockMouseEvent(inputEvent); 2166 pointerLockMouseEvent(inputEvent);
2167 return WebInputEventResult::HandledSystem; 2167 return WebInputEventResult::HandledSystem;
2168 } 2168 }
2169 2169
2170 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type)) { 2170 if (m_mouseCaptureNode &&
2171 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); 2171 WebInputEvent::isMouseEventType(inputEvent.type())) {
2172 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type());
2172 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. 2173 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it.
2173 Node* node = m_mouseCaptureNode; 2174 Node* node = m_mouseCaptureNode;
2174 2175
2175 // Not all platforms call mouseCaptureLost() directly. 2176 // Not all platforms call mouseCaptureLost() directly.
2176 if (inputEvent.type == WebInputEvent::MouseUp) 2177 if (inputEvent.type() == WebInputEvent::MouseUp)
2177 mouseCaptureLost(); 2178 mouseCaptureLost();
2178 2179
2179 std::unique_ptr<UserGestureIndicator> gestureIndicator; 2180 std::unique_ptr<UserGestureIndicator> gestureIndicator;
2180 2181
2181 AtomicString eventType; 2182 AtomicString eventType;
2182 switch (inputEvent.type) { 2183 switch (inputEvent.type()) {
2183 case WebInputEvent::MouseMove: 2184 case WebInputEvent::MouseMove:
2184 eventType = EventTypeNames::mousemove; 2185 eventType = EventTypeNames::mousemove;
2185 break; 2186 break;
2186 case WebInputEvent::MouseLeave: 2187 case WebInputEvent::MouseLeave:
2187 eventType = EventTypeNames::mouseout; 2188 eventType = EventTypeNames::mouseout;
2188 break; 2189 break;
2189 case WebInputEvent::MouseDown: 2190 case WebInputEvent::MouseDown:
2190 eventType = EventTypeNames::mousedown; 2191 eventType = EventTypeNames::mousedown;
2191 gestureIndicator = WTF::wrapUnique( 2192 gestureIndicator = WTF::wrapUnique(
2192 new UserGestureIndicator(DocumentUserGestureToken::create( 2193 new UserGestureIndicator(DocumentUserGestureToken::create(
(...skipping 17 matching lines...) Expand all
2210 return WebInputEventResult::HandledSystem; 2211 return WebInputEventResult::HandledSystem;
2211 } 2212 }
2212 2213
2213 // FIXME: This should take in the intended frame, not the local frame root. 2214 // FIXME: This should take in the intended frame, not the local frame root.
2214 WebInputEventResult result = PageWidgetDelegate::handleInputEvent( 2215 WebInputEventResult result = PageWidgetDelegate::handleInputEvent(
2215 *this, WebCoalescedInputEvent(inputEvent), mainFrameImpl()->frame()); 2216 *this, WebCoalescedInputEvent(inputEvent), mainFrameImpl()->frame());
2216 if (result != WebInputEventResult::NotHandled) 2217 if (result != WebInputEventResult::NotHandled)
2217 return result; 2218 return result;
2218 2219
2219 // Unhandled pinch events should adjust the scale. 2220 // Unhandled pinch events should adjust the scale.
2220 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { 2221 if (inputEvent.type() == WebInputEvent::GesturePinchUpdate) {
2221 const WebGestureEvent& pinchEvent = 2222 const WebGestureEvent& pinchEvent =
2222 static_cast<const WebGestureEvent&>(inputEvent); 2223 static_cast<const WebGestureEvent&>(inputEvent);
2223 2224
2224 // For touchpad gestures synthesize a Windows-like wheel event 2225 // For touchpad gestures synthesize a Windows-like wheel event
2225 // to send to any handlers that may exist. Not necessary for touchscreen 2226 // to send to any handlers that may exist. Not necessary for touchscreen
2226 // as touch events would have already been sent for the gesture. 2227 // as touch events would have already been sent for the gesture.
2227 if (pinchEvent.sourceDevice == WebGestureDeviceTouchpad) { 2228 if (pinchEvent.sourceDevice == WebGestureDeviceTouchpad) {
2228 result = handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent); 2229 result = handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent);
2229 if (result != WebInputEventResult::NotHandled) 2230 if (result != WebInputEventResult::NotHandled)
2230 return result; 2231 return result;
(...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after
4106 m_overrideCompositorVisibility = true; 4107 m_overrideCompositorVisibility = true;
4107 else 4108 else
4108 m_overrideCompositorVisibility = false; 4109 m_overrideCompositorVisibility = false;
4109 if (m_layerTreeView) 4110 if (m_layerTreeView)
4110 m_layerTreeView->setVisible(isVisible); 4111 m_layerTreeView->setVisible(isVisible);
4111 } 4112 }
4112 4113
4113 void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event) { 4114 void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event) {
4114 std::unique_ptr<UserGestureIndicator> gestureIndicator; 4115 std::unique_ptr<UserGestureIndicator> gestureIndicator;
4115 AtomicString eventType; 4116 AtomicString eventType;
4116 switch (event.type) { 4117 switch (event.type()) {
4117 case WebInputEvent::MouseDown: 4118 case WebInputEvent::MouseDown:
4118 eventType = EventTypeNames::mousedown; 4119 eventType = EventTypeNames::mousedown;
4119 if (!page() || !page()->pointerLockController().element()) 4120 if (!page() || !page()->pointerLockController().element())
4120 break; 4121 break;
4121 gestureIndicator = WTF::wrapUnique( 4122 gestureIndicator = WTF::wrapUnique(
4122 new UserGestureIndicator(DocumentUserGestureToken::create( 4123 new UserGestureIndicator(DocumentUserGestureToken::create(
4123 &page()->pointerLockController().element()->document(), 4124 &page()->pointerLockController().element()->document(),
4124 UserGestureToken::NewGesture))); 4125 UserGestureToken::NewGesture)));
4125 m_pointerLockGestureToken = gestureIndicator->currentToken(); 4126 m_pointerLockGestureToken = gestureIndicator->currentToken();
4126 break; 4127 break;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
4190 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4191 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4191 return nullptr; 4192 return nullptr;
4192 return focusedFrame; 4193 return focusedFrame;
4193 } 4194 }
4194 4195
4195 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4196 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4196 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4197 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4197 } 4198 }
4198 4199
4199 } // namespace blink 4200 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebPluginContainerImpl.cpp ('k') | third_party/WebKit/Source/web/tests/VisualViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698