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

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

Issue 2539283002: Remove PlatformGestureEvent in favour of using WebGestureEvent (Closed)
Patch Set: Add missing copyright on new file 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,
158 TimeTicks::FromSeconds(gestureEvent.timeStampSeconds),
158 WebPointerProperties::PointerType::Mouse); 159 WebPointerProperties::PointerType::Mouse);
159 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( 160 m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
160 currentHitTest.innerNode(), EventTypeNames::mousemove, fakeMouseMove); 161 currentHitTest.innerNode(), EventTypeNames::mousemove, fakeMouseMove);
161 } 162 }
162 163
163 // Do a new hit-test in case the mousemove event changed the DOM. 164 // 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 165 // 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 166 // 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 167 // 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 168 // note that the position of the frame may have changed, so we need to
168 // recompute the content co-ordinates (updating layout/style as 169 // recompute the content co-ordinates (updating layout/style as
169 // hitTestResultAtPoint normally would). 170 // hitTestResultAtPoint normally would).
170 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. 171 // FIXME: Use a hit-test cache to avoid unnecessary hit tests.
171 // http://crbug.com/398920 172 // http://crbug.com/398920
172 if (currentHitTest.innerNode()) { 173 if (currentHitTest.innerNode()) {
173 LocalFrame* mainFrame = m_frame->localFrameRoot(); 174 LocalFrame* mainFrame = m_frame->localFrameRoot();
174 if (mainFrame && mainFrame->view()) 175 if (mainFrame && mainFrame->view())
175 mainFrame->view()->updateLifecycleToCompositingCleanPlusScrolling(); 176 mainFrame->view()->updateLifecycleToCompositingCleanPlusScrolling();
176 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); 177 adjustedPoint = frameView->rootFrameToContents(
178 flooredIntPoint(gestureEvent.positionInRootFrame()));
177 currentHitTest = EventHandlingUtil::hitTestResultInFrame( 179 currentHitTest = EventHandlingUtil::hitTestResultInFrame(
178 m_frame, adjustedPoint, hitType); 180 m_frame, adjustedPoint, hitType);
179 } 181 }
180 182
181 // Capture data for showUnhandledTapUIIfNeeded. 183 // Capture data for showUnhandledTapUIIfNeeded.
182 Node* tappedNode = currentHitTest.innerNode(); 184 Node* tappedNode = currentHitTest.innerNode();
183 IntPoint tappedPosition = gestureEvent.position(); 185 IntPoint tappedPosition = flooredIntPoint(gestureEvent.positionInRootFrame());
184 Node* tappedNonTextNode = tappedNode; 186 Node* tappedNonTextNode = tappedNode;
185 UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create( 187 UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create(
186 tappedNode ? &tappedNode->document() : nullptr)); 188 tappedNode ? &tappedNode->document() : nullptr));
187 189
188 if (tappedNonTextNode && tappedNonTextNode->isTextNode()) 190 if (tappedNonTextNode && tappedNonTextNode->isTextNode())
189 tappedNonTextNode = FlatTreeTraversal::parent(*tappedNonTextNode); 191 tappedNonTextNode = FlatTreeTraversal::parent(*tappedNonTextNode);
190 192
191 m_mouseEventManager->setClickNode(tappedNonTextNode); 193 m_mouseEventManager->setClickNode(tappedNonTextNode);
192 194
193 PlatformMouseEvent fakeMouseDown( 195 PlatformMouseEvent fakeMouseDown(
194 gestureEvent.position(), gestureEvent.globalPosition(), 196 gestureEvent, WebPointerProperties::Button::Left,
195 WebPointerProperties::Button::Left, PlatformEvent::MousePressed, 197 PlatformEvent::MousePressed, gestureEvent.tapCount(),
196 gestureEvent.tapCount(), static_cast<PlatformEvent::Modifiers>( 198 static_cast<PlatformEvent::Modifiers>(modifiers |
197 modifiers | PlatformEvent::LeftButtonDown), 199 PlatformEvent::LeftButtonDown),
198 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), 200 PlatformMouseEvent::FromTouch,
201 TimeTicks::FromSeconds(gestureEvent.timeStampSeconds),
199 WebPointerProperties::PointerType::Mouse); 202 WebPointerProperties::PointerType::Mouse);
200 203
201 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that 204 // 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 205 // mean for for TEs? What's the right balance here? crbug.com/617255
203 WebInputEventResult mouseDownEventResult = 206 WebInputEventResult mouseDownEventResult =
204 WebInputEventResult::HandledSuppressed; 207 WebInputEventResult::HandledSuppressed;
205 if (!m_suppressMouseEventsFromGestures) { 208 if (!m_suppressMouseEventsFromGestures) {
206 m_mouseEventManager->setClickCount(gestureEvent.tapCount()); 209 m_mouseEventManager->setClickCount(gestureEvent.tapCount());
207 210
208 mouseDownEventResult = 211 mouseDownEventResult =
209 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( 212 m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
210 currentHitTest.innerNode(), EventTypeNames::mousedown, 213 currentHitTest.innerNode(), EventTypeNames::mousedown,
211 fakeMouseDown); 214 fakeMouseDown);
212 m_selectionController->initializeSelectionState(); 215 m_selectionController->initializeSelectionState();
213 if (mouseDownEventResult == WebInputEventResult::NotHandled) 216 if (mouseDownEventResult == WebInputEventResult::NotHandled)
214 mouseDownEventResult = m_mouseEventManager->handleMouseFocus( 217 mouseDownEventResult = m_mouseEventManager->handleMouseFocus(
215 currentHitTest, 218 currentHitTest,
216 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()); 219 InputDeviceCapabilities::firesTouchEventsSourceCapabilities());
217 if (mouseDownEventResult == WebInputEventResult::NotHandled) 220 if (mouseDownEventResult == WebInputEventResult::NotHandled)
218 mouseDownEventResult = m_mouseEventManager->handleMousePressEvent( 221 mouseDownEventResult = m_mouseEventManager->handleMousePressEvent(
219 MouseEventWithHitTestResults(fakeMouseDown, currentHitTest)); 222 MouseEventWithHitTestResults(fakeMouseDown, currentHitTest));
220 } 223 }
221 224
222 if (currentHitTest.innerNode()) { 225 if (currentHitTest.innerNode()) {
223 DCHECK(gestureEvent.type() == PlatformEvent::GestureTap); 226 DCHECK(gestureEvent.type == WebInputEvent::GestureTap);
224 HitTestResult result = currentHitTest; 227 HitTestResult result = currentHitTest;
225 result.setToShadowHostIfInUserAgentShadowRoot(); 228 result.setToShadowHostIfInUserAgentShadowRoot();
226 m_frame->chromeClient().onMouseDown(result.innerNode()); 229 m_frame->chromeClient().onMouseDown(result.innerNode());
227 } 230 }
228 231
229 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. 232 // FIXME: Use a hit-test cache to avoid unnecessary hit tests.
230 // http://crbug.com/398920 233 // http://crbug.com/398920
231 if (currentHitTest.innerNode()) { 234 if (currentHitTest.innerNode()) {
232 LocalFrame* mainFrame = m_frame->localFrameRoot(); 235 LocalFrame* mainFrame = m_frame->localFrameRoot();
233 if (mainFrame && mainFrame->view()) 236 if (mainFrame && mainFrame->view())
234 mainFrame->view()->updateAllLifecyclePhases(); 237 mainFrame->view()->updateAllLifecyclePhases();
235 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); 238 adjustedPoint = frameView->rootFrameToContents(tappedPosition);
236 currentHitTest = EventHandlingUtil::hitTestResultInFrame( 239 currentHitTest = EventHandlingUtil::hitTestResultInFrame(
237 m_frame, adjustedPoint, hitType); 240 m_frame, adjustedPoint, hitType);
238 } 241 }
239 242
240 PlatformMouseEvent fakeMouseUp( 243 PlatformMouseEvent fakeMouseUp(
241 gestureEvent.position(), gestureEvent.globalPosition(), 244 gestureEvent, WebPointerProperties::Button::Left,
242 WebPointerProperties::Button::Left, PlatformEvent::MouseReleased, 245 PlatformEvent::MouseReleased, gestureEvent.tapCount(),
243 gestureEvent.tapCount(), static_cast<PlatformEvent::Modifiers>(modifiers), 246 static_cast<PlatformEvent::Modifiers>(modifiers),
244 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), 247 PlatformMouseEvent::FromTouch,
248 TimeTicks::FromSeconds(gestureEvent.timeStampSeconds),
245 WebPointerProperties::PointerType::Mouse); 249 WebPointerProperties::PointerType::Mouse);
246 WebInputEventResult mouseUpEventResult = 250 WebInputEventResult mouseUpEventResult =
247 m_suppressMouseEventsFromGestures 251 m_suppressMouseEventsFromGestures
248 ? WebInputEventResult::HandledSuppressed 252 ? WebInputEventResult::HandledSuppressed
249 : m_mouseEventManager->setMousePositionAndDispatchMouseEvent( 253 : m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
250 currentHitTest.innerNode(), EventTypeNames::mouseup, 254 currentHitTest.innerNode(), EventTypeNames::mouseup,
251 fakeMouseUp); 255 fakeMouseUp);
252 256
253 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; 257 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled;
254 if (tappedNonTextNode) { 258 if (tappedNonTextNode) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 IntPoint tappedPositionInViewport = 292 IntPoint tappedPositionInViewport =
289 frameHost()->visualViewport().rootFrameToViewport(tappedPosition); 293 frameHost()->visualViewport().rootFrameToViewport(tappedPosition);
290 m_frame->chromeClient().showUnhandledTapUIIfNeeded( 294 m_frame->chromeClient().showUnhandledTapUIIfNeeded(
291 tappedPositionInViewport, tappedNode, domTreeChanged || styleChanged); 295 tappedPositionInViewport, tappedNode, domTreeChanged || styleChanged);
292 } 296 }
293 return eventResult; 297 return eventResult;
294 } 298 }
295 299
296 WebInputEventResult GestureManager::handleGestureLongPress( 300 WebInputEventResult GestureManager::handleGestureLongPress(
297 const GestureEventWithHitTestResults& targetedEvent) { 301 const GestureEventWithHitTestResults& targetedEvent) {
298 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 302 const WebGestureEvent& gestureEvent = targetedEvent.event();
299 303
300 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests 304 // 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 305 // 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 306 // 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. 307 // scenario that it's unlikely to matter much in practice.
304 308
305 IntPoint hitTestPoint = 309 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(
306 m_frame->view()->rootFrameToContents(gestureEvent.position()); 310 flooredIntPoint(gestureEvent.positionInRootFrame()));
307 HitTestResult hitTestResult = 311 HitTestResult hitTestResult =
308 m_frame->eventHandler().hitTestResultAtPoint(hitTestPoint); 312 m_frame->eventHandler().hitTestResultAtPoint(hitTestPoint);
309 313
310 m_longTapShouldInvokeContextMenu = false; 314 m_longTapShouldInvokeContextMenu = false;
311 bool hitTestContainsLinks = hitTestResult.URLElement() || 315 bool hitTestContainsLinks = hitTestResult.URLElement() ||
312 !hitTestResult.absoluteImageURL().isNull() || 316 !hitTestResult.absoluteImageURL().isNull() ||
313 !hitTestResult.absoluteMediaURL().isNull(); 317 !hitTestResult.absoluteMediaURL().isNull();
314 318
315 if (!hitTestContainsLinks && 319 if (!hitTestContainsLinks &&
316 m_mouseEventManager->handleDragDropIfPossible(targetedEvent)) { 320 m_mouseEventManager->handleDragDropIfPossible(targetedEvent)) {
(...skipping 23 matching lines...) Expand all
340 } 344 }
341 345
342 WebInputEventResult GestureManager::handleGestureTwoFingerTap( 346 WebInputEventResult GestureManager::handleGestureTwoFingerTap(
343 const GestureEventWithHitTestResults& targetedEvent) { 347 const GestureEventWithHitTestResults& targetedEvent) {
344 m_selectionController->handleGestureTwoFingerTap(targetedEvent); 348 m_selectionController->handleGestureTwoFingerTap(targetedEvent);
345 return sendContextMenuEventForGesture(targetedEvent); 349 return sendContextMenuEventForGesture(targetedEvent);
346 } 350 }
347 351
348 WebInputEventResult GestureManager::sendContextMenuEventForGesture( 352 WebInputEventResult GestureManager::sendContextMenuEventForGesture(
349 const GestureEventWithHitTestResults& targetedEvent) { 353 const GestureEventWithHitTestResults& targetedEvent) {
350 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 354 const WebGestureEvent& gestureEvent = targetedEvent.event();
351 unsigned modifiers = gestureEvent.getModifiers(); 355 unsigned modifiers = gestureEvent.modifiers;
352 356
353 if (!m_suppressMouseEventsFromGestures) { 357 if (!m_suppressMouseEventsFromGestures) {
354 // Send MouseMoved event prior to handling (https://crbug.com/485290). 358 // Send MouseMoved event prior to handling (https://crbug.com/485290).
355 PlatformMouseEvent fakeMouseMove( 359 PlatformMouseEvent fakeMouseMove(
356 gestureEvent.position(), gestureEvent.globalPosition(), 360 gestureEvent, WebPointerProperties::Button::NoButton,
357 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 361 PlatformEvent::MouseMoved,
358 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers), 362 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers),
359 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), 363 PlatformMouseEvent::FromTouch,
364 TimeTicks::FromSeconds(gestureEvent.timeStampSeconds),
360 WebPointerProperties::PointerType::Mouse); 365 WebPointerProperties::PointerType::Mouse);
361 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( 366 m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
362 targetedEvent.hitTestResult().innerNode(), EventTypeNames::mousemove, 367 targetedEvent.hitTestResult().innerNode(), EventTypeNames::mousemove,
363 fakeMouseMove); 368 fakeMouseMove);
364 } 369 }
365 370
366 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; 371 PlatformEvent::EventType eventType = PlatformEvent::MousePressed;
367 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) 372 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp())
368 eventType = PlatformEvent::MouseReleased; 373 eventType = PlatformEvent::MouseReleased;
369 374
370 PlatformMouseEvent mouseEvent( 375 PlatformMouseEvent mouseEvent(
371 targetedEvent.event().position(), targetedEvent.event().globalPosition(), 376 gestureEvent, WebPointerProperties::Button::Right, eventType,
372 WebPointerProperties::Button::Right, eventType, /* clickCount */ 1, 377 /* clickCount */ 1,
373 static_cast<PlatformEvent::Modifiers>( 378 static_cast<PlatformEvent::Modifiers>(
374 modifiers | PlatformEvent::Modifiers::RightButtonDown), 379 modifiers | PlatformEvent::Modifiers::RightButtonDown),
375 PlatformMouseEvent::FromTouch, TimeTicks::Now(), 380 PlatformMouseEvent::FromTouch, TimeTicks::Now(),
376 WebPointerProperties::PointerType::Mouse); 381 WebPointerProperties::PointerType::Mouse);
377 382
378 if (!m_suppressMouseEventsFromGestures && m_frame->view()) { 383 if (!m_suppressMouseEventsFromGestures && m_frame->view()) {
379 HitTestRequest request(HitTestRequest::Active); 384 HitTestRequest request(HitTestRequest::Active);
380 LayoutPoint documentPoint = 385 LayoutPoint documentPoint = m_frame->view()->rootFrameToContents(
381 m_frame->view()->rootFrameToContents(targetedEvent.event().position()); 386 flooredIntPoint(targetedEvent.event().positionInRootFrame()));
382 MouseEventWithHitTestResults mev = 387 MouseEventWithHitTestResults mev =
383 m_frame->document()->performMouseEventHitTest(request, documentPoint, 388 m_frame->document()->performMouseEventHitTest(request, documentPoint,
384 mouseEvent); 389 mouseEvent);
385 m_mouseEventManager->handleMouseFocus( 390 m_mouseEventManager->handleMouseFocus(
386 mev.hitTestResult(), 391 mev.hitTestResult(),
387 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()); 392 InputDeviceCapabilities::firesTouchEventsSourceCapabilities());
388 } 393 }
389 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); 394 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent);
390 } 395 }
391 396
(...skipping 21 matching lines...) Expand all
413 return nullptr; 418 return nullptr;
414 419
415 return &m_frame->page()->frameHost(); 420 return &m_frame->page()->frameHost();
416 } 421 }
417 422
418 TimeTicks GestureManager::getLastShowPressTimestamp() const { 423 TimeTicks GestureManager::getLastShowPressTimestamp() const {
419 return m_lastShowPressTimestamp; 424 return m_lastShowPressTimestamp;
420 } 425 }
421 426
422 } // namespace blink 427 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/GestureManager.h ('k') | third_party/WebKit/Source/core/input/MouseEventManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698