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

Unified Diff: Source/core/dom/EventRetargeter.cpp

Issue 15063004: Make Event.path() return a pre-calculated NodeList rather than calculating it dynamically. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add an include. Created 7 years, 7 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
« no previous file with comments | « Source/core/dom/EventContext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « Source/core/dom/EventContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698