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

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

Issue 29873003: Have LiveNodeList::rootNode() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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/LiveNodeList.cpp ('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 f891743f786f5c612f8b78e239b3f4548c976708..a6faa8660ea52e106b8731df266c309be3f248c6 100644
--- a/Source/core/html/HTMLCollection.cpp
+++ b/Source/core/html/HTMLCollection.cpp
@@ -253,30 +253,30 @@ template <> inline bool isMatchingElement(const ClassNodeList* nodeList, Element
return nodeList->nodeMatchesInlined(element);
}
-static Node* previousNode(Node* base, Node* previous, bool onlyIncludeDirectChildren)
+static Node* previousNode(Node& base, Node& previous, bool onlyIncludeDirectChildren)
{
- return onlyIncludeDirectChildren ? previous->previousSibling() : NodeTraversal::previous(previous, base);
+ return onlyIncludeDirectChildren ? previous.previousSibling() : NodeTraversal::previous(&previous, &base);
}
-static inline Node* lastDescendent(Node* node)
+static inline Node* lastDescendent(Node& node)
{
- node = node->lastChild();
- for (Node* current = node; current; current = current->lastChild())
- node = current;
- return node;
+ Node* descendent = node.lastChild();
+ for (Node* current = descendent; current; current = current->lastChild())
+ descendent = current;
+ return descendent;
}
-static Node* lastNode(Node* rootNode, bool onlyIncludeDirectChildren)
+static Node* lastNode(Node& rootNode, bool onlyIncludeDirectChildren)
{
- return onlyIncludeDirectChildren ? rootNode->lastChild() : lastDescendent(rootNode);
+ return onlyIncludeDirectChildren ? rootNode.lastChild() : lastDescendent(rootNode);
}
ALWAYS_INLINE Node* LiveNodeListBase::iterateForPreviousNode(Node* current) const
{
bool onlyIncludeDirectChildren = shouldOnlyIncludeDirectChildren();
CollectionType collectionType = type();
- Node* rootNode = this->rootNode();
- for (; current; current = previousNode(rootNode, current, onlyIncludeDirectChildren)) {
+ Node& rootNode = this->rootNode();
+ for (; current; current = previousNode(rootNode, *current, onlyIncludeDirectChildren)) {
if (isNodeList(collectionType)) {
if (current->isElementNode() && isMatchingElement(static_cast<const LiveNodeList*>(this), toElement(current)))
return toElement(current);
@@ -292,7 +292,7 @@ ALWAYS_INLINE Node* LiveNodeListBase::itemBefore(Node* previous) const
{
Node* current;
if (LIKELY(!!previous)) // Without this LIKELY, length() and item() can be 10% slower.
- current = previousNode(rootNode(), previous, shouldOnlyIncludeDirectChildren());
+ current = previousNode(rootNode(), *previous, shouldOnlyIncludeDirectChildren());
else
current = lastNode(rootNode(), shouldOnlyIncludeDirectChildren());
« no previous file with comments | « Source/core/dom/LiveNodeList.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698