Chromium Code Reviews| 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 bad5b0dc36e3628c3abf728963fe111b80484d2d..dd44bd04e2ddfa67201299d3c7bca64e10a72212 100644 |
| --- a/third_party/WebKit/Source/core/input/EventHandler.cpp |
| +++ b/third_party/WebKit/Source/core/input/EventHandler.cpp |
| @@ -215,6 +215,7 @@ EventHandler::EventHandler(LocalFrame* frame) |
| , m_longTapShouldInvokeContextMenu(false) |
| , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| , m_lastShowPressTimestamp(0) |
| + , m_suppressMouseEventsFromGestures(false) |
| { |
| } |
| @@ -281,6 +282,7 @@ void EventHandler::clear() |
| m_longTapShouldInvokeContextMenu = false; |
| m_dragStartPos = LayoutPoint(); |
| m_mouseDown = PlatformMouseEvent(); |
| + m_suppressMouseEventsFromGestures = false; |
| } |
| WebInputEventResult EventHandler::mergeEventResult( |
| @@ -1809,6 +1811,8 @@ WebInputEventResult EventHandler::handleGestureEventInFrame(const GestureEventWi |
| } |
| switch (gestureEvent.type()) { |
| + case PlatformEvent::GestureTapDown: |
| + return handleGestureTapDown(targetedEvent); |
| case PlatformEvent::GestureTap: |
| return handleGestureTap(targetedEvent); |
| case PlatformEvent::GestureShowPress: |
| @@ -1819,7 +1823,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: |
| @@ -1840,6 +1843,13 @@ WebInputEventResult EventHandler::handleGestureScrollEvent(const PlatformGesture |
| return m_scrollManager.handleGestureScrollEvent(gestureEvent); |
| } |
| +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()); |
| @@ -1856,12 +1866,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 |
| @@ -1889,8 +1902,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; |
|
Rick Byers
2016/06/03 16:20:44
Back to the earlier discussion - as written this m
mustaq
2016/06/03 20:34:45
Looks like we were thinking in opposite directions
|
| + 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()); |
| @@ -1912,11 +1927,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) { |
| @@ -1960,6 +1978,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); |
| @@ -3089,7 +3109,6 @@ HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout |
| WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& event) |
| { |
| TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); |
| - |
| return m_pointerEventManager.handleTouchEvents(event); |
| } |