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

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: Created 4 years 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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 692
693 WebInputEventResult WebViewImpl::handleGestureEvent( 693 WebInputEventResult WebViewImpl::handleGestureEvent(
694 const WebGestureEvent& event) { 694 const WebGestureEvent& event) {
695 if (!m_client) 695 if (!m_client)
696 return WebInputEventResult::NotHandled; 696 return WebInputEventResult::NotHandled;
697 697
698 WebInputEventResult eventResult = WebInputEventResult::NotHandled; 698 WebInputEventResult eventResult = WebInputEventResult::NotHandled;
699 bool eventCancelled = false; // for disambiguation 699 bool eventCancelled = false; // for disambiguation
700 700
701 // Special handling for slow-path fling gestures. 701 // Special handling for slow-path fling gestures.
702 switch (event.type) { 702 switch (event.type()) {
703 case WebInputEvent::GestureFlingStart: { 703 case WebInputEvent::GestureFlingStart: {
704 if (mainFrameImpl() 704 if (mainFrameImpl()
705 ->frame() 705 ->frame()
706 ->eventHandler() 706 ->eventHandler()
707 .isScrollbarHandlingGestures()) 707 .isScrollbarHandlingGestures())
708 break; 708 break;
709 endActiveFlingAnimation(); 709 endActiveFlingAnimation();
710 m_client->cancelScheduledContentIntents(); 710 m_client->cancelScheduledContentIntents();
711 m_positionOnFlingStart = WebPoint(event.x, event.y); 711 m_positionOnFlingStart = WebPoint(event.x, event.y);
712 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); 712 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY);
713 m_flingModifier = event.modifiers; 713 m_flingModifier = event.modifiers();
714 m_flingSourceDevice = event.sourceDevice; 714 m_flingSourceDevice = event.sourceDevice;
715 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized); 715 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized);
716 std::unique_ptr<WebGestureCurve> flingCurve = 716 std::unique_ptr<WebGestureCurve> flingCurve =
717 WTF::wrapUnique(Platform::current()->createFlingAnimationCurve( 717 WTF::wrapUnique(Platform::current()->createFlingAnimationCurve(
718 event.sourceDevice, 718 event.sourceDevice,
719 WebFloatPoint(event.data.flingStart.velocityX, 719 WebFloatPoint(event.data.flingStart.velocityX,
720 event.data.flingStart.velocityY), 720 event.data.flingStart.velocityY),
721 WebSize())); 721 WebSize()));
722 DCHECK(flingCurve); 722 DCHECK(flingCurve);
723 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart( 723 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(
(...skipping 21 matching lines...) Expand all
745 return eventResult; 745 return eventResult;
746 default: 746 default:
747 break; 747 break;
748 } 748 }
749 749
750 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), 750 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(),
751 event); 751 event);
752 752
753 // Special handling for double tap and scroll events as we don't want to 753 // Special handling for double tap and scroll events as we don't want to
754 // hit test for them. 754 // hit test for them.
755 switch (event.type) { 755 switch (event.type()) {
756 case WebInputEvent::GestureDoubleTap: 756 case WebInputEvent::GestureDoubleTap:
757 if (m_webSettings->doubleTapToZoomEnabled() && 757 if (m_webSettings->doubleTapToZoomEnabled() &&
758 minimumPageScaleFactor() != maximumPageScaleFactor()) { 758 minimumPageScaleFactor() != maximumPageScaleFactor()) {
759 m_client->cancelScheduledContentIntents(); 759 m_client->cancelScheduledContentIntents();
760 animateDoubleTapZoom(platformEvent.position()); 760 animateDoubleTapZoom(platformEvent.position());
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.
765 eventResult = WebInputEventResult::HandledSystem; 765 eventResult = WebInputEventResult::HandledSystem;
(...skipping 23 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 platformEvent); 795 platformEvent);
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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 2122
2123 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient(); 2123 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient();
2124 UserGestureNotifier notifier(this); 2124 UserGestureNotifier notifier(this);
2125 // On the first input event since page load, |notifier| instructs the 2125 // On the first input event since page load, |notifier| instructs the
2126 // autofill client to unblock values of password input fields of any forms 2126 // autofill client to unblock values of password input fields of any forms
2127 // on the page. There is a single input event, GestureTap, which can both 2127 // on the page. There is a single input event, GestureTap, which can both
2128 // be the first event after page load, and cause a form submission. In that 2128 // be the first event after page load, and cause a form submission. In that
2129 // case, the form submission happens before the autofill client is told 2129 // case, the form submission happens before the autofill client is told
2130 // to unblock the password values, and so the password values are not 2130 // to unblock the password values, and so the password values are not
2131 // submitted. To avoid that, GestureTap is handled explicitly: 2131 // submitted. To avoid that, GestureTap is handled explicitly:
2132 if (inputEvent.type == WebInputEvent::GestureTap && autofillClient) { 2132 if (inputEvent.type() == WebInputEvent::GestureTap && autofillClient) {
2133 m_userGestureObserved = true; 2133 m_userGestureObserved = true;
2134 autofillClient->firstUserGestureObserved(); 2134 autofillClient->firstUserGestureObserved();
2135 } 2135 }
2136 2136
2137 page()->frameHost().visualViewport().startTrackingPinchStats(); 2137 page()->frameHost().visualViewport().startTrackingPinchStats();
2138 2138
2139 TRACE_EVENT1("input,rail", "WebViewImpl::handleInputEvent", "type", 2139 TRACE_EVENT1("input,rail", "WebViewImpl::handleInputEvent", "type",
2140 WebInputEvent::GetName(inputEvent.type)); 2140 WebInputEvent::GetName(inputEvent.type()));
2141 2141
2142 // If a drag-and-drop operation is in progress, ignore input events. 2142 // If a drag-and-drop operation is in progress, ignore input events.
2143 if (mainFrameImpl()->frameWidget()->doingDragAndDrop()) 2143 if (mainFrameImpl()->frameWidget()->doingDragAndDrop())
2144 return WebInputEventResult::HandledSuppressed; 2144 return WebInputEventResult::HandledSuppressed;
2145 2145
2146 if (m_devToolsEmulator->handleInputEvent(inputEvent)) 2146 if (m_devToolsEmulator->handleInputEvent(inputEvent))
2147 return WebInputEventResult::HandledSuppressed; 2147 return WebInputEventResult::HandledSuppressed;
2148 2148
2149 if (InspectorOverlay* overlay = inspectorOverlay()) { 2149 if (InspectorOverlay* overlay = inspectorOverlay()) {
2150 if (overlay->handleInputEvent(inputEvent)) 2150 if (overlay->handleInputEvent(inputEvent))
2151 return WebInputEventResult::HandledSuppressed; 2151 return WebInputEventResult::HandledSuppressed;
2152 } 2152 }
2153 2153
2154 // Report the event to be NOT processed by WebKit, so that the browser can 2154 // Report the event to be NOT processed by WebKit, so that the browser can
2155 // handle it appropriately. 2155 // handle it appropriately.
2156 if (m_ignoreInputEvents) 2156 if (m_ignoreInputEvents)
2157 return WebInputEventResult::NotHandled; 2157 return WebInputEventResult::NotHandled;
2158 2158
2159 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent, 2159 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent,
2160 &inputEvent); 2160 &inputEvent);
2161 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld(); 2161 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld();
2162 2162
2163 bool isPointerLocked = false; 2163 bool isPointerLocked = false;
2164 if (WebFrameWidgetBase* widget = mainFrameImpl()->frameWidget()) { 2164 if (WebFrameWidgetBase* widget = mainFrameImpl()->frameWidget()) {
2165 if (WebWidgetClient* client = widget->client()) 2165 if (WebWidgetClient* client = widget->client())
2166 isPointerLocked = client->isPointerLocked(); 2166 isPointerLocked = client->isPointerLocked();
2167 } 2167 }
2168 2168
2169 if (isPointerLocked && WebInputEvent::isMouseEventType(inputEvent.type)) { 2169 if (isPointerLocked && WebInputEvent::isMouseEventType(inputEvent.type())) {
2170 pointerLockMouseEvent(inputEvent); 2170 pointerLockMouseEvent(inputEvent);
2171 return WebInputEventResult::HandledSystem; 2171 return WebInputEventResult::HandledSystem;
2172 } 2172 }
2173 2173
2174 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type)) { 2174 if (m_mouseCaptureNode &&
2175 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); 2175 WebInputEvent::isMouseEventType(inputEvent.type())) {
2176 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type());
2176 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. 2177 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it.
2177 Node* node = m_mouseCaptureNode; 2178 Node* node = m_mouseCaptureNode;
2178 2179
2179 // Not all platforms call mouseCaptureLost() directly. 2180 // Not all platforms call mouseCaptureLost() directly.
2180 if (inputEvent.type == WebInputEvent::MouseUp) 2181 if (inputEvent.type() == WebInputEvent::MouseUp)
2181 mouseCaptureLost(); 2182 mouseCaptureLost();
2182 2183
2183 std::unique_ptr<UserGestureIndicator> gestureIndicator; 2184 std::unique_ptr<UserGestureIndicator> gestureIndicator;
2184 2185
2185 AtomicString eventType; 2186 AtomicString eventType;
2186 switch (inputEvent.type) { 2187 switch (inputEvent.type()) {
2187 case WebInputEvent::MouseMove: 2188 case WebInputEvent::MouseMove:
2188 eventType = EventTypeNames::mousemove; 2189 eventType = EventTypeNames::mousemove;
2189 break; 2190 break;
2190 case WebInputEvent::MouseLeave: 2191 case WebInputEvent::MouseLeave:
2191 eventType = EventTypeNames::mouseout; 2192 eventType = EventTypeNames::mouseout;
2192 break; 2193 break;
2193 case WebInputEvent::MouseDown: 2194 case WebInputEvent::MouseDown:
2194 eventType = EventTypeNames::mousedown; 2195 eventType = EventTypeNames::mousedown;
2195 gestureIndicator = WTF::wrapUnique( 2196 gestureIndicator = WTF::wrapUnique(
2196 new UserGestureIndicator(DocumentUserGestureToken::create( 2197 new UserGestureIndicator(DocumentUserGestureToken::create(
(...skipping 17 matching lines...) Expand all
2214 return WebInputEventResult::HandledSystem; 2215 return WebInputEventResult::HandledSystem;
2215 } 2216 }
2216 2217
2217 // FIXME: This should take in the intended frame, not the local frame root. 2218 // FIXME: This should take in the intended frame, not the local frame root.
2218 WebInputEventResult result = PageWidgetDelegate::handleInputEvent( 2219 WebInputEventResult result = PageWidgetDelegate::handleInputEvent(
2219 *this, inputEvent, mainFrameImpl()->frame()); 2220 *this, inputEvent, mainFrameImpl()->frame());
2220 if (result != WebInputEventResult::NotHandled) 2221 if (result != WebInputEventResult::NotHandled)
2221 return result; 2222 return result;
2222 2223
2223 // Unhandled pinch events should adjust the scale. 2224 // Unhandled pinch events should adjust the scale.
2224 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { 2225 if (inputEvent.type() == WebInputEvent::GesturePinchUpdate) {
2225 const WebGestureEvent& pinchEvent = 2226 const WebGestureEvent& pinchEvent =
2226 static_cast<const WebGestureEvent&>(inputEvent); 2227 static_cast<const WebGestureEvent&>(inputEvent);
2227 2228
2228 // For touchpad gestures synthesize a Windows-like wheel event 2229 // For touchpad gestures synthesize a Windows-like wheel event
2229 // to send to any handlers that may exist. Not necessary for touchscreen 2230 // to send to any handlers that may exist. Not necessary for touchscreen
2230 // as touch events would have already been sent for the gesture. 2231 // as touch events would have already been sent for the gesture.
2231 if (pinchEvent.sourceDevice == WebGestureDeviceTouchpad) { 2232 if (pinchEvent.sourceDevice == WebGestureDeviceTouchpad) {
2232 result = handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent); 2233 result = handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent);
2233 if (result != WebInputEventResult::NotHandled) 2234 if (result != WebInputEventResult::NotHandled)
2234 return result; 2235 return result;
(...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after
4128 m_overrideCompositorVisibility = true; 4129 m_overrideCompositorVisibility = true;
4129 else 4130 else
4130 m_overrideCompositorVisibility = false; 4131 m_overrideCompositorVisibility = false;
4131 if (m_layerTreeView) 4132 if (m_layerTreeView)
4132 m_layerTreeView->setVisible(isVisible); 4133 m_layerTreeView->setVisible(isVisible);
4133 } 4134 }
4134 4135
4135 void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event) { 4136 void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event) {
4136 std::unique_ptr<UserGestureIndicator> gestureIndicator; 4137 std::unique_ptr<UserGestureIndicator> gestureIndicator;
4137 AtomicString eventType; 4138 AtomicString eventType;
4138 switch (event.type) { 4139 switch (event.type()) {
4139 case WebInputEvent::MouseDown: 4140 case WebInputEvent::MouseDown:
4140 eventType = EventTypeNames::mousedown; 4141 eventType = EventTypeNames::mousedown;
4141 if (!page() || !page()->pointerLockController().element()) 4142 if (!page() || !page()->pointerLockController().element())
4142 break; 4143 break;
4143 gestureIndicator = WTF::wrapUnique( 4144 gestureIndicator = WTF::wrapUnique(
4144 new UserGestureIndicator(DocumentUserGestureToken::create( 4145 new UserGestureIndicator(DocumentUserGestureToken::create(
4145 &page()->pointerLockController().element()->document(), 4146 &page()->pointerLockController().element()->document(),
4146 UserGestureToken::NewGesture))); 4147 UserGestureToken::NewGesture)));
4147 m_pointerLockGestureToken = gestureIndicator->currentToken(); 4148 m_pointerLockGestureToken = gestureIndicator->currentToken();
4148 break; 4149 break;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
4212 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4213 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4213 return nullptr; 4214 return nullptr;
4214 return focusedFrame; 4215 return focusedFrame;
4215 } 4216 }
4216 4217
4217 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4218 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4218 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4219 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4219 } 4220 }
4220 4221
4221 } // namespace blink 4222 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698