Index: Source/core/dom/EventRetargeter.cpp |
diff --git a/Source/core/dom/EventRetargeter.cpp b/Source/core/dom/EventRetargeter.cpp |
index 95ab788e9177ead2a3b9da1dcb4bb8fc72a1d6d9..502a57092e0ba3773eb76bd6286eacb4e371bf67 100644 |
--- a/Source/core/dom/EventRetargeter.cpp |
+++ b/Source/core/dom/EventRetargeter.cpp |
@@ -20,6 +20,7 @@ |
#include "config.h" |
#include "core/dom/EventRetargeter.h" |
+#include "RuntimeEnabledFeatures.h" |
#include "core/dom/ContainerNode.h" |
#include "core/dom/EventContext.h" |
#include "core/dom/EventPathWalker.h" |
@@ -103,6 +104,28 @@ void EventRetargeter::calculateEventPath(Node* node, Event* event) |
targetStack.removeLast(); |
} |
} |
+ |
+ // Calculates eventPath for each node for Event.path() API. |
+ if (!RuntimeEnabledFeatures::experimentalShadowDOMEnabled()) |
+ return; |
+ TreeScope* lastScope = 0; |
+ size_t eventPathSize = eventPath.size(); |
+ for (size_t i = 0; i < eventPathSize; ++i) { |
+ TreeScope* currentScope = eventPath[i]->node()->treeScope(); |
+ if (currentScope == lastScope) { |
+ // Fast path. |
+ eventPath[i]->setEventPath(eventPath[i - 1]->eventPath()); |
+ continue; |
+ } |
+ lastScope = currentScope; |
+ Vector<RefPtr<Node> > nodes; |
+ for (size_t j = 0; j < eventPathSize; ++j) { |
+ Node* node = eventPath[j]->node(); |
+ if (node->treeScope()->isInclusiveAncestorOf(currentScope)) |
+ nodes.append(node); |
+ } |
+ eventPath[i]->adoptEventPath(nodes); |
+ } |
} |
void EventRetargeter::adjustForMouseEvent(Node* node, MouseEvent& mouseEvent) |