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

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

Issue 68173014: Have ElementTraversal::firstWithin() take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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/html/HTMLCollection.h ('k') | Source/core/html/HTMLFieldSetElement.h » ('j') | 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 ff4ce6c0ce60f4936b631b27efffd2bef75d3f56..a0edbbc2f208a1b2285f96ac7171948e3dc2f838 100644
--- a/Source/core/html/HTMLCollection.cpp
+++ b/Source/core/html/HTMLCollection.cpp
@@ -302,11 +302,11 @@ ALWAYS_INLINE Node* LiveNodeListBase::itemBefore(Node* previous) const
}
template <class NodeListType>
-inline Element* firstMatchingElement(const NodeListType* nodeList, ContainerNode* root)
+inline Element* firstMatchingElement(const NodeListType* nodeList, ContainerNode& root)
{
Element* element = ElementTraversal::firstWithin(root);
while (element && !isMatchingElement(nodeList, element))
- element = ElementTraversal::next(*element, root);
+ element = ElementTraversal::next(*element, &root);
return element;
}
@@ -345,7 +345,7 @@ inline Node* LiveNodeListBase::traverseChildNodeListForwardToOffset(unsigned off
}
// FIXME: This should be in LiveNodeList
-inline Element* LiveNodeListBase::traverseLiveNodeListFirstElement(ContainerNode* root) const
+inline Element* LiveNodeListBase::traverseLiveNodeListFirstElement(ContainerNode& root) const
{
ASSERT(isNodeList(type()));
ASSERT(type() != ChildNodeListType);
@@ -435,9 +435,9 @@ Node* LiveNodeListBase::item(unsigned offset) const
if (type() == ChildNodeListType)
firstItem = root->firstChild();
else if (isNodeList(type()))
- firstItem = traverseLiveNodeListFirstElement(root);
+ firstItem = traverseLiveNodeListFirstElement(*root);
else
- firstItem = static_cast<const HTMLCollection*>(this)->traverseFirstElement(offsetInArray, root);
+ firstItem = static_cast<const HTMLCollection*>(this)->traverseFirstElement(offsetInArray, *root);
if (!firstItem) {
setLengthCache(0);
@@ -525,11 +525,11 @@ bool HTMLCollection::checkForNameMatch(Element* element, bool checkName, const A
return e->getNameAttribute() == name && e->getIdAttribute() != name;
}
-inline Element* firstMatchingChildElement(const HTMLCollection* nodeList, ContainerNode* root)
+inline Element* firstMatchingChildElement(const HTMLCollection* nodeList, ContainerNode& root)
{
Element* element = ElementTraversal::firstWithin(root);
while (element && !isMatchingElement(nodeList, element))
- element = ElementTraversal::nextSkippingChildren(*element, root);
+ element = ElementTraversal::nextSkippingChildren(*element, &root);
return element;
}
@@ -542,7 +542,7 @@ inline Element* nextMatchingChildElement(const HTMLCollection* nodeList, Element
return next;
}
-inline Element* HTMLCollection::traverseFirstElement(unsigned& offsetInArray, ContainerNode* root) const
+inline Element* HTMLCollection::traverseFirstElement(unsigned& offsetInArray, ContainerNode& root) const
{
if (overridesItemAfter())
return virtualItemAfter(offsetInArray, 0);
@@ -599,7 +599,7 @@ Node* HTMLCollection::namedItem(const AtomicString& name) const
unsigned arrayOffset = 0;
unsigned i = 0;
- for (Element* element = traverseFirstElement(arrayOffset, root); element; element = traverseNextElement(arrayOffset, *element, root)) {
+ for (Element* element = traverseFirstElement(arrayOffset, *root); element; element = traverseNextElement(arrayOffset, *element, root)) {
if (checkForNameMatch(element, /* checkName */ false, name)) {
setItemCache(element, i, arrayOffset);
return element;
@@ -608,7 +608,7 @@ Node* HTMLCollection::namedItem(const AtomicString& name) const
}
i = 0;
- for (Element* element = traverseFirstElement(arrayOffset, root); element; element = traverseNextElement(arrayOffset, *element, root)) {
+ for (Element* element = traverseFirstElement(arrayOffset, *root); element; element = traverseNextElement(arrayOffset, *element, root)) {
if (checkForNameMatch(element, /* checkName */ true, name)) {
setItemCache(element, i, arrayOffset);
return element;
@@ -629,7 +629,7 @@ void HTMLCollection::updateNameCache() const
return;
unsigned arrayOffset = 0;
- for (Element* element = traverseFirstElement(arrayOffset, root); element; element = traverseNextElement(arrayOffset, *element, root)) {
+ for (Element* element = traverseFirstElement(arrayOffset, *root); element; element = traverseNextElement(arrayOffset, *element, root)) {
const AtomicString& idAttrVal = element->getIdAttribute();
if (!idAttrVal.isEmpty())
appendIdCache(idAttrVal, element);
« no previous file with comments | « Source/core/html/HTMLCollection.h ('k') | Source/core/html/HTMLFieldSetElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698