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

Side by Side Diff: third_party/WebKit/Source/core/input/GestureManager.cpp

Issue 2539283002: Remove PlatformGestureEvent in favour of using WebGestureEvent (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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "core/input/GestureManager.h" 5 #include "core/input/GestureManager.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/DocumentUserGestureToken.h" 8 #include "core/dom/DocumentUserGestureToken.h"
9 #include "core/editing/SelectionController.h" 9 #include "core/editing/SelectionController.h"
10 #include "core/events/GestureEvent.h" 10 #include "core/events/GestureEvent.h"
(...skipping 29 matching lines...) Expand all
40 40
41 DEFINE_TRACE(GestureManager) { 41 DEFINE_TRACE(GestureManager) {
42 visitor->trace(m_frame); 42 visitor->trace(m_frame);
43 visitor->trace(m_scrollManager); 43 visitor->trace(m_scrollManager);
44 visitor->trace(m_mouseEventManager); 44 visitor->trace(m_mouseEventManager);
45 visitor->trace(m_pointerEventManager); 45 visitor->trace(m_pointerEventManager);
46 visitor->trace(m_selectionController); 46 visitor->trace(m_selectionController);
47 } 47 }
48 48
49 HitTestRequest::HitTestRequestType GestureManager::getHitTypeForGestureType( 49 HitTestRequest::HitTestRequestType GestureManager::getHitTypeForGestureType(
50 PlatformEvent::EventType type) { 50 WebInputEvent::Type type) {
51 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent; 51 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent;
52 switch (type) { 52 switch (type) {
53 case PlatformEvent::GestureShowPress: 53 case WebInputEvent::GestureShowPress:
54 case PlatformEvent::GestureTapUnconfirmed: 54 case WebInputEvent::GestureTapUnconfirmed:
55 return hitType | HitTestRequest::Active; 55 return hitType | HitTestRequest::Active;
56 case PlatformEvent::GestureTapDownCancel: 56 case WebInputEvent::GestureTapCancel:
57 // A TapDownCancel received when no element is active shouldn't really be 57 // A TapDownCancel received when no element is active shouldn't really be
58 // changing hover state. 58 // changing hover state.
59 if (!m_frame->document()->activeHoverElement()) 59 if (!m_frame->document()->activeHoverElement())
60 hitType |= HitTestRequest::ReadOnly; 60 hitType |= HitTestRequest::ReadOnly;
61 return hitType | HitTestRequest::Release; 61 return hitType | HitTestRequest::Release;
62 case PlatformEvent::GestureTap: 62 case WebInputEvent::GestureTap:
63 return hitType | HitTestRequest::Release; 63 return hitType | HitTestRequest::Release;
64 case PlatformEvent::GestureTapDown: 64 case WebInputEvent::GestureTapDown:
65 case PlatformEvent::GestureLongPress: 65 case WebInputEvent::GestureLongPress:
66 case PlatformEvent::GestureLongTap: 66 case WebInputEvent::GestureLongTap:
67 case PlatformEvent::GestureTwoFingerTap: 67 case WebInputEvent::GestureTwoFingerTap:
68 // FIXME: Shouldn't LongTap and TwoFingerTap clear the Active state? 68 // FIXME: Shouldn't LongTap and TwoFingerTap clear the Active state?
69 return hitType | HitTestRequest::Active | HitTestRequest::ReadOnly; 69 return hitType | HitTestRequest::Active | HitTestRequest::ReadOnly;
70 default: 70 default:
71 NOTREACHED(); 71 NOTREACHED();
72 return hitType | HitTestRequest::Active | HitTestRequest::ReadOnly; 72 return hitType | HitTestRequest::Active | HitTestRequest::ReadOnly;
73 } 73 }
74 } 74 }
75 75
76 WebInputEventResult GestureManager::handleGestureEventInFrame( 76 WebInputEventResult GestureManager::handleGestureEventInFrame(
77 const GestureEventWithHitTestResults& targetedEvent) { 77 const GestureEventWithHitTestResults& targetedEvent) {
78 DCHECK(!targetedEvent.event().isScrollEvent()); 78 DCHECK(!targetedEvent.event().isScrollEvent());
79 79
80 Node* eventTarget = targetedEvent.hitTestResult().innerNode(); 80 Node* eventTarget = targetedEvent.hitTestResult().innerNode();
81 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 81 const WebGestureEvent& gestureEvent = targetedEvent.event();
82 82
83 if (m_scrollManager->canHandleGestureEvent(targetedEvent)) 83 if (m_scrollManager->canHandleGestureEvent(targetedEvent))
84 return WebInputEventResult::HandledSuppressed; 84 return WebInputEventResult::HandledSuppressed;
85 85
86 if (eventTarget) { 86 if (eventTarget) {
87 GestureEvent* gestureDomEvent = 87 GestureEvent* gestureDomEvent =
88 GestureEvent::create(eventTarget->document().domWindow(), gestureEvent); 88 GestureEvent::create(eventTarget->document().domWindow(), gestureEvent);
89 if (gestureDomEvent) { 89 if (gestureDomEvent) {
90 DispatchEventResult gestureDomEventResult = 90 DispatchEventResult gestureDomEventResult =
91 eventTarget->dispatchEvent(gestureDomEvent); 91 eventTarget->dispatchEvent(gestureDomEvent);
92 if (gestureDomEventResult != DispatchEventResult::NotCanceled) { 92 if (gestureDomEventResult != DispatchEventResult::NotCanceled) {
93 DCHECK(gestureDomEventResult != 93 DCHECK(gestureDomEventResult !=
94 DispatchEventResult::CanceledByEventHandler); 94 DispatchEventResult::CanceledByEventHandler);
95 return EventHandlingUtil::toWebInputEventResult(gestureDomEventResult); 95 return EventHandlingUtil::toWebInputEventResult(gestureDomEventResult);
96 } 96 }
97 } 97 }
98 } 98 }
99 99
100 switch (gestureEvent.type()) { 100 switch (gestureEvent.type) {
101 case PlatformEvent::GestureTapDown: 101 case WebInputEvent::GestureTapDown:
102 return handleGestureTapDown(targetedEvent); 102 return handleGestureTapDown(targetedEvent);
103 case PlatformEvent::GestureTap: 103 case WebInputEvent::GestureTap:
104 return handleGestureTap(targetedEvent); 104 return handleGestureTap(targetedEvent);
105 case PlatformEvent::GestureShowPress: 105 case WebInputEvent::GestureShowPress:
106 return handleGestureShowPress(); 106 return handleGestureShowPress();
107 case PlatformEvent::GestureLongPress: 107 case WebInputEvent::GestureLongPress:
108 return handleGestureLongPress(targetedEvent); 108 return handleGestureLongPress(targetedEvent);
109 case PlatformEvent::GestureLongTap: 109 case WebInputEvent::GestureLongTap:
110 return handleGestureLongTap(targetedEvent); 110 return handleGestureLongTap(targetedEvent);
111 case PlatformEvent::GestureTwoFingerTap: 111 case WebInputEvent::GestureTwoFingerTap:
112 return handleGestureTwoFingerTap(targetedEvent); 112 return handleGestureTwoFingerTap(targetedEvent);
113 case PlatformEvent::GesturePinchBegin: 113 case WebInputEvent::GesturePinchBegin:
114 case PlatformEvent::GesturePinchEnd: 114 case WebInputEvent::GesturePinchEnd:
115 case PlatformEvent::GesturePinchUpdate: 115 case WebInputEvent::GesturePinchUpdate:
116 case PlatformEvent::GestureTapDownCancel: 116 case WebInputEvent::GestureTapCancel:
117 case PlatformEvent::GestureTapUnconfirmed: 117 case WebInputEvent::GestureTapUnconfirmed:
118 break; 118 break;
119 default: 119 default:
120 NOTREACHED(); 120 NOTREACHED();
121 } 121 }
122 122
123 return WebInputEventResult::NotHandled; 123 return WebInputEventResult::NotHandled;
124 } 124 }
125 125
126 WebInputEventResult GestureManager::handleGestureTapDown( 126 WebInputEventResult GestureManager::handleGestureTapDown(
127 const GestureEventWithHitTestResults& targetedEvent) { 127 const GestureEventWithHitTestResults& targetedEvent) {
128 m_suppressMouseEventsFromGestures = 128 m_suppressMouseEventsFromGestures =
129 m_pointerEventManager->primaryPointerdownCanceled( 129 m_pointerEventManager->primaryPointerdownCanceled(
130 targetedEvent.event().uniqueTouchEventId()); 130 targetedEvent.event().uniqueTouchEventId);
131 return WebInputEventResult::NotHandled; 131 return WebInputEventResult::NotHandled;
132 } 132 }
133 133
134 WebInputEventResult GestureManager::handleGestureTap( 134 WebInputEventResult GestureManager::handleGestureTap(
135 const GestureEventWithHitTestResults& targetedEvent) { 135 const GestureEventWithHitTestResults& targetedEvent) {
136 FrameView* frameView(m_frame->view()); 136 FrameView* frameView(m_frame->view());
137 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 137 const WebGestureEvent& gestureEvent = targetedEvent.event();
138 HitTestRequest::HitTestRequestType hitType = 138 HitTestRequest::HitTestRequestType hitType =
139 getHitTypeForGestureType(gestureEvent.type()); 139 getHitTypeForGestureType(gestureEvent.type);
140 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); 140 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion();
141 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); 141 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion();
142 142
143 HitTestResult currentHitTest = targetedEvent.hitTestResult(); 143 HitTestResult currentHitTest = targetedEvent.hitTestResult();
144 144
145 // We use the adjusted position so the application isn't surprised to see a 145 // We use the adjusted position so the application isn't surprised to see a
146 // event with co-ordinates outside the target's bounds. 146 // event with co-ordinates outside the target's bounds.
147 IntPoint adjustedPoint = 147 IntPoint adjustedPoint = frameView->rootFrameToContents(
148 frameView->rootFrameToContents(gestureEvent.position()); 148 flooredIntPoint(gestureEvent.positionInRootFrame()));
149 149
150 const unsigned modifiers = gestureEvent.getModifiers(); 150 const unsigned modifiers = gestureEvent.modifiers;
151 151
152 if (!m_suppressMouseEventsFromGestures) { 152 if (!m_suppressMouseEventsFromGestures) {
153 PlatformMouseEvent fakeMouseMove( 153 PlatformMouseEvent fakeMouseMove(
154 gestureEvent.position(), gestureEvent.globalPosition(), 154 gestureEvent, WebPointerProperties::Button::NoButton,
155 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 155 PlatformEvent::MouseMoved,
156 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers), 156 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers),
157 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), 157 PlatformMouseEvent::FromTouch, gestureEvent.timeStampSeconds,
158 WebPointerProperties::PointerType::Mouse); 158 WebPointerProperties::PointerType::Mouse);
159 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( 159 m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
160 currentHitTest.innerNode(), EventTypeNames::mousemove, fakeMouseMove); 160 currentHitTest.innerNode(), EventTypeNames::mousemove, fakeMouseMove);
161 } 161 }
162 162
163 // Do a new hit-test in case the mousemove event changed the DOM. 163 // Do a new hit-test in case the mousemove event changed the DOM.
164 // Note that if the original hit test wasn't over an element (eg. was over a 164 // Note that if the original hit test wasn't over an element (eg. was over a
165 // scrollbar) we don't want to re-hit-test because it may be in the wrong 165 // scrollbar) we don't want to re-hit-test because it may be in the wrong
166 // frame (and there's no way the page could have seen the event anyway). Also 166 // frame (and there's no way the page could have seen the event anyway). Also
167 // note that the position of the frame may have changed, so we need to 167 // note that the position of the frame may have changed, so we need to
168 // recompute the content co-ordinates (updating layout/style as 168 // recompute the content co-ordinates (updating layout/style as
169 // hitTestResultAtPoint normally would). 169 // hitTestResultAtPoint normally would).
170 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. 170 // FIXME: Use a hit-test cache to avoid unnecessary hit tests.
171 // http://crbug.com/398920 171 // http://crbug.com/398920
172 if (currentHitTest.innerNode()) { 172 if (currentHitTest.innerNode()) {
173 LocalFrame* mainFrame = m_frame->localFrameRoot(); 173 LocalFrame* mainFrame = m_frame->localFrameRoot();
174 if (mainFrame && mainFrame->view()) 174 if (mainFrame && mainFrame->view())
175 mainFrame->view()->updateLifecycleToCompositingCleanPlusScrolling(); 175 mainFrame->view()->updateLifecycleToCompositingCleanPlusScrolling();
176 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); 176 adjustedPoint = frameView->rootFrameToContents(
177 flooredIntPoint(gestureEvent.positionInRootFrame()));
177 currentHitTest = EventHandlingUtil::hitTestResultInFrame( 178 currentHitTest = EventHandlingUtil::hitTestResultInFrame(
178 m_frame, adjustedPoint, hitType); 179 m_frame, adjustedPoint, hitType);
179 } 180 }
180 181
181 // Capture data for showUnhandledTapUIIfNeeded. 182 // Capture data for showUnhandledTapUIIfNeeded.
182 Node* tappedNode = currentHitTest.innerNode(); 183 Node* tappedNode = currentHitTest.innerNode();
183 IntPoint tappedPosition = gestureEvent.position(); 184 IntPoint tappedPosition = flooredIntPoint(gestureEvent.positionInRootFrame());
184 Node* tappedNonTextNode = tappedNode; 185 Node* tappedNonTextNode = tappedNode;
185 UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create( 186 UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create(
186 tappedNode ? &tappedNode->document() : nullptr)); 187 tappedNode ? &tappedNode->document() : nullptr));
187 188
188 if (tappedNonTextNode && tappedNonTextNode->isTextNode()) 189 if (tappedNonTextNode && tappedNonTextNode->isTextNode())
189 tappedNonTextNode = FlatTreeTraversal::parent(*tappedNonTextNode); 190 tappedNonTextNode = FlatTreeTraversal::parent(*tappedNonTextNode);
190 191
191 m_mouseEventManager->setClickNode(tappedNonTextNode); 192 m_mouseEventManager->setClickNode(tappedNonTextNode);
192 193
193 PlatformMouseEvent fakeMouseDown( 194 PlatformMouseEvent fakeMouseDown(
194 gestureEvent.position(), gestureEvent.globalPosition(), 195 gestureEvent, WebPointerProperties::Button::Left,
195 WebPointerProperties::Button::Left, PlatformEvent::MousePressed, 196 PlatformEvent::MousePressed, gestureEvent.tapCount(),
196 gestureEvent.tapCount(), static_cast<PlatformEvent::Modifiers>( 197 static_cast<PlatformEvent::Modifiers>(modifiers |
197 modifiers | PlatformEvent::LeftButtonDown), 198 PlatformEvent::LeftButtonDown),
198 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), 199 PlatformMouseEvent::FromTouch, gestureEvent.timeStampSeconds,
199 WebPointerProperties::PointerType::Mouse); 200 WebPointerProperties::PointerType::Mouse);
200 201
201 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that 202 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that
202 // mean for for TEs? What's the right balance here? crbug.com/617255 203 // mean for for TEs? What's the right balance here? crbug.com/617255
203 WebInputEventResult mouseDownEventResult = 204 WebInputEventResult mouseDownEventResult =
204 WebInputEventResult::HandledSuppressed; 205 WebInputEventResult::HandledSuppressed;
205 if (!m_suppressMouseEventsFromGestures) { 206 if (!m_suppressMouseEventsFromGestures) {
206 m_mouseEventManager->setClickCount(gestureEvent.tapCount()); 207 m_mouseEventManager->setClickCount(gestureEvent.tapCount());
207 208
208 mouseDownEventResult = 209 mouseDownEventResult =
209 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( 210 m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
210 currentHitTest.innerNode(), EventTypeNames::mousedown, 211 currentHitTest.innerNode(), EventTypeNames::mousedown,
211 fakeMouseDown); 212 fakeMouseDown);
212 m_selectionController->initializeSelectionState(); 213 m_selectionController->initializeSelectionState();
213 if (mouseDownEventResult == WebInputEventResult::NotHandled) 214 if (mouseDownEventResult == WebInputEventResult::NotHandled)
214 mouseDownEventResult = m_mouseEventManager->handleMouseFocus( 215 mouseDownEventResult = m_mouseEventManager->handleMouseFocus(
215 currentHitTest, 216 currentHitTest,
216 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()); 217 InputDeviceCapabilities::firesTouchEventsSourceCapabilities());
217 if (mouseDownEventResult == WebInputEventResult::NotHandled) 218 if (mouseDownEventResult == WebInputEventResult::NotHandled)
218 mouseDownEventResult = m_mouseEventManager->handleMousePressEvent( 219 mouseDownEventResult = m_mouseEventManager->handleMousePressEvent(
219 MouseEventWithHitTestResults(fakeMouseDown, currentHitTest)); 220 MouseEventWithHitTestResults(fakeMouseDown, currentHitTest));
220 } 221 }
221 222
222 if (currentHitTest.innerNode()) { 223 if (currentHitTest.innerNode()) {
223 DCHECK(gestureEvent.type() == PlatformEvent::GestureTap); 224 DCHECK(gestureEvent.type == WebInputEvent::GestureTap);
224 HitTestResult result = currentHitTest; 225 HitTestResult result = currentHitTest;
225 result.setToShadowHostIfInUserAgentShadowRoot(); 226 result.setToShadowHostIfInUserAgentShadowRoot();
226 m_frame->chromeClient().onMouseDown(result.innerNode()); 227 m_frame->chromeClient().onMouseDown(result.innerNode());
227 } 228 }
228 229
229 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. 230 // FIXME: Use a hit-test cache to avoid unnecessary hit tests.
230 // http://crbug.com/398920 231 // http://crbug.com/398920
231 if (currentHitTest.innerNode()) { 232 if (currentHitTest.innerNode()) {
232 LocalFrame* mainFrame = m_frame->localFrameRoot(); 233 LocalFrame* mainFrame = m_frame->localFrameRoot();
233 if (mainFrame && mainFrame->view()) 234 if (mainFrame && mainFrame->view())
234 mainFrame->view()->updateAllLifecyclePhases(); 235 mainFrame->view()->updateAllLifecyclePhases();
235 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); 236 adjustedPoint = frameView->rootFrameToContents(tappedPosition);
236 currentHitTest = EventHandlingUtil::hitTestResultInFrame( 237 currentHitTest = EventHandlingUtil::hitTestResultInFrame(
237 m_frame, adjustedPoint, hitType); 238 m_frame, adjustedPoint, hitType);
238 } 239 }
239 240
240 PlatformMouseEvent fakeMouseUp( 241 PlatformMouseEvent fakeMouseUp(
241 gestureEvent.position(), gestureEvent.globalPosition(), 242 gestureEvent, WebPointerProperties::Button::Left,
242 WebPointerProperties::Button::Left, PlatformEvent::MouseReleased, 243 PlatformEvent::MouseReleased, gestureEvent.tapCount(),
243 gestureEvent.tapCount(), static_cast<PlatformEvent::Modifiers>(modifiers), 244 static_cast<PlatformEvent::Modifiers>(modifiers),
244 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), 245 PlatformMouseEvent::FromTouch, gestureEvent.timeStampSeconds,
245 WebPointerProperties::PointerType::Mouse); 246 WebPointerProperties::PointerType::Mouse);
246 WebInputEventResult mouseUpEventResult = 247 WebInputEventResult mouseUpEventResult =
247 m_suppressMouseEventsFromGestures 248 m_suppressMouseEventsFromGestures
248 ? WebInputEventResult::HandledSuppressed 249 ? WebInputEventResult::HandledSuppressed
249 : m_mouseEventManager->setMousePositionAndDispatchMouseEvent( 250 : m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
250 currentHitTest.innerNode(), EventTypeNames::mouseup, 251 currentHitTest.innerNode(), EventTypeNames::mouseup,
251 fakeMouseUp); 252 fakeMouseUp);
252 253
253 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; 254 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled;
254 if (tappedNonTextNode) { 255 if (tappedNonTextNode) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 IntPoint tappedPositionInViewport = 289 IntPoint tappedPositionInViewport =
289 frameHost()->visualViewport().rootFrameToViewport(tappedPosition); 290 frameHost()->visualViewport().rootFrameToViewport(tappedPosition);
290 m_frame->chromeClient().showUnhandledTapUIIfNeeded( 291 m_frame->chromeClient().showUnhandledTapUIIfNeeded(
291 tappedPositionInViewport, tappedNode, domTreeChanged || styleChanged); 292 tappedPositionInViewport, tappedNode, domTreeChanged || styleChanged);
292 } 293 }
293 return eventResult; 294 return eventResult;
294 } 295 }
295 296
296 WebInputEventResult GestureManager::handleGestureLongPress( 297 WebInputEventResult GestureManager::handleGestureLongPress(
297 const GestureEventWithHitTestResults& targetedEvent) { 298 const GestureEventWithHitTestResults& targetedEvent) {
298 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 299 const WebGestureEvent& gestureEvent = targetedEvent.event();
299 300
300 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests 301 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests
301 // here (re-using the supplied HitTestResult), but that will require some 302 // here (re-using the supplied HitTestResult), but that will require some
302 // overhaul of the touch drag-and-drop code and LongPress is such a special 303 // overhaul of the touch drag-and-drop code and LongPress is such a special
303 // scenario that it's unlikely to matter much in practice. 304 // scenario that it's unlikely to matter much in practice.
304 305
305 IntPoint hitTestPoint = 306 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(
306 m_frame->view()->rootFrameToContents(gestureEvent.position()); 307 flooredIntPoint(gestureEvent.positionInRootFrame()));
307 HitTestResult hitTestResult = 308 HitTestResult hitTestResult =
308 m_frame->eventHandler().hitTestResultAtPoint(hitTestPoint); 309 m_frame->eventHandler().hitTestResultAtPoint(hitTestPoint);
309 310
310 m_longTapShouldInvokeContextMenu = false; 311 m_longTapShouldInvokeContextMenu = false;
311 bool hitTestContainsLinks = hitTestResult.URLElement() || 312 bool hitTestContainsLinks = hitTestResult.URLElement() ||
312 !hitTestResult.absoluteImageURL().isNull() || 313 !hitTestResult.absoluteImageURL().isNull() ||
313 !hitTestResult.absoluteMediaURL().isNull(); 314 !hitTestResult.absoluteMediaURL().isNull();
314 315
315 if (!hitTestContainsLinks && 316 if (!hitTestContainsLinks &&
316 m_mouseEventManager->handleDragDropIfPossible(targetedEvent)) { 317 m_mouseEventManager->handleDragDropIfPossible(targetedEvent)) {
(...skipping 23 matching lines...) Expand all
340 } 341 }
341 342
342 WebInputEventResult GestureManager::handleGestureTwoFingerTap( 343 WebInputEventResult GestureManager::handleGestureTwoFingerTap(
343 const GestureEventWithHitTestResults& targetedEvent) { 344 const GestureEventWithHitTestResults& targetedEvent) {
344 m_selectionController->handleGestureTwoFingerTap(targetedEvent); 345 m_selectionController->handleGestureTwoFingerTap(targetedEvent);
345 return sendContextMenuEventForGesture(targetedEvent); 346 return sendContextMenuEventForGesture(targetedEvent);
346 } 347 }
347 348
348 WebInputEventResult GestureManager::sendContextMenuEventForGesture( 349 WebInputEventResult GestureManager::sendContextMenuEventForGesture(
349 const GestureEventWithHitTestResults& targetedEvent) { 350 const GestureEventWithHitTestResults& targetedEvent) {
350 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 351 const WebGestureEvent& gestureEvent = targetedEvent.event();
351 unsigned modifiers = gestureEvent.getModifiers(); 352 unsigned modifiers = gestureEvent.modifiers;
352 353
353 if (!m_suppressMouseEventsFromGestures) { 354 if (!m_suppressMouseEventsFromGestures) {
354 // Send MouseMoved event prior to handling (https://crbug.com/485290). 355 // Send MouseMoved event prior to handling (https://crbug.com/485290).
355 PlatformMouseEvent fakeMouseMove( 356 PlatformMouseEvent fakeMouseMove(
356 gestureEvent.position(), gestureEvent.globalPosition(), 357 gestureEvent, WebPointerProperties::Button::NoButton,
357 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 358 PlatformEvent::MouseMoved,
358 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers), 359 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers),
359 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), 360 PlatformMouseEvent::FromTouch, gestureEvent.timeStampSeconds,
360 WebPointerProperties::PointerType::Mouse); 361 WebPointerProperties::PointerType::Mouse);
361 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( 362 m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
362 targetedEvent.hitTestResult().innerNode(), EventTypeNames::mousemove, 363 targetedEvent.hitTestResult().innerNode(), EventTypeNames::mousemove,
363 fakeMouseMove); 364 fakeMouseMove);
364 } 365 }
365 366
366 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; 367 PlatformEvent::EventType eventType = PlatformEvent::MousePressed;
367 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) 368 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp())
368 eventType = PlatformEvent::MouseReleased; 369 eventType = PlatformEvent::MouseReleased;
369 370
370 PlatformMouseEvent mouseEvent( 371 PlatformMouseEvent mouseEvent(
371 targetedEvent.event().position(), targetedEvent.event().globalPosition(), 372 gestureEvent, WebPointerProperties::Button::Right, eventType,
372 WebPointerProperties::Button::Right, eventType, /* clickCount */ 1, 373 /* clickCount */ 1,
373 static_cast<PlatformEvent::Modifiers>( 374 static_cast<PlatformEvent::Modifiers>(
374 modifiers | PlatformEvent::Modifiers::RightButtonDown), 375 modifiers | PlatformEvent::Modifiers::RightButtonDown),
375 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), 376 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(),
376 WebPointerProperties::PointerType::Mouse); 377 WebPointerProperties::PointerType::Mouse);
377 378
378 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); 379 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent);
379 } 380 }
380 381
381 WebInputEventResult GestureManager::handleGestureShowPress() { 382 WebInputEventResult GestureManager::handleGestureShowPress() {
382 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); 383 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime();
(...skipping 19 matching lines...) Expand all
402 return nullptr; 403 return nullptr;
403 404
404 return &m_frame->page()->frameHost(); 405 return &m_frame->page()->frameHost();
405 } 406 }
406 407
407 double GestureManager::getLastShowPressTimestamp() const { 408 double GestureManager::getLastShowPressTimestamp() const {
408 return m_lastShowPressTimestamp; 409 return m_lastShowPressTimestamp;
409 } 410 }
410 411
411 } // namespace blink 412 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698