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

Unified Diff: third_party/WebKit/Source/core/events/EventPath.cpp

Issue 2186823002: Do not call an event listener on a cloned node in svg <use>'s UA shadow tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rewrite Created 4 years, 5 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/events/EventPath.cpp
diff --git a/third_party/WebKit/Source/core/events/EventPath.cpp b/third_party/WebKit/Source/core/events/EventPath.cpp
index 91eb910123dbf79a5181116ccee8aea8c401d926..f45763f5d32e21fd5622a1432e1c86937a8eff29 100644
--- a/third_party/WebKit/Source/core/events/EventPath.cpp
+++ b/third_party/WebKit/Source/core/events/EventPath.cpp
@@ -35,6 +35,7 @@
#include "core/events/TouchEvent.h"
#include "core/events/TouchEventContext.h"
#include "core/html/HTMLSlotElement.h"
+#include "core/svg/SVGUseElement.h"
namespace blink {
@@ -76,15 +77,23 @@ void EventPath::initializeWith(Node& node, Event* event)
initialize();
}
-static inline bool eventPathShouldBeEmptyFor(Node& node)
+static inline bool isInSVGUseShadowTree(Node& node)
{
- return node.isPseudoElement() && !node.parentElement();
+ if (ShadowRoot* root = node.containingShadowRoot())
+ return root->type() == ShadowRootType::UserAgent && isSVGUseElement(root->host());
+ return false;
+}
+
+static inline bool eventPathShouldBeEmptyFor(Node& node, Event* event)
+{
+ return (node.isPseudoElement() && !node.parentElement()) || (isInSVGUseShadowTree(node) && event && !event->composed());
pdr. 2016/07/30 04:02:42 WDYT of breaking these two complex cases apart as
hayato 2016/08/01 03:44:10 Sounds nice. Done
}
void EventPath::initialize()
{
- if (eventPathShouldBeEmptyFor(*m_node))
+ if (eventPathShouldBeEmptyFor(*m_node, m_event))
return;
+
calculatePath();
calculateAdjustedTargets();
calculateTreeOrderAndSetNearestAncestorClosedTree();
@@ -102,6 +111,12 @@ void EventPath::calculatePath()
// storing it in a perfectly sized m_nodeEventContexts Vector.
HeapVector<Member<Node>, 64> nodesInPath;
Node* current = m_node;
+
+ // Exclude nodes in SVG <use>'s shadow tree from event path.
+ // See crbug.com/630870
+ while (isInSVGUseShadowTree(*current))
pdr. 2016/07/30 04:02:42 I think this can be rewritten using existing apis
hayato 2016/08/01 03:44:10 Thanks! Done.
+ current = &current->containingShadowRoot()->host();
+
nodesInPath.append(current);
while (current) {
if (m_event && current->keepEventInNode(m_event))

Powered by Google App Engine
This is Rietveld 408576698