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

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

Issue 229213002: Make HTMLCollection / NodeList backward traversal consistent with forward one (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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
Index: Source/core/dom/ChildNodeList.cpp
diff --git a/Source/core/dom/ChildNodeList.cpp b/Source/core/dom/ChildNodeList.cpp
index d87dec6e81c0538a3cf5bb8832274c9f4bb3c633..8c72856e08ece51e5ed21997f0bc876decc3895b 100644
--- a/Source/core/dom/ChildNodeList.cpp
+++ b/Source/core/dom/ChildNodeList.cpp
@@ -44,11 +44,6 @@ ChildNodeList::~ChildNodeList()
m_parent->nodeLists()->removeChildNodeList(this);
}
-Node* ChildNodeList::itemBefore(const Node* previous) const
-{
- return LIKELY(!!previous) ? previous->previousSibling() : rootNode().lastChild();
-}
-
Node* ChildNodeList::traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset) const
{
ASSERT(currentOffset < offset);
@@ -60,4 +55,15 @@ Node* ChildNodeList::traverseForwardToOffset(unsigned offset, Node& currentNode,
return 0;
}
+Node* ChildNodeList::traverseBackwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset) const
+{
+ ASSERT(currentOffset > offset);
+ Node* previous = &currentNode;
+ while ((previous = previous->previousSibling())) {
+ if (--currentOffset == offset)
+ return previous;
+ }
+ return 0;
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698