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

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

Issue 1136953011: Shrinking EventPath to improve memory usage and performance (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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/events/EventPath.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « Source/core/events/EventPath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698