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

Unified Diff: Source/core/page/EventHandler.cpp

Issue 453493002: Improve detection of touch events when hiding media controls. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@autoHideControls
Patch Set: Cannot use isSimulated, so define derivesFromTouch Created 6 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
« Source/core/events/MouseEvent.h ('K') | « Source/core/page/EventHandler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/EventHandler.cpp
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
index 757bdf11c82ae9d1d1eb1f115577fc3b10074a04..05a88d82f4f5e66a24b3e1a58cb4229e53c918ef 100644
--- a/Source/core/page/EventHandler.cpp
+++ b/Source/core/page/EventHandler.cpp
@@ -1283,7 +1283,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
m_frame->selection().setCaretBlinkingSuspended(true);
- bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targetNode(), m_clickCount, mouseEvent, true);
+ bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targetNode(), m_clickCount, mouseEvent, true, false);
swallowEvent = swallowEvent || handleMouseFocus(mouseEvent);
m_capturesDragging = !swallowEvent || mev.scrollbar();
@@ -1398,7 +1398,7 @@ bool EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMouseEvent& mouseEv
}
if (m_frameSetBeingResized)
- return !dispatchMouseEvent(EventTypeNames::mousemove, m_frameSetBeingResized.get(), 0, mouseEvent, false);
+ return !dispatchMouseEvent(EventTypeNames::mousemove, m_frameSetBeingResized.get(), 0, mouseEvent, false, false);
// Send events right to a scrollbar if the mouse is pressed.
if (m_lastScrollbarUnderMouse && m_mousePressed) {
@@ -1453,7 +1453,7 @@ bool EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMouseEvent& mouseEv
if (newSubframe) {
// Update over/out state before passing the event to the subframe.
- updateMouseEventTargetNode(mev.targetNode(), mouseEvent, true);
+ updateMouseEventTargetNode(mev.targetNode(), mouseEvent, true, false);
// Event dispatch in updateMouseEventTargetNode may have caused the subframe of the target
// node to be detached from its FrameView, in which case the event should not be passed.
@@ -1476,7 +1476,7 @@ bool EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMouseEvent& mouseEv
if (swallowEvent)
return true;
- swallowEvent = !dispatchMouseEvent(EventTypeNames::mousemove, mev.targetNode(), 0, mouseEvent, true);
+ swallowEvent = !dispatchMouseEvent(EventTypeNames::mousemove, mev.targetNode(), 0, mouseEvent, true, false);
if (!swallowEvent)
swallowEvent = handleMouseDraggedEvent(mev);
@@ -1528,13 +1528,13 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
}
if (m_frameSetBeingResized)
- return !dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResized.get(), m_clickCount, mouseEvent, false);
+ return !dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResized.get(), m_clickCount, mouseEvent, false, false);
if (m_lastScrollbarUnderMouse) {
invalidateClick();
m_lastScrollbarUnderMouse->mouseUp(mouseEvent);
bool setUnder = false;
- return !dispatchMouseEvent(EventTypeNames::mouseup, m_lastNodeUnderMouse.get(), m_clickCount, mouseEvent, setUnder);
+ return !dispatchMouseEvent(EventTypeNames::mouseup, m_lastNodeUnderMouse.get(), m_clickCount, mouseEvent, setUnder, false);
}
// Mouse events simulated from touch should not hit-test again.
@@ -1549,7 +1549,7 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
if (subframe && passMouseReleaseEventToSubframe(mev, subframe))
return true;
- bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, mev.targetNode(), m_clickCount, mouseEvent, false);
+ bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, mev.targetNode(), m_clickCount, mouseEvent, false, false);
bool contextMenuEvent = mouseEvent.button() == RightButton;
#if OS(MACOSX)
@@ -1561,7 +1561,7 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
bool swallowClickEvent = false;
if (m_clickCount > 0 && !contextMenuEvent && mev.targetNode() && m_clickNode) {
if (Node* clickTargetNode = mev.targetNode()->commonAncestor(*m_clickNode, parentForClickEvent))
- swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, clickTargetNode, m_clickCount, mouseEvent, true);
+ swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, clickTargetNode, m_clickCount, mouseEvent, true, false);
}
if (m_resizeScrollableArea) {
@@ -1804,7 +1804,7 @@ MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques
return m_frame->document()->prepareMouseEvent(request, documentPointForWindowPoint(m_frame, mev.position()), mev);
}
-void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMouseEvent& mouseEvent, bool fireMouseOverOut)
+void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMouseEvent& mouseEvent, bool fireMouseOverOut, bool derivesFromTouch)
{
Node* result = targetNode;
@@ -1856,20 +1856,20 @@ void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo
if (m_lastNodeUnderMouse != m_nodeUnderMouse) {
// send mouseout event to the old node
if (m_lastNodeUnderMouse)
- m_lastNodeUnderMouse->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseout, 0, m_nodeUnderMouse.get());
+ m_lastNodeUnderMouse->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseout, 0, m_nodeUnderMouse.get(), derivesFromTouch);
// send mouseover event to the new node
if (m_nodeUnderMouse)
- m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseover, 0, m_lastNodeUnderMouse.get());
+ m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseover, 0, m_lastNodeUnderMouse.get(), derivesFromTouch);
}
m_lastNodeUnderMouse = m_nodeUnderMouse;
}
}
// The return value means 'continue default handling.'
-bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent, bool setUnder)
+bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent, bool setUnder, bool derivesFromTouch)
{
- updateMouseEventTargetNode(targetNode, mouseEvent, setUnder);
- return !m_nodeUnderMouse || m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, eventType, clickCount);
+ updateMouseEventTargetNode(targetNode, mouseEvent, setUnder, derivesFromTouch);
+ return !m_nodeUnderMouse || m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, eventType, clickCount, 0, derivesFromTouch);
}
// The return value means 'swallow event' (was handled), as for other handle* functions.
@@ -2238,7 +2238,7 @@ bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
PlatformMouseEvent fakeMouseMove(adjustedPoint, gestureEvent.globalPosition(),
NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
- dispatchMouseEvent(EventTypeNames::mousemove, newHitTest.targetNode(), 0, fakeMouseMove, true);
+ dispatchMouseEvent(EventTypeNames::mousemove, newHitTest.targetNode(), 0, fakeMouseMove, true, true);
Rick Byers 2014/08/19 16:06:47 Rather than take a completely new bool here, this
// Do a new hit-test in case the mousemove event changed the DOM.
// FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.com/398920
@@ -2250,7 +2250,7 @@ bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
PlatformMouseEvent fakeMouseDown(adjustedPoint, gestureEvent.globalPosition(),
LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(),
modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
- bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, newHitTest.targetNode(), gestureEvent.tapCount(), fakeMouseDown, true);
+ bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, newHitTest.targetNode(), gestureEvent.tapCount(), fakeMouseDown, true, true);
if (!swallowMouseDownEvent)
swallowMouseDownEvent = handleMouseFocus(fakeMouseDown);
if (!swallowMouseDownEvent)
@@ -2261,12 +2261,12 @@ bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
PlatformMouseEvent fakeMouseUp(adjustedPoint, gestureEvent.globalPosition(),
LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(),
modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
- bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, newHitTest.targetNode(), gestureEvent.tapCount(), fakeMouseUp, false);
+ bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, newHitTest.targetNode(), gestureEvent.tapCount(), fakeMouseUp, false, true);
bool swallowClickEvent = false;
if (m_clickNode) {
Node* clickTargetNode = newHitTest.targetNode()->commonAncestor(*m_clickNode, parentForClickEvent);
- swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, clickTargetNode, gestureEvent.tapCount(), fakeMouseUp, true);
+ swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, clickTargetNode, gestureEvent.tapCount(), fakeMouseUp, true, true);
m_clickNode = nullptr;
}
@@ -2689,7 +2689,7 @@ bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event)
selectClosestWordOrLinkFromMouseEvent(mev);
}
- return !dispatchMouseEvent(EventTypeNames::contextmenu, mev.targetNode(), 0, event, false);
+ return !dispatchMouseEvent(EventTypeNames::contextmenu, mev.targetNode(), 0, event, false, false);
}
bool EventHandler::sendContextMenuEventForKey()
« Source/core/events/MouseEvent.h ('K') | « Source/core/page/EventHandler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698