Chromium Code Reviews| Index: Source/core/dom/LiveNodeList.cpp |
| diff --git a/Source/core/dom/LiveNodeList.cpp b/Source/core/dom/LiveNodeList.cpp |
| index b437e68908ef5f953b87c4a67035faba2adf0f00..99325b7db392c5befaacc88344aa5c397afa5f5b 100644 |
| --- a/Source/core/dom/LiveNodeList.cpp |
| +++ b/Source/core/dom/LiveNodeList.cpp |
| @@ -25,10 +25,20 @@ |
| namespace blink { |
| -static inline bool isMatchingElement(const LiveNodeList& nodeList, const Element& element) |
| -{ |
| - return nodeList.elementMatches(element); |
| -} |
| +class IsMatch { |
| +public: |
| + IsMatch(const LiveNodeList& list) |
| + : m_list(list) |
| + { } |
| + |
| + bool operator() (Element& element) const |
|
rwlbuis
2014/08/13 15:10:03
Should this be const?
Inactive
2014/08/13 15:11:28
Done.
|
| + { |
| + return m_list.elementMatches(element); |
| + } |
| + |
| +private: |
| + const LiveNodeList& m_list; |
| +}; |
| Node* LiveNodeList::virtualOwnerNode() const |
| { |
| @@ -52,22 +62,22 @@ Element* LiveNodeList::item(unsigned offset) const |
| Element* LiveNodeList::traverseToFirstElement() const |
| { |
| - return firstMatchingElement(*this); |
| + return ElementTraversal::firstWithin(rootNode(), IsMatch(*this)); |
| } |
| Element* LiveNodeList::traverseToLastElement() const |
| { |
| - return lastMatchingElement(*this); |
| + return ElementTraversal::lastWithin(rootNode(), IsMatch(*this)); |
| } |
| -Element* LiveNodeList::traverseForwardToOffset(unsigned offset, Element& currentNode, unsigned& currentOffset) const |
| +Element* LiveNodeList::traverseForwardToOffset(unsigned offset, Element& currentElement, unsigned& currentOffset) const |
| { |
| - return traverseMatchingElementsForwardToOffset(*this, offset, currentNode, currentOffset); |
| + return traverseMatchingElementsForwardToOffset(currentElement, &rootNode(), offset, currentOffset, IsMatch(*this)); |
| } |
| -Element* LiveNodeList::traverseBackwardToOffset(unsigned offset, Element& currentNode, unsigned& currentOffset) const |
| +Element* LiveNodeList::traverseBackwardToOffset(unsigned offset, Element& currentElement, unsigned& currentOffset) const |
| { |
| - return traverseMatchingElementsBackwardToOffset(*this, offset, currentNode, currentOffset); |
| + return traverseMatchingElementsBackwardToOffset(currentElement, &rootNode(), offset, currentOffset, IsMatch(*this)); |
| } |
| void LiveNodeList::trace(Visitor* visitor) |