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

Unified Diff: Source/core/dom/Node.cpp

Issue 642973003: Introduce typed Node/Element iterators for range-based for loops of C++11. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename `from` to `fromNext`. Make some parameters const references. Created 6 years, 2 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/dom/Node.cpp
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index c8485a36b2a426c5234039e26282047a08b551e7..971504ef70b6f112e689dd27031c569032eb9b01 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -1668,7 +1668,7 @@ void Node::showNodePathForThis() const
static void traverseTreeAndMark(const String& baseIndent, const Node* rootNode, const Node* markedNode1, const char* markedLabel1, const Node* markedNode2, const char* markedLabel2)
{
- for (const Node* node = rootNode; node; node = NodeTraversal::next(*node, rootNode)) {
+ for (Node& node : NodeTraversal::inclusiveDescendantsOf(*rootNode)) {
if (node == markedNode1)
fprintf(stderr, "%s", markedLabel1);
if (node == markedNode2)
@@ -1676,26 +1676,26 @@ static void traverseTreeAndMark(const String& baseIndent, const Node* rootNode,
StringBuilder indent;
indent.append(baseIndent);
- for (const Node* tmpNode = node; tmpNode && tmpNode != rootNode; tmpNode = tmpNode->parentOrShadowHostNode())
+ for (const Node* tmpNode = &node; tmpNode && tmpNode != rootNode; tmpNode = tmpNode->parentOrShadowHostNode())
indent.append('\t');
fprintf(stderr, "%s", indent.toString().utf8().data());
- node->showNode();
+ node.showNode();
indent.append('\t');
- if (node->isElementNode()) {
- const Element* element = toElement(node);
- if (Element* pseudo = element->pseudoElement(BEFORE))
+ if (node.isElementNode()) {
+ const Element& element = toElement(node);
+ if (Element* pseudo = element.pseudoElement(BEFORE))
traverseTreeAndMark(indent.toString(), pseudo, markedNode1, markedLabel1, markedNode2, markedLabel2);
- if (Element* pseudo = element->pseudoElement(AFTER))
+ if (Element* pseudo = element.pseudoElement(AFTER))
traverseTreeAndMark(indent.toString(), pseudo, markedNode1, markedLabel1, markedNode2, markedLabel2);
- if (Element* pseudo = element->pseudoElement(BACKDROP))
+ if (Element* pseudo = element.pseudoElement(BACKDROP))
traverseTreeAndMark(indent.toString(), pseudo, markedNode1, markedLabel1, markedNode2, markedLabel2);
}
- if (node->isShadowRoot()) {
- if (ShadowRoot* youngerShadowRoot = toShadowRoot(node)->youngerShadowRoot())
+ if (node.isShadowRoot()) {
+ if (ShadowRoot* youngerShadowRoot = toShadowRoot(node).youngerShadowRoot())
traverseTreeAndMark(indent.toString(), youngerShadowRoot, markedNode1, markedLabel1, markedNode2, markedLabel2);
- } else if (ShadowRoot* oldestShadowRoot = oldestShadowRootFor(node))
+ } else if (ShadowRoot* oldestShadowRoot = oldestShadowRootFor(&node))
traverseTreeAndMark(indent.toString(), oldestShadowRoot, markedNode1, markedLabel1, markedNode2, markedLabel2);
}
}

Powered by Google App Engine
This is Rietveld 408576698