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

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

Issue 849783002: Event.path should include Window (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: test expected update for http/tests/dom/crash-on-querying-event-path.html Created 5 years, 11 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: Source/core/events/Event.cpp
diff --git a/Source/core/events/Event.cpp b/Source/core/events/Event.cpp
index 09aea35a8b7f01ca55c0788ab8aff6a4c95ffd6b..96029aa6bf189ca3b30d52770af24831d30bbe12 100644
--- a/Source/core/events/Event.cpp
+++ b/Source/core/events/Event.cpp
@@ -236,28 +236,36 @@ void Event::initEventPath(Node& node)
m_eventPath = adoptPtrWillBeNoop(new EventPath(node, this));
}
-PassRefPtrWillBeRawPtr<StaticNodeList> Event::path() const
+WillBeHeapVector<RefPtrWillBeRawPtr<EventTarget>> Event::path() const
{
if (!m_currentTarget) {
ASSERT(m_eventPhase == Event::NONE);
if (!m_eventPath) {
// Before dispatching the event
- return StaticNodeList::createEmpty();
+ return WillBeHeapVector<RefPtrWillBeRawPtr<EventTarget>>();
}
ASSERT(!m_eventPath->isEmpty());
// After dispatching the event
return m_eventPath->last().treeScopeEventContext().ensureEventPath(*m_eventPath);
}
- if (!m_currentTarget->toNode())
- return StaticNodeList::createEmpty();
- Node* node = m_currentTarget->toNode();
- size_t eventPathSize = m_eventPath->size();
- for (size_t i = 0; i < eventPathSize; ++i) {
- if (node == (*m_eventPath)[i].node()) {
- return (*m_eventPath)[i].treeScopeEventContext().ensureEventPath(*m_eventPath);
+
+ if (Node* node = m_currentTarget->toNode()) {
+ ASSERT(m_eventPath);
+ size_t eventPathSize = m_eventPath->size();
+ for (size_t i = 0; i < eventPathSize; ++i) {
+ if (node == (*m_eventPath)[i].node()) {
+ return (*m_eventPath)[i].treeScopeEventContext().ensureEventPath(*m_eventPath);
+ }
}
+ ASSERT_NOT_REACHED();
}
- return StaticNodeList::createEmpty();
+
+ // Returns [window] for events that are directly dispatched to the window object;
+ // e.g., window.load, pageshow, etc.
+ if (LocalDOMWindow* window = m_currentTarget->toDOMWindow())
+ return WillBeHeapVector<RefPtrWillBeRawPtr<EventTarget>>(1, window);
+
+ return WillBeHeapVector<RefPtrWillBeRawPtr<EventTarget>>();
}
EventTarget* Event::currentTarget() const

Powered by Google App Engine
This is Rietveld 408576698