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

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

Issue 2249663002: Fixed & refactored mouse event firing at gesture context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed tests, removed one overfitting Created 4 years, 4 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/GestureManager.cpp
diff --git a/third_party/WebKit/Source/core/input/GestureManager.cpp b/third_party/WebKit/Source/core/input/GestureManager.cpp
index bb56ddba8fd8f4a17637580c017a1e3880187b65..0cd148a351eb2fe948e97ff2b659055cb130d0b1 100644
--- a/third_party/WebKit/Source/core/input/GestureManager.cpp
+++ b/third_party/WebKit/Source/core/input/GestureManager.cpp
@@ -187,7 +187,7 @@ WebInputEventResult GestureManager::handleGestureTap(const GestureEventWithHitTe
mouseDownEventResult = m_frame->eventHandler().dispatchMouseEvent(EventTypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown);
m_selectionController->initializeSelectionState();
if (mouseDownEventResult == WebInputEventResult::NotHandled)
- mouseDownEventResult = m_frame->eventHandler().handleMouseFocus(MouseEventWithHitTestResults(fakeMouseDown, currentHitTest), InputDeviceCapabilities::firesTouchEventsSourceCapabilities());
+ mouseDownEventResult = m_frame->eventHandler().handleMouseFocus(currentHitTest, InputDeviceCapabilities::firesTouchEventsSourceCapabilities());
if (mouseDownEventResult == WebInputEventResult::NotHandled)
mouseDownEventResult = m_frame->eventHandler().handleMousePressEvent(MouseEventWithHitTestResults(fakeMouseDown, currentHitTest));
}
@@ -298,25 +298,24 @@ WebInputEventResult GestureManager::sendContextMenuEventForGesture(const Gesture
PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerProperties::PointerType::Mouse);
m_frame->eventHandler().dispatchMouseEvent(
EventTypeNames::mousemove, targetedEvent.hitTestResult().innerNode(), 0, fakeMouseMove);
+
+ if (m_frame->view()) {
+ HitTestRequest request(HitTestRequest::Active);
+ LayoutPoint documentPoint = m_frame->view()->rootFrameToContents(targetedEvent.event().position());
+ HitTestResult hitTestResult(request, documentPoint);
+ m_frame->eventHandler().handleMouseFocus(hitTestResult, InputDeviceCapabilities::firesTouchEventsSourceCapabilities());
+ }
}
PlatformEvent::EventType eventType = PlatformEvent::MousePressed;
if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp())
eventType = PlatformEvent::MouseReleased;
- // To simulate right-click behavior, we send a right mouse down and then context menu event.
- // TODO(crbug.com/579564): Maybe we should not send mouse down at all
- PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEvent.event().globalPosition(), RightButton, eventType, 1,
- static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::RightButtonDown),
- PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), WebPointerProperties::PointerType::Mouse);
- if (!m_suppressMouseEventsFromGestures) {
- // FIXME: Send HitTestResults to avoid redundant hit tests.
- m_frame->eventHandler().handleMousePressEvent(mouseEvent);
- }
+ PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEvent.event().globalPosition(), NoButton,
+ eventType, /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers), PlatformMouseEvent::FromTouch,
+ WTF::monotonicallyIncreasingTime(), WebPointerProperties::PointerType::Mouse);
return m_frame->eventHandler().sendContextMenuEvent(mouseEvent);
- // We do not need to send a corresponding mouse release because in case of
- // right-click, the context menu takes capture and consumes all events.
}
WebInputEventResult GestureManager::handleGestureShowPress()

Powered by Google App Engine
This is Rietveld 408576698