Index: Source/core/events/EventPath.cpp |
diff --git a/Source/core/events/EventPath.cpp b/Source/core/events/EventPath.cpp |
index 9e53e718837b7f4b98bb0c5d7645cbec6efd6614..4f3ba0286bb513402aa081d2f22e1e7b78c55c64 100644 |
--- a/Source/core/events/EventPath.cpp |
+++ b/Source/core/events/EventPath.cpp |
@@ -88,21 +88,17 @@ void EventPath::initialize() |
calculateTreeScopePrePostOrderNumbers(); |
} |
-void EventPath::addNodeEventContext(Node& node) |
-{ |
- m_nodeEventContexts.append(NodeEventContext(&node, eventTargetRespectingTargetRules(node))); |
-} |
- |
void EventPath::calculatePath() |
{ |
ASSERT(m_node); |
ASSERT(m_nodeEventContexts.isEmpty()); |
m_node->updateDistribution(); |
+ Vector<Node*, 256> nodesInPath; |
sof
2015/05/19 07:16:19
Make this WillBeHeapVector<RawPtrWillBeMember<Node
Daniel Bratell
2015/05/19 08:11:42
Done.
|
Node* current = m_node; |
- addNodeEventContext(*current); |
+ nodesInPath.append(current); |
if (!m_node->inDocument()) |
- return; |
+ current = nullptr; |
while (current) { |
if (m_event && current->keepEventInNode(m_event)) |
break; |
@@ -114,9 +110,9 @@ void EventPath::calculatePath() |
ShadowRoot* containingShadowRoot = insertionPoint->containingShadowRoot(); |
ASSERT(containingShadowRoot); |
if (!containingShadowRoot->isOldest()) |
- addNodeEventContext(*containingShadowRoot->olderShadowRoot()); |
+ nodesInPath.append(containingShadowRoot->olderShadowRoot()); |
} |
- addNodeEventContext(*insertionPoint); |
+ nodesInPath.append(insertionPoint); |
} |
current = insertionPoints.last(); |
continue; |
@@ -125,13 +121,19 @@ void EventPath::calculatePath() |
if (m_event && shouldStopAtShadowRoot(*m_event, *toShadowRoot(current), *m_node)) |
break; |
current = current->shadowHost(); |
- addNodeEventContext(*current); |
+ nodesInPath.append(current); |
} else { |
current = current->parentNode(); |
if (current) |
- addNodeEventContext(*current); |
+ nodesInPath.append(current); |
} |
} |
+ |
+ ASSERT(m_nodeEventContexts.size() == 0); |
hayato
2015/05/19 06:45:29
We don't need this ASSERT since L94 already assert
Daniel Bratell
2015/05/19 08:11:42
Done.
|
+ m_nodeEventContexts.reserveCapacity(nodesInPath.size()); |
+ for (Node* nodeInPath : nodesInPath) { |
+ m_nodeEventContexts.append(NodeEventContext(nodeInPath, eventTargetRespectingTargetRules(*nodeInPath))); |
+ } |
} |
void EventPath::calculateTreeScopePrePostOrderNumbers() |