diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-09-28 16:39:37 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:31:01 +0000 |
commit | 9daf1655d7e4eaaa6ed5f44055a4b4fd399fd25c (patch) | |
tree | 322337ad0acbc75732f916376ec6d36e7ec0e5bc /Source/WebCore/page/EventHandler.cpp | |
parent | 6882a04fb36642862b11efe514251d32070c3d65 (diff) | |
download | qtwebkit-9daf1655d7e4eaaa6ed5f44055a4b4fd399fd25c.tar.gz |
Imported WebKit commit eb954cdcf58f9b915b2fcb6f8e4cb3a60650a4f3
Change-Id: I8dda875c38075d43b76fe3a21acb0ffa102bb82d
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/page/EventHandler.cpp')
-rw-r--r-- | Source/WebCore/page/EventHandler.cpp | 29 |
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) { |