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

Unified Diff: Source/core/html/HTMLCollection.cpp

Issue 180383002: Move LiveNodeListBase code out of HTMLCollection.cpp (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 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/LiveNodeListBase.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLCollection.cpp
diff --git a/Source/core/html/HTMLCollection.cpp b/Source/core/html/HTMLCollection.cpp
index e332fb713f793001ef54618e889b50650074d7be..fd13bbcbd93480251bc0386975bc650f8fa881b0 100644
--- a/Source/core/html/HTMLCollection.cpp
+++ b/Source/core/html/HTMLCollection.cpp
@@ -284,48 +284,6 @@ template <> inline bool isMatchingElement(const LiveNodeList& nodeList, const El
return nodeList.nodeMatches(element);
}
-static Node* previousNode(const ContainerNode& base, const Node& previous, bool onlyIncludeDirectChildren)
-{
- return onlyIncludeDirectChildren ? previous.previousSibling() : NodeTraversal::previous(previous, &base);
-}
-
-static inline Node* lastDescendant(const ContainerNode& node)
-{
- Node* descendant = node.lastChild();
- for (Node* current = descendant; current; current = current->lastChild())
- descendant = current;
- return descendant;
-}
-
-static Node* lastNode(const ContainerNode& rootNode, bool onlyIncludeDirectChildren)
-{
- return onlyIncludeDirectChildren ? rootNode.lastChild() : lastDescendant(rootNode);
-}
-
-template <typename Collection>
-ALWAYS_INLINE Element* LiveNodeListBase::iterateForPreviousNode(const Collection& collection, Node* current)
-{
- bool onlyIncludeDirectChildren = collection.shouldOnlyIncludeDirectChildren();
- ContainerNode& rootNode = collection.rootNode();
- for (; current; current = previousNode(rootNode, *current, onlyIncludeDirectChildren)) {
- if (current->isElementNode() && isMatchingElement(collection, toElement(*current)))
- return toElement(current);
- }
- return 0;
-}
-
-template <typename Collection>
-Element* LiveNodeListBase::itemBefore(const Collection& collection, const Element* previous)
-{
- Node* current;
- if (LIKELY(!!previous)) // Without this LIKELY, length() and item() can be 10% slower.
- current = previousNode(collection.rootNode(), *previous, collection.shouldOnlyIncludeDirectChildren());
- else
- current = lastNode(collection.rootNode(), collection.shouldOnlyIncludeDirectChildren());
-
- return iterateForPreviousNode(collection, current);
-}
-
Element* LiveNodeList::itemBefore(const Element* previous) const
{
return LiveNodeListBase::itemBefore(*this, previous);
« no previous file with comments | « Source/core/dom/LiveNodeListBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698