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

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

Issue 2141993003: PointerEvents for long-press: fix double firing & canceling MEs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed preventing MEs on canceled pointerdowns Created 4 years, 5 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 // 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/editing/SelectionController.h" 8 #include "core/editing/SelectionController.h"
9 #include "core/events/GestureEvent.h" 9 #include "core/events/GestureEvent.h"
10 #include "core/frame/FrameHost.h" 10 #include "core/frame/FrameHost.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return handleGestureTapDown(targetedEvent); 97 return handleGestureTapDown(targetedEvent);
98 case PlatformEvent::GestureTap: 98 case PlatformEvent::GestureTap:
99 return handleGestureTap(targetedEvent); 99 return handleGestureTap(targetedEvent);
100 case PlatformEvent::GestureShowPress: 100 case PlatformEvent::GestureShowPress:
101 return handleGestureShowPress(); 101 return handleGestureShowPress();
102 case PlatformEvent::GestureLongPress: 102 case PlatformEvent::GestureLongPress:
103 return handleGestureLongPress(targetedEvent); 103 return handleGestureLongPress(targetedEvent);
104 case PlatformEvent::GestureLongTap: 104 case PlatformEvent::GestureLongTap:
105 return handleGestureLongTap(targetedEvent); 105 return handleGestureLongTap(targetedEvent);
106 case PlatformEvent::GestureTwoFingerTap: 106 case PlatformEvent::GestureTwoFingerTap:
107 return m_frame->eventHandler().sendContextMenuEventForGesture(targetedEv ent); 107 return handleGestureTwoFingerTap(targetedEvent);
108 case PlatformEvent::GesturePinchBegin: 108 case PlatformEvent::GesturePinchBegin:
109 case PlatformEvent::GesturePinchEnd: 109 case PlatformEvent::GesturePinchEnd:
110 case PlatformEvent::GesturePinchUpdate: 110 case PlatformEvent::GesturePinchUpdate:
111 case PlatformEvent::GestureTapDownCancel: 111 case PlatformEvent::GestureTapDownCancel:
112 case PlatformEvent::GestureTapUnconfirmed: 112 case PlatformEvent::GestureTapUnconfirmed:
113 break; 113 break;
114 default: 114 default:
115 NOTREACHED(); 115 NOTREACHED();
116 } 116 }
117 117
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 m_longTapShouldInvokeContextMenu = true; 259 m_longTapShouldInvokeContextMenu = true;
260 return WebInputEventResult::HandledSystem; 260 return WebInputEventResult::HandledSystem;
261 } 261 }
262 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(gestureEvent.po sition()); 262 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(gestureEvent.po sition());
263 HitTestResult result = m_frame->eventHandler().hitTestResultAtPoint(hitTestP oint); 263 HitTestResult result = m_frame->eventHandler().hitTestResultAtPoint(hitTestP oint);
264 if (m_selectionController->handleGestureLongPress(gestureEvent, result)) { 264 if (m_selectionController->handleGestureLongPress(gestureEvent, result)) {
265 m_frame->eventHandler().focusDocumentView(); 265 m_frame->eventHandler().focusDocumentView();
266 return WebInputEventResult::HandledSystem; 266 return WebInputEventResult::HandledSystem;
267 } 267 }
268 268
269 return m_frame->eventHandler().sendContextMenuEventForGesture(targetedEvent) ; 269 return sendContextMenuEventForGesture(targetedEvent);
270 } 270 }
271 271
272 WebInputEventResult GestureManager::handleGestureLongTap(const GestureEventWithH itTestResults& targetedEvent) 272 WebInputEventResult GestureManager::handleGestureLongTap(const GestureEventWithH itTestResults& targetedEvent)
273 { 273 {
274 #if !OS(ANDROID) 274 #if !OS(ANDROID)
275 if (m_longTapShouldInvokeContextMenu) { 275 if (m_longTapShouldInvokeContextMenu) {
276 m_longTapShouldInvokeContextMenu = false; 276 m_longTapShouldInvokeContextMenu = false;
277 return m_frame->eventHandler().sendContextMenuEventForGesture(targetedEv ent); 277 return sendContextMenuEventForGesture(targetedEvent);
278 } 278 }
279 #endif 279 #endif
280 return WebInputEventResult::NotHandled; 280 return WebInputEventResult::NotHandled;
281 } 281 }
282 282
283 WebInputEventResult GestureManager::handleGestureTwoFingerTap(const GestureEvent WithHitTestResults& targetedEvent)
284 {
285 return sendContextMenuEventForGesture(targetedEvent);
286 }
287
288 WebInputEventResult GestureManager::sendContextMenuEventForGesture(const Gesture EventWithHitTestResults& targetedEvent)
289 {
290 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
291 unsigned modifiers = gestureEvent.getModifiers();
292
293 if (!m_suppressMouseEventsFromGestures) {
294 // Send MouseMoved event prior to handling (https://crbug.com/485290).
295 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.g lobalPosition(),
296 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
297 static_cast<PlatformEvent::Modifiers>(modifiers),
298 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerP roperties::PointerType::Mouse);
299
300 m_frame->eventHandler().dispatchMouseEvent(EventTypeNames::mousemove, ta rgetedEvent.hitTestResult().innerNode(), 0, fakeMouseMove);
301 }
302
303 PlatformEvent::EventType eventType = PlatformEvent::MousePressed;
304 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp())
305 eventType = PlatformEvent::MouseReleased;
306
307 // To simulate right-click behavior, we send a right mouse down and then
308 // context menu event.
309 // TODO(crbug.com/579564): Maybe we should not send mouse down at all
310 PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEven t.event().globalPosition(), RightButton, eventType, 1,
311 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::RightBu ttonDown),
312 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), WebPo interProperties::PointerType::Mouse);
313
314 if (!m_suppressMouseEventsFromGestures && m_frame->view()) {
315 MouseEventWithHitTestResults mev(mouseEvent, targetedEvent.hitTestResult ());
dtapuska 2016/07/18 21:16:31 Is it safe to reuse the hit test result here? The
mustaq 2016/07/19 15:50:27 Brought back the hittest, got distracted by the fi
mustaq 2016/07/19 15:52:32 Note that we don't passMousePressEventToScrollbar(
mustaq 2016/07/20 15:54:41 Bad news: the cherry-picking of DOM events is caus
316 WebInputEventResult eventResult = m_frame->eventHandler().dispatchMouseE vent(EventTypeNames::mousedown, mev.innerNode(), /* clickCount */ 0, mouseEvent) ;
317
318 if (eventResult == WebInputEventResult::NotHandled) {
319 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheti cEventType() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTo uchEventsSourceCapabilities() : InputDeviceCapabilities::doesntFireTouchEventsSo urceCapabilities();
320 eventResult = m_frame->eventHandler().handleMouseFocus(mev, sourceCa pabilities);
321 }
322
323 if (eventResult == WebInputEventResult::NotHandled)
324 m_frame->eventHandler().handleMousePressEvent(mev);
325 }
326
327 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent);
328 // We do not need to send a corresponding mouse release because in case of
329 // right-click, the context menu takes capture and consumes all events.
330 }
331
283 WebInputEventResult GestureManager::handleGestureShowPress() 332 WebInputEventResult GestureManager::handleGestureShowPress()
284 { 333 {
285 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); 334 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime();
286 335
287 FrameView* view = m_frame->view(); 336 FrameView* view = m_frame->view();
288 if (!view) 337 if (!view)
289 return WebInputEventResult::NotHandled; 338 return WebInputEventResult::NotHandled;
290 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) 339 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator())
291 scrollAnimator->cancelAnimation(); 340 scrollAnimator->cancelAnimation();
292 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); 341 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas();
(...skipping 14 matching lines...) Expand all
307 356
308 return &m_frame->page()->frameHost(); 357 return &m_frame->page()->frameHost();
309 } 358 }
310 359
311 double GestureManager::getLastShowPressTimestamp() const 360 double GestureManager::getLastShowPressTimestamp() const
312 { 361 {
313 return m_lastShowPressTimestamp; 362 return m_lastShowPressTimestamp;
314 } 363 }
315 364
316 } // namespace blink 365 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698