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

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

Issue 125503002: We should unify various forms of tree traversal in DOM (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix the comments in TreeNode.h to be more descriptive Created 6 years, 11 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/NodeTraversal.h
diff --git a/Source/core/dom/NodeTraversal.h b/Source/core/dom/NodeTraversal.h
index 438b0c09a29d4cf9f8181ae17ed7c789af8a0926..35f845626a67e9aad54d8d278148dc5edabb82a0 100644
--- a/Source/core/dom/NodeTraversal.h
+++ b/Source/core/dom/NodeTraversal.h
@@ -26,6 +26,7 @@
#define NodeTraversal_h
#include "core/dom/Node.h"
+#include "wtf/TreeNode.h"
namespace WebCore {
@@ -67,53 +68,17 @@ Node* nextIncludingPseudoSkippingChildren(const Node&, const Node* stayWithin =
Node* nextAncestorSibling(const Node&);
Node* nextAncestorSibling(const Node&, const Node* stayWithin);
-template <class NodeType>
-inline Node* traverseNextTemplate(NodeType& 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); }
-
-template <class NodeType>
-inline Node* traverseNextTemplate(NodeType& current, const Node* stayWithin)
-{
- if (current.firstChild())
- return current.firstChild();
- if (current == stayWithin)
- return 0;
- 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); }
-
-template <class NodeType>
-inline Node* traverseNextSkippingChildrenTemplate(NodeType& current)
-{
- if (current.nextSibling())
- return current.nextSibling();
- return nextAncestorSibling(current);
-}
-inline Node* nextSkippingChildren(const Node& current) { return traverseNextSkippingChildrenTemplate(current); }
-inline Node* nextSkippingChildren(const ContainerNode& current) { return traverseNextSkippingChildrenTemplate(current); }
-
-template <class NodeType>
-inline Node* traverseNextSkippingChildrenTemplate(NodeType& current, const Node* stayWithin)
-{
- if (current == stayWithin)
- return 0;
- if (current.nextSibling())
- return current.nextSibling();
- return nextAncestorSibling(current, stayWithin);
-}
-inline Node* nextSkippingChildren(const Node& current, const Node* stayWithin) { return traverseNextSkippingChildrenTemplate(current, stayWithin); }
-inline Node* nextSkippingChildren(const ContainerNode& current, const Node* stayWithin) { return traverseNextSkippingChildrenTemplate(current, stayWithin); }
+inline Node* next(const Node& current) { return traverseNext(current); }
+inline Node* next(const ContainerNode& current) { return traverseNext<Node>(current); }
+
+inline Node* next(const Node& current, const Node* stayWithin) { return traverseNext(current, stayWithin); }
+inline Node* next(const ContainerNode& current, const Node* stayWithin) { return traverseNext<Node>(current, stayWithin); }
+
+inline Node* nextSkippingChildren(const Node& current) { return traverseNextSkippingChildren(current); }
+inline Node* nextSkippingChildren(const ContainerNode& current) { return traverseNextSkippingChildren<Node>(current); }
+
+inline Node* nextSkippingChildren(const Node& current, const Node* stayWithin) { return traverseNextSkippingChildren(current, stayWithin); }
+inline Node* nextSkippingChildren(const ContainerNode& current, const Node* stayWithin) { return traverseNextSkippingChildren<Node>(current, stayWithin); }
}
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/dom/StyleEngine.cpp » ('j') | Source/wtf/TreeNode.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698