Changeset 155264 in webkit
- Timestamp:
- Sep 7, 2013, 3:30:41 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r155262 r155264 1 2013-09-07 Antti Koivisto <antti@apple.com> 2 3 Simplify ComposedShadowTreeWalker parent traversal 4 https://bugs.webkit.org/show_bug.cgi?id=120971 5 6 Reviewed by Andreas Kling. 7 8 Combine a bunch of parent traversal functions into one. 9 10 * dom/ComposedShadowTreeWalker.cpp: 11 (WebCore::ComposedShadowTreeWalker::traverseParent): 12 (WebCore::ComposedShadowTreeWalker::previous): 13 * dom/ComposedShadowTreeWalker.h: 14 15 Remove unused fromFirstChild. 16 1 17 2013-09-07 Anders Carlsson <andersca@apple.com> 2 18 -
trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp
r154327 r155264 53 53 } 54 54 55 ComposedShadowTreeWalker ComposedShadowTreeWalker::fromFirstChild(const Node* node, Policy policy)56 {57 ComposedShadowTreeWalker walker(node, policy);58 walker.firstChild();59 return walker;60 }61 62 55 void ComposedShadowTreeWalker::firstChild() 63 56 { … … 179 172 } 180 173 181 inline Node* ComposedShadowTreeWalker::traverseNodeEscapingFallbackContents(const Node* node) const182 {183 ASSERT(node);184 if (!node->isInsertionPoint())185 return const_cast<Node*>(node);186 const InsertionPoint* insertionPoint = toInsertionPoint(node);187 return insertionPoint->hasDistribution() ? 0 :188 insertionPoint->isActive() ? traverseParent(node) : const_cast<Node*>(node);189 }190 191 174 void ComposedShadowTreeWalker::parent() 192 175 { … … 196 179 } 197 180 198 // FIXME: Use an iterative algorithm so that it can be inlined.199 // https://bugs.webkit.org/show_bug.cgi?id=90415200 181 Node* ComposedShadowTreeWalker::traverseParent(const Node* node) const 201 182 { … … 209 190 if (InsertionPoint* insertionPoint = findInsertionPointOf(node)) 210 191 return traverseParent(insertionPoint); 211 return 0; 212 } 213 return traverseParentInCurrentTree(node); 214 } 215 216 inline Node* ComposedShadowTreeWalker::traverseParentInCurrentTree(const Node* node) const 217 { 218 if (Node* parent = node->parentNode()) 219 return parent->isShadowRoot() ? traverseParentBackToShadowRootOrHost(toShadowRoot(parent)) : traverseNodeEscapingFallbackContents(parent); 220 return 0; 221 } 222 223 Node* ComposedShadowTreeWalker::traverseParentBackToShadowRootOrHost(const ShadowRoot* shadowRoot) const 224 { 225 ASSERT(shadowRoot); 226 227 if (canCrossUpperBoundary()) 228 return shadowRoot->hostElement(); 229 230 return const_cast<ShadowRoot*>(shadowRoot); 192 return nullptr; 193 } 194 ContainerNode* parent = node->parentNode(); 195 if (!parent) 196 return nullptr; 197 198 if (parent->isShadowRoot()) 199 return canCrossUpperBoundary() ? toShadowRoot(parent)->hostElement() : parent; 200 201 if (parent->isInsertionPoint()) { 202 const InsertionPoint* insertionPoint = toInsertionPoint(parent); 203 if (insertionPoint->hasDistribution()) 204 return nullptr; 205 if (insertionPoint->isActive()) 206 return traverseParent(parent); 207 } 208 return parent; 231 209 } 232 210 … … 267 245 m_node = n; 268 246 } else 269 parent();247 m_node = traverseParent(m_node); 270 248 assertPostcondition(); 271 249 } -
trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h
r154327 r155264 52 52 53 53 ComposedShadowTreeWalker(const Node*, Policy = CrossUpperBoundary, StartPolicy = CannotStartFromShadowBoundary); 54 55 // For a common use case such as:56 // for (ComposedShadowTreeWalker walker = ComposedShadowTreeWalker::fromFirstChild(node); walker.get(); walker.nextSibling())57 static ComposedShadowTreeWalker fromFirstChild(const Node*, Policy = CrossUpperBoundary);58 54 59 55 Node* get() const { return const_cast<Node*>(m_node); } … … 116 112 static Node* escapeFallbackContentElement(const Node*, TraversalDirection); 117 113 118 Node* traverseNodeEscapingFallbackContents(const Node*) const;119 Node* traverseParentInCurrentTree(const Node*) const;120 Node* traverseParentBackToShadowRootOrHost(const ShadowRoot*) const;121 122 114 const Node* m_node; 123 115 Policy m_policy;
Note:
See TracChangeset
for help on using the changeset viewer.