void EventRetargeter::buildRelatedNodeMap(const Node* relatedNode, RelatedNodeMap& relatedNodeMap) { Vector<Node*, 32> relatedNodeStack; TreeScope* lastTreeScope = 0; for (Node* node = nodeOrHostIfPseudoElement(const_cast<Node*>(relatedNode)); node; node = node->parentOrShadowHostNode()) { if (relatedNodeStack.isEmpty()) relatedNodeStack.append(node); TreeScope* scope = node->treeScope(); // Skips adding a node to the map if treeScope does not change. Just for the performance optimization. if (scope != lastTreeScope) relatedNodeMap.add(scope, relatedNodeStack.last()); lastTreeScope = scope; if (node->isShadowRoot()) { ASSERT(!relatedNodeStack.isEmpty()); relatedNodeStack.removeLast(); } } }
void EventRetargeter::buildRelatedNodeMap(const Node* relatedNode, RelatedNodeMap& relatedNodeMap) { Vector<Node*, 32> relatedNodeStack; TreeScope* lastTreeScope = 0; for (EventPathWalker walker(relatedNode); walker.node(); walker.moveToParent()) { Node* node = walker.node(); if (relatedNodeStack.isEmpty()) relatedNodeStack.append(node); else if (walker.isVisitingInsertionPointInReprojection()) relatedNodeStack.append(relatedNodeStack.last()); TreeScope* scope = node->treeScope(); // Skips adding a node to the map if treeScope does not change. Just for the performance optimization. if (scope != lastTreeScope) relatedNodeMap.add(scope, relatedNodeStack.last()); lastTreeScope = scope; if (node->isShadowRoot()) { ASSERT(!relatedNodeStack.isEmpty()); relatedNodeStack.removeLast(); } } }