Index: Source/core/dom/ElementTraversal.h |
diff --git a/Source/core/dom/ElementTraversal.h b/Source/core/dom/ElementTraversal.h |
index 007ab6cf45b3e13213efb37f29e8fd153a3da7f9..2f8ede5aaf8257376e092345d5ad6e83423c571a 100644 |
--- a/Source/core/dom/ElementTraversal.h |
+++ b/Source/core/dom/ElementTraversal.h |
@@ -31,169 +31,154 @@ |
namespace WebCore { |
-template <class ElementType> |
-class Traversal { |
+class ElementTraversal { |
public: |
// First / Last element child of the node. |
- static ElementType* firstWithin(const ContainerNode& current) { return firstElementWithinTemplate(current); } |
- static ElementType* firstWithin(const Node& current) { return firstElementWithinTemplate(current); } |
- static ElementType* lastWithin(const ContainerNode& current) { return lastWithinTemplate(current); } |
- static ElementType* lastWithin(const Node& current) { return lastWithinTemplate(current); } |
+ static Element* firstWithin(const ContainerNode& current) { return firstElementWithinTemplate(current); } |
+ static Element* firstWithin(const Node& current) { return firstElementWithinTemplate(current); } |
+ static Element* lastWithin(const ContainerNode& current) { return lastWithinTemplate(current); } |
+ static Element* lastWithin(const Node& current) { return lastWithinTemplate(current); } |
// Pre-order traversal skipping non-element nodes. |
- static ElementType* next(const ContainerNode& current) { return traverseNextElementTemplate(current); } |
- static ElementType* next(const Node& current) { return traverseNextElementTemplate(current); } |
- static ElementType* next(const ContainerNode& current, const Node* stayWithin) { return traverseNextElementTemplate(current, stayWithin); } |
- static ElementType* next(const Node& current, const Node* stayWithin) { return traverseNextElementTemplate(current, stayWithin); } |
+ static Element* next(const ContainerNode& current) { return traverseNextElementTemplate(current); } |
+ static Element* next(const Node& current) { return traverseNextElementTemplate(current); } |
+ static Element* next(const ContainerNode& current, const Node* stayWithin) { return traverseNextElementTemplate(current, stayWithin); } |
+ static Element* next(const Node& current, const Node* stayWithin) { return traverseNextElementTemplate(current, stayWithin); } |
// Like next, but skips children. |
- static ElementType* nextSkippingChildren(const ContainerNode& current) { return traverseNextElementSkippingChildrenTemplate(current); } |
- static ElementType* nextSkippingChildren(const Node& current) { return traverseNextElementSkippingChildrenTemplate(current); } |
- static ElementType* nextSkippingChildren(const ContainerNode& current, const Node* stayWithin) { return traverseNextElementSkippingChildrenTemplate(current, stayWithin); } |
- static ElementType* nextSkippingChildren(const Node& current, const Node* stayWithin) { return traverseNextElementSkippingChildrenTemplate(current, stayWithin); } |
+ static Element* nextSkippingChildren(const ContainerNode& current) { return traverseNextElementSkippingChildrenTemplate(current); } |
+ static Element* nextSkippingChildren(const Node& current) { return traverseNextElementSkippingChildrenTemplate(current); } |
+ static Element* nextSkippingChildren(const ContainerNode& current, const Node* stayWithin) { return traverseNextElementSkippingChildrenTemplate(current, stayWithin); } |
+ static Element* nextSkippingChildren(const Node& current, const Node* stayWithin) { return traverseNextElementSkippingChildrenTemplate(current, stayWithin); } |
// Pre-order traversal including the pseudo-elements. |
- static ElementType* previousIncludingPseudo(const Node&, const Node* stayWithin = 0); |
- static ElementType* nextIncludingPseudo(const Node&, const Node* stayWithin = 0); |
- static ElementType* nextIncludingPseudoSkippingChildren(const Node&, const Node* stayWithin = 0); |
+ static Element* previousIncludingPseudo(const Node&, const Node* stayWithin = 0); |
+ static Element* nextIncludingPseudo(const Node&, const Node* stayWithin = 0); |
+ static Element* nextIncludingPseudoSkippingChildren(const Node&, const Node* stayWithin = 0); |
// Utility function to traverse only the element and pseudo-element siblings of a node. |
- static ElementType* pseudoAwarePreviousSibling(const Node&); |
+ static Element* pseudoAwarePreviousSibling(const Node&); |
// Previous / Next sibling. |
- static ElementType* previousSibling(const Node&); |
- static ElementType* nextSibling(const Node&); |
+ static Element* previousSibling(const Node&); |
+ static Element* nextSibling(const Node&); |
private: |
template <class NodeType> |
- static ElementType* firstElementWithinTemplate(NodeType&); |
+ static Element* firstElementWithinTemplate(NodeType&); |
template <class NodeType> |
- static ElementType* lastWithinTemplate(NodeType&); |
+ static Element* lastWithinTemplate(NodeType&); |
template <class NodeType> |
- static ElementType* traverseNextElementTemplate(NodeType&); |
+ static Element* traverseNextElementTemplate(NodeType&); |
template <class NodeType> |
- static ElementType* traverseNextElementTemplate(NodeType&, const Node* stayWithin); |
+ static Element* traverseNextElementTemplate(NodeType&, const Node* stayWithin); |
template <class NodeType> |
- static ElementType* traverseNextElementSkippingChildrenTemplate(NodeType&); |
+ static Element* traverseNextElementSkippingChildrenTemplate(NodeType&); |
template <class NodeType> |
- static ElementType* traverseNextElementSkippingChildrenTemplate(NodeType&, const Node* stayWithin); |
+ static Element* traverseNextElementSkippingChildrenTemplate(NodeType&, const Node* stayWithin); |
}; |
-typedef Traversal<Element> ElementTraversal; |
- |
-template <class ElementType> |
template <class NodeType> |
-inline ElementType* Traversal<ElementType>::firstElementWithinTemplate(NodeType& current) |
+inline Element* ElementTraversal::firstElementWithinTemplate(NodeType& current) |
{ |
// Except for the root containers, only elements can have element children. |
Node* node = current.firstChild(); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = node->nextSibling(); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
-template <class ElementType> |
template <class NodeType> |
-inline ElementType* Traversal<ElementType>::lastWithinTemplate(NodeType& current) |
+inline Element* ElementTraversal::lastWithinTemplate(NodeType& current) |
{ |
Node* node = current.lastChild(); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = node->previousSibling(); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
-template <class ElementType> |
template <class NodeType> |
-inline ElementType* Traversal<ElementType>::traverseNextElementTemplate(NodeType& current) |
+inline Element* ElementTraversal::traverseNextElementTemplate(NodeType& current) |
{ |
Node* node = NodeTraversal::next(current); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = NodeTraversal::nextSkippingChildren(*node); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
-template <class ElementType> |
template <class NodeType> |
-inline ElementType* Traversal<ElementType>::traverseNextElementTemplate(NodeType& current, const Node* stayWithin) |
+inline Element* ElementTraversal::traverseNextElementTemplate(NodeType& current, const Node* stayWithin) |
{ |
Node* node = NodeTraversal::next(current, stayWithin); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = NodeTraversal::nextSkippingChildren(*node, stayWithin); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
-template <class ElementType> |
template <class NodeType> |
-inline ElementType* Traversal<ElementType>::traverseNextElementSkippingChildrenTemplate(NodeType& current) |
+inline Element* ElementTraversal::traverseNextElementSkippingChildrenTemplate(NodeType& current) |
{ |
Node* node = NodeTraversal::nextSkippingChildren(current); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = NodeTraversal::nextSkippingChildren(*node); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
-template <class ElementType> |
template <class NodeType> |
-inline ElementType* Traversal<ElementType>::traverseNextElementSkippingChildrenTemplate(NodeType& current, const Node* stayWithin) |
+inline Element* ElementTraversal::traverseNextElementSkippingChildrenTemplate(NodeType& current, const Node* stayWithin) |
{ |
Node* node = NodeTraversal::nextSkippingChildren(current, stayWithin); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = NodeTraversal::nextSkippingChildren(*node, stayWithin); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
-template <class ElementType> |
-inline ElementType* Traversal<ElementType>::previousIncludingPseudo(const Node& current, const Node* stayWithin) |
+inline Element* ElementTraversal::previousIncludingPseudo(const Node& current, const Node* stayWithin) |
{ |
Node* node = NodeTraversal::previousIncludingPseudo(current, stayWithin); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = NodeTraversal::previousIncludingPseudo(*node, stayWithin); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
-template <class ElementType> |
-inline ElementType* Traversal<ElementType>::nextIncludingPseudo(const Node& current, const Node* stayWithin) |
+inline Element* ElementTraversal::nextIncludingPseudo(const Node& current, const Node* stayWithin) |
{ |
Node* node = NodeTraversal::nextIncludingPseudo(current, stayWithin); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = NodeTraversal::nextIncludingPseudo(*node, stayWithin); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
-template <class ElementType> |
-inline ElementType* Traversal<ElementType>::nextIncludingPseudoSkippingChildren(const Node& current, const Node* stayWithin) |
+inline Element* ElementTraversal::nextIncludingPseudoSkippingChildren(const Node& current, const Node* stayWithin) |
{ |
Node* node = NodeTraversal::nextIncludingPseudoSkippingChildren(current, stayWithin); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = NodeTraversal::nextIncludingPseudoSkippingChildren(*node, stayWithin); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
-template <class ElementType> |
-inline ElementType* Traversal<ElementType>::pseudoAwarePreviousSibling(const Node& current) |
+inline Element* ElementTraversal::pseudoAwarePreviousSibling(const Node& current) |
{ |
Node* node = current.pseudoAwarePreviousSibling(); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = node->pseudoAwarePreviousSibling(); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
-template <class ElementType> |
-inline ElementType* Traversal<ElementType>::previousSibling(const Node& current) |
+inline Element* ElementTraversal::previousSibling(const Node& current) |
{ |
Node* node = current.previousSibling(); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = node->previousSibling(); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
-template <class ElementType> |
-inline ElementType* Traversal<ElementType>::nextSibling(const Node& current) |
+inline Element* ElementTraversal::nextSibling(const Node& current) |
{ |
Node* node = current.nextSibling(); |
- while (node && !isElementOfType<ElementType>(*node)) |
+ while (node && !node->isElementNode()) |
node = node->nextSibling(); |
- return toElement<ElementType>(node); |
+ return toElement(node); |
} |
} // namespace WebCore |