Index: Source/core/dom/LiveNodeListBase.h |
diff --git a/Source/core/dom/LiveNodeListBase.h b/Source/core/dom/LiveNodeListBase.h |
index 7d2a56fc3f37a5c6291bf19bb29fcb68181a9dd9..3daef7952d2bd125c71302b85aafabdbe556062b 100644 |
--- a/Source/core/dom/LiveNodeListBase.h |
+++ b/Source/core/dom/LiveNodeListBase.h |
@@ -79,18 +79,10 @@ protected: |
ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeListRootType>(m_rootType); } |
- template <class NodeListType> |
- static Element* firstMatchingElement(const NodeListType&); |
- template <class NodeListType> |
- static Element* lastMatchingElement(const NodeListType&); |
- template <class NodeListType> |
- static Element* nextMatchingElement(const NodeListType&, Element& current); |
- template <class NodeListType> |
- static Element* previousMatchingElement(const NodeListType&, Element& current); |
- template <class NodeListType> |
- static Element* traverseMatchingElementsForwardToOffset(const NodeListType&, unsigned offset, Element& currentElement, unsigned& currentOffset); |
- template <class NodeListType> |
- static Element* traverseMatchingElementsBackwardToOffset(const NodeListType&, unsigned offset, Element& currentElement, unsigned& currentOffset); |
+ template <typename MatchFunc> |
+ static Element* traverseMatchingElementsForwardToOffset(Element& currentElement, const ContainerNode* stayWithin, unsigned offset, unsigned& currentOffset, MatchFunc); |
+ template <typename MatchFunc> |
+ static Element* traverseMatchingElementsBackwardToOffset(Element& currentElement, const ContainerNode* stayWithin, unsigned offset, unsigned& currentOffset, MatchFunc); |
virtual void trace(Visitor* visitor) { visitor->trace(m_ownerNode); } |
@@ -125,64 +117,22 @@ ALWAYS_INLINE bool LiveNodeListBase::shouldInvalidateTypeOnAttributeChange(NodeL |
return false; |
} |
-template <typename NodeListType> |
-Element* LiveNodeListBase::lastMatchingElement(const NodeListType& nodeList) |
-{ |
- ContainerNode& root = nodeList.rootNode(); |
- Element* element = ElementTraversal::lastWithin(root); |
- while (element && !isMatchingElement(nodeList, *element)) |
- element = ElementTraversal::previous(*element, &root); |
- return element; |
-} |
- |
-template <class NodeListType> |
-Element* LiveNodeListBase::firstMatchingElement(const NodeListType& nodeList) |
-{ |
- ContainerNode& root = nodeList.rootNode(); |
- Element* element = ElementTraversal::firstWithin(root); |
- while (element && !isMatchingElement(nodeList, *element)) |
- element = ElementTraversal::next(*element, &root); |
- return element; |
-} |
- |
-template <class NodeListType> |
-Element* LiveNodeListBase::nextMatchingElement(const NodeListType& nodeList, Element& current) |
-{ |
- ContainerNode& root = nodeList.rootNode(); |
- Element* next = ¤t; |
- do { |
- next = ElementTraversal::next(*next, &root); |
- } while (next && !isMatchingElement(nodeList, *next)); |
- return next; |
-} |
- |
-template <class NodeListType> |
-Element* LiveNodeListBase::previousMatchingElement(const NodeListType& nodeList, Element& current) |
-{ |
- ContainerNode& root = nodeList.rootNode(); |
- Element* previous = ¤t; |
- do { |
- previous = ElementTraversal::previous(*previous, &root); |
- } while (previous && !isMatchingElement(nodeList, *previous)); |
- return previous; |
-} |
- |
-template <class NodeListType> |
-Element* LiveNodeListBase::traverseMatchingElementsForwardToOffset(const NodeListType& nodeList, unsigned offset, Element& currentElement, unsigned& currentOffset) |
+template <typename MatchFunc> |
+Element* LiveNodeListBase::traverseMatchingElementsForwardToOffset(Element& currentElement, const ContainerNode* stayWithin, unsigned offset, unsigned& currentOffset, MatchFunc isMatch) |
{ |
ASSERT(currentOffset < offset); |
- for (Element* next = nextMatchingElement(nodeList, currentElement); next; next = nextMatchingElement(nodeList, *next)) { |
+ for (Element* next = ElementTraversal::next(currentElement, stayWithin, isMatch); next; next = ElementTraversal::next(*next, stayWithin, isMatch)) { |
if (++currentOffset == offset) |
return next; |
} |
return 0; |
} |
-template <class NodeListType> |
-Element* LiveNodeListBase::traverseMatchingElementsBackwardToOffset(const NodeListType& nodeList, unsigned offset, Element& currentElement, unsigned& currentOffset) |
+template <typename MatchFunc> |
+Element* LiveNodeListBase::traverseMatchingElementsBackwardToOffset(Element& currentElement, const ContainerNode* stayWithin, unsigned offset, unsigned& currentOffset, MatchFunc isMatch) |
{ |
ASSERT(currentOffset > offset); |
- for (Element* previous = previousMatchingElement(nodeList, currentElement); previous; previous = previousMatchingElement(nodeList, *previous)) { |
+ for (Element* previous = ElementTraversal::previous(currentElement, stayWithin, isMatch); previous; previous = ElementTraversal::previous(*previous, stayWithin, isMatch)) { |
if (--currentOffset == offset) |
return previous; |
} |