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

Unified Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 1989623002: Suppressed MEs for gestures from cancelled PEs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a comment. Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/input/EventHandler.cpp
diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp
index 0ae26ba3d1e0713165e07821db931a4ca6935347..0124480a3ec2331a465b75796fac886e0eb3f096 100644
--- a/third_party/WebKit/Source/core/input/EventHandler.cpp
+++ b/third_party/WebKit/Source/core/input/EventHandler.cpp
@@ -261,6 +261,7 @@ EventHandler::EventHandler(LocalFrame* frame)
, m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired)
, m_lastShowPressTimestamp(0)
, m_deltaConsumedForScrollSequence(false)
+ , m_suppressMouseEventsFromGestures(false)
{
}
@@ -334,6 +335,7 @@ void EventHandler::clear()
m_dragStartPos = LayoutPoint();
m_offsetFromResizeCorner = LayoutSize();
m_mouseDown = PlatformMouseEvent();
+ m_suppressMouseEventsFromGestures = false;
}
WebInputEventResult EventHandler::mergeEventResult(
@@ -2063,6 +2065,8 @@ WebInputEventResult EventHandler::handleGestureEventInFrame(const GestureEventWi
}
switch (gestureEvent.type()) {
+ case PlatformEvent::GestureTapDown:
+ return handleGestureTapDown(targetedEvent);
case PlatformEvent::GestureTap:
return handleGestureTap(targetedEvent);
case PlatformEvent::GestureShowPress:
@@ -2073,7 +2077,6 @@ WebInputEventResult EventHandler::handleGestureEventInFrame(const GestureEventWi
return handleGestureLongTap(targetedEvent);
case PlatformEvent::GestureTwoFingerTap:
return sendContextMenuEventForGesture(targetedEvent);
- case PlatformEvent::GestureTapDown:
case PlatformEvent::GesturePinchBegin:
case PlatformEvent::GesturePinchEnd:
case PlatformEvent::GesturePinchUpdate:
@@ -2161,6 +2164,13 @@ WebInputEventResult EventHandler::handleGestureScrollEvent(const PlatformGesture
}
}
+WebInputEventResult EventHandler::handleGestureTapDown(const GestureEventWithHitTestResults& targetedEvent)
+{
+ m_suppressMouseEventsFromGestures =
+ m_pointerEventManager.primaryPointerdownCanceled(targetedEvent.event().uniqueTouchEventId());
+ return WebInputEventResult::NotHandled;
+}
+
WebInputEventResult EventHandler::handleGestureTap(const GestureEventWithHitTestResults& targetedEvent)
{
FrameView* frameView(m_frame->view());
@@ -2177,12 +2187,15 @@ WebInputEventResult EventHandler::handleGestureTap(const GestureEventWithHitTest
// co-ordinates outside the target's bounds.
IntPoint adjustedPoint = frameView->rootFrameToContents(gestureEvent.position());
- unsigned modifiers = gestureEvent.getModifiers();
- PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globalPosition(),
- NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
- static_cast<PlatformEvent::Modifiers>(modifiers),
- PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerProperties::PointerType::Mouse);
- dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0, fakeMouseMove);
+ const unsigned modifiers = gestureEvent.getModifiers();
+
+ if (!m_suppressMouseEventsFromGestures) {
+ PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globalPosition(),
+ NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
+ static_cast<PlatformEvent::Modifiers>(modifiers),
+ PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerProperties::PointerType::Mouse);
+ dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0, fakeMouseMove);
+ }
// Do a new hit-test in case the mousemove event changed the DOM.
// Note that if the original hit test wasn't over an element (eg. was over a scrollbar) we
@@ -2210,8 +2223,10 @@ WebInputEventResult EventHandler::handleGestureTap(const GestureEventWithHitTest
PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globalPosition(),
LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(),
static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftButtonDown),
- PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerProperties::PointerType::Mouse);
- WebInputEventResult mouseDownEventResult = dispatchMouseEvent(EventTypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown);
+ PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerProperties::PointerType::Mouse);
+ WebInputEventResult mouseDownEventResult = WebInputEventResult::NotHandled;
+ if (!m_suppressMouseEventsFromGestures)
+ mouseDownEventResult = dispatchMouseEvent(EventTypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown);
selectionController().initializeSelectionState();
if (mouseDownEventResult == WebInputEventResult::NotHandled)
mouseDownEventResult = handleMouseFocus(MouseEventWithHitTestResults(fakeMouseDown, currentHitTest), InputDeviceCapabilities::firesTouchEventsSourceCapabilities());
@@ -2233,11 +2248,14 @@ WebInputEventResult EventHandler::handleGestureTap(const GestureEventWithHitTest
adjustedPoint = frameView->rootFrameToContents(gestureEvent.position());
currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType);
}
+
PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalPosition(),
LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(),
static_cast<PlatformEvent::Modifiers>(modifiers),
- PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerProperties::PointerType::Mouse);
- WebInputEventResult mouseUpEventResult = dispatchMouseEvent(EventTypeNames::mouseup, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp);
+ PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerProperties::PointerType::Mouse);
+ WebInputEventResult mouseUpEventResult = WebInputEventResult::NotHandled;
+ if (!m_suppressMouseEventsFromGestures)
+ mouseUpEventResult = dispatchMouseEvent(EventTypeNames::mouseup, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp);
WebInputEventResult clickEventResult = WebInputEventResult::NotHandled;
if (m_clickNode) {
@@ -2281,6 +2299,8 @@ WebInputEventResult EventHandler::handleGestureLongPress(const GestureEventWithH
m_longTapShouldInvokeContextMenu = false;
if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_frame->view()) {
+ // TODO(mustaq): Suppressing long-tap MouseEvents could break
+ // drag-drop. Will do separately because of the risk. crbug.com/606938.
PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosition(), LeftButton, PlatformEvent::MousePressed, 1,
static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftButtonDown),
PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), WebPointerProperties::PointerType::Mouse);
@@ -3638,7 +3658,6 @@ HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout
WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
{
TRACE_EVENT0("blink", "EventHandler::handleTouchEvent");
-
return m_pointerEventManager.handleTouchEvents(event);
}

Powered by Google App Engine
This is Rietveld 408576698