summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/page/EventHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/page/EventHandler.cpp')
-rw-r--r--Source/WebCore/page/EventHandler.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp
index f13749ba0..e8aa9dfb3 100644
--- a/Source/WebCore/page/EventHandler.cpp
+++ b/Source/WebCore/page/EventHandler.cpp
@@ -1128,14 +1128,14 @@ HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe
}
}
+ // We should always start hit testing a clean tree.
+ if (m_frame.document())
+ m_frame.document()->updateLayoutIgnorePendingStylesheets();
HitTestResult result(point, padding.height(), padding.width(), padding.height(), padding.width());
-
RenderView* renderView = m_frame.contentRenderer();
if (!renderView)
return result;
-
- // We should always start hittesting a clean tree.
- renderView->document().updateLayoutIgnorePendingStylesheets();
+
// hitTestResultAtPoint is specifically used to hitTest into all frames, thus it always allows child frame content.
HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent);
renderView->hitTest(request, result);
@@ -1948,6 +1948,24 @@ void EventHandler::invalidateClick()
m_clickNode = nullptr;
}
+static Node* targetNodeForClickEvent(Node* mousePressNode, Node* mouseReleaseNode)
+{
+ if (!mousePressNode || !mouseReleaseNode)
+ return nullptr;
+
+ if (mousePressNode == mouseReleaseNode)
+ return mouseReleaseNode;
+
+ Element* mouseReleaseShadowHost = mouseReleaseNode->shadowHost();
+ if (mouseReleaseShadowHost && mouseReleaseShadowHost == mousePressNode->shadowHost()) {
+ // We want to dispatch the click to the shadow tree host element to give listeners the illusion that the
+ // shadom tree is a single element. For example, we want to give the illusion that <input type="range">
+ // is a single element even though it is a composition of multiple shadom tree elements.
+ return mouseReleaseShadowHost;
+ }
+ return nullptr;
+}
+
bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& platformMouseEvent)
{
RefPtr<FrameView> protector(m_frame.view());
@@ -2009,8 +2027,7 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& platformMou
bool contextMenuEvent = platformMouseEvent.button() == RightButton;
- Node* targetNode = mouseEvent.targetNode();
- Node* nodeToClick = (m_clickNode && targetNode) ? commonAncestorCrossingShadowBoundary(*m_clickNode, *targetNode) : nullptr;
+ Node* nodeToClick = targetNodeForClickEvent(m_clickNode.get(), mouseEvent.targetNode());
bool swallowClickEvent = m_clickCount > 0 && !contextMenuEvent && nodeToClick && !dispatchMouseEvent(eventNames().clickEvent, nodeToClick, true, m_clickCount, platformMouseEvent, true);
if (m_resizeLayer) {