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

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

Issue 14508005: Support an Event Path API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Introduce TreeScope::isInclusiveAncestorOf 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/Event.h ('k') | Source/core/dom/Event.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Event.cpp
diff --git a/Source/core/dom/Event.cpp b/Source/core/dom/Event.cpp
index 637ca94f119a5c4126a3cadc82fddd7a2d856675..de51a3f403605a7fa7e5735ad608fbdbe0b818d7 100644
--- a/Source/core/dom/Event.cpp
+++ b/Source/core/dom/Event.cpp
@@ -26,6 +26,7 @@
#include "core/dom/EventDispatcher.h"
#include "core/dom/EventNames.h"
#include "core/dom/EventTarget.h"
+#include "core/dom/StaticNodeList.h"
#include "core/dom/UserGestureIndicator.h"
#include "core/dom/WebCoreMemoryInstrumentation.h"
#include <wtf/CurrentTime.h>
@@ -201,4 +202,20 @@ void Event::setUnderlyingEvent(PassRefPtr<Event> ue)
m_underlyingEvent = ue;
}
+PassRefPtr<NodeList> Event::path() const
+{
+ if (!m_currentTarget || !m_currentTarget->toNode())
+ return StaticNodeList::createEmpty();
+ TreeScope* currentScope = m_currentTarget->toNode()->treeScope();
+ Vector<RefPtr<Node> > nodes;
+ size_t eventPathSize = m_eventPath.size();
+ for (size_t i = 0; i < eventPathSize; ++i) {
+ Node* node = m_eventPath[i]->node();
+ ASSERT(node);
+ if (node->treeScope()->isInclusiveAncestorOf(currentScope))
+ nodes.append(node);
+ }
+ return StaticNodeList::adopt(nodes);
+}
+
} // namespace WebCore
« no previous file with comments | « Source/core/dom/Event.h ('k') | Source/core/dom/Event.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698