Index: Source/core/dom/ElementTraversal.h |
diff --git a/Source/core/dom/ElementTraversal.h b/Source/core/dom/ElementTraversal.h |
index c5a39068ce5c6abc6801fbee57fdc919c7cd1865..3d24b383ad877ab32524b92c96a2615be8e11081 100644 |
--- a/Source/core/dom/ElementTraversal.h |
+++ b/Source/core/dom/ElementTraversal.h |
@@ -34,6 +34,7 @@ namespace blink { |
template <class ElementType> |
class Traversal { |
public: |
+ using TraversalNodeType = ElementType; |
// First or last ElementType child of the node. |
static ElementType* firstChild(const ContainerNode& current) { return firstChildTemplate(current); } |
static ElementType* firstChild(const Node& current) { return firstChildTemplate(current); } |
@@ -94,6 +95,11 @@ public: |
template <class MatchFunc> |
static ElementType* nextSibling(const Node&, MatchFunc); |
+ static TraversalRange<TraversalChildrenIterator<Traversal<ElementType>>> childrenOf(const Node&); |
+ static TraversalRange<TraversalDescendantIterator<Traversal<ElementType>>> descendantsOf(const Node&); |
+ static TraversalRange<TraversalInclusiveDescendantIterator<Traversal<ElementType>>> inclusiveDescendantsOf(const ElementType&); |
+ static TraversalRange<TraversalNextIterator<Traversal<ElementType>>> fromNext(const Node&); |
+ |
private: |
template <class NodeType> |
static ElementType* firstChildTemplate(NodeType&); |
@@ -113,6 +119,30 @@ private: |
typedef Traversal<Element> ElementTraversal; |
+template <class ElementType> |
+inline TraversalRange<TraversalChildrenIterator<Traversal<ElementType>>> Traversal<ElementType>::childrenOf(const Node& start) |
+{ |
+ return TraversalRange<TraversalChildrenIterator<Traversal<ElementType>>>(start); |
+}; |
+ |
+template <class ElementType> |
+inline TraversalRange<TraversalDescendantIterator<Traversal<ElementType>>> Traversal<ElementType>::descendantsOf(const Node& root) |
+{ |
+ return TraversalRange<TraversalDescendantIterator<Traversal<ElementType>>>(root); |
+}; |
+ |
+template <class ElementType> |
+inline TraversalRange<TraversalInclusiveDescendantIterator<Traversal<ElementType>>> Traversal<ElementType>::inclusiveDescendantsOf(const ElementType& root) |
+{ |
+ return TraversalRange<TraversalInclusiveDescendantIterator<Traversal<ElementType>>>(root); |
+}; |
+ |
+template <class ElementType> |
+inline TraversalRange<TraversalNextIterator<Traversal<ElementType>>> Traversal<ElementType>::fromNext(const Node& start) |
dglazkov
2014/10/21 16:03:11
This name had stumped me a little bit. What does i
hayato
2014/10/22 05:15:18
NodeTraversal::startsFromNext might be better?
An
|
+{ |
+ return TraversalRange<TraversalNextIterator<Traversal<ElementType>>>(start); |
+}; |
+ |
// Specialized for pure Element to exploit the fact that Elements parent is always either another Element or the root. |
template <> |
template <class NodeType> |