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

Unified Diff: Source/core/dom/LiveNodeList.cpp

Issue 468183002: Move matching Element traversal functions from LiveNodeListBase to ElementTraversal (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use anonymous namespace Created 6 years, 4 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
« no previous file with comments | « Source/core/dom/ElementTraversal.h ('k') | Source/core/dom/LiveNodeListBase.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/LiveNodeList.cpp
diff --git a/Source/core/dom/LiveNodeList.cpp b/Source/core/dom/LiveNodeList.cpp
index b437e68908ef5f953b87c4a67035faba2adf0f00..94f300eb63a5da533d7edd5a9fae1fa08cc299bb 100644
--- a/Source/core/dom/LiveNodeList.cpp
+++ b/Source/core/dom/LiveNodeList.cpp
@@ -25,10 +25,24 @@
namespace blink {
-static inline bool isMatchingElement(const LiveNodeList& nodeList, const Element& element)
-{
- return nodeList.elementMatches(element);
-}
+namespace {
+
+class IsMatch {
+public:
+ IsMatch(const LiveNodeList& list)
+ : m_list(list)
+ { }
+
+ bool operator() (const Element& element) const
+ {
+ return m_list.elementMatches(element);
+ }
+
+private:
+ const LiveNodeList& m_list;
+};
+
+} // namespace
Node* LiveNodeList::virtualOwnerNode() const
{
@@ -52,22 +66,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)
« no previous file with comments | « Source/core/dom/ElementTraversal.h ('k') | Source/core/dom/LiveNodeListBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698