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

Unified Diff: Source/core/dom/NodeTraversal.h

Issue 67473002: Have ElementTraversal / NodeTraversal's next() methods take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master Created 7 years, 1 month 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/dom/NodeIterator.cpp ('k') | Source/core/dom/Range.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/NodeTraversal.h
diff --git a/Source/core/dom/NodeTraversal.h b/Source/core/dom/NodeTraversal.h
index c6966a61b9befdc1ec75ba118441017117afd549..d428e8f80f564d1a4c4faf619e142618b490ef3e 100644
--- a/Source/core/dom/NodeTraversal.h
+++ b/Source/core/dom/NodeTraversal.h
@@ -35,10 +35,10 @@ namespace NodeTraversal {
// This uses the same order that tags appear in the source file. If the stayWithin
// argument is non-null, the traversal will stop once the specified node is reached.
// This can be used to restrict traversal to a particular sub-tree.
-Node* next(const Node*);
-Node* next(const Node*, const Node* stayWithin);
-Node* next(const ContainerNode*);
-Node* next(const ContainerNode*, const Node* stayWithin);
+Node* next(const Node&);
+Node* next(const Node&, const Node* stayWithin);
+Node* next(const ContainerNode&);
+Node* next(const ContainerNode&, const Node* stayWithin);
// Like next, but skips children and starts with the next sibling.
Node* nextSkippingChildren(const Node*);
@@ -68,30 +68,30 @@ Node* nextAncestorSibling(const Node*);
Node* nextAncestorSibling(const Node*, const Node* stayWithin);
template <class NodeType>
-inline Node* traverseNextTemplate(NodeType* current)
+inline Node* traverseNextTemplate(NodeType& current)
{
- if (current->firstChild())
- return current->firstChild();
- if (current->nextSibling())
- return current->nextSibling();
- return nextAncestorSibling(current);
+ if (current.firstChild())
+ return current.firstChild();
+ if (current.nextSibling())
+ return current.nextSibling();
+ return nextAncestorSibling(&current);
}
-inline Node* next(const Node* current) { return traverseNextTemplate(current); }
-inline Node* next(const ContainerNode* current) { return traverseNextTemplate(current); }
+inline Node* next(const Node& current) { return traverseNextTemplate(current); }
+inline Node* next(const ContainerNode& current) { return traverseNextTemplate(current); }
template <class NodeType>
-inline Node* traverseNextTemplate(NodeType* current, const Node* stayWithin)
+inline Node* traverseNextTemplate(NodeType& current, const Node* stayWithin)
{
- if (current->firstChild())
- return current->firstChild();
+ if (current.firstChild())
+ return current.firstChild();
if (current == stayWithin)
return 0;
- if (current->nextSibling())
- return current->nextSibling();
- return nextAncestorSibling(current, stayWithin);
+ if (current.nextSibling())
+ return current.nextSibling();
+ return nextAncestorSibling(&current, stayWithin);
}
-inline Node* next(const Node* current, const Node* stayWithin) { return traverseNextTemplate(current, stayWithin); }
-inline Node* next(const ContainerNode* current, const Node* stayWithin) { return traverseNextTemplate(current, stayWithin); }
+inline Node* next(const Node& current, const Node* stayWithin) { return traverseNextTemplate(current, stayWithin); }
+inline Node* next(const ContainerNode& current, const Node* stayWithin) { return traverseNextTemplate(current, stayWithin); }
template <class NodeType>
inline Node* traverseNextSkippingChildrenTemplate(NodeType* current)
« no previous file with comments | « Source/core/dom/NodeIterator.cpp ('k') | Source/core/dom/Range.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698