Commit 144b78b3 authored by ch.dumez@samsung.com's avatar ch.dumez@samsung.com

Replace nextSiblingChildren() with simpler nextSibling() when equivalent

This makes the code more readable as it makes it clear we are only traversing
children. This is also a bit more efficient as nextSiblingChildren() tries to
traverse the ancestors siblings when done with the current siblings.

R=esprehn, adamk

Review URL: https://codereview.chromium.org/196823006

git-svn-id: svn://svn.chromium.org/blink/trunk@169614 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ae07325b
......@@ -309,17 +309,17 @@ static inline bool nameShouldBeVisibleInDocumentAll(const HTMLElement& element)
inline Element* firstMatchingChildElement(const HTMLCollection& nodeList, const ContainerNode& root)
{
Element* element = ElementTraversal::firstWithin(root);
Element* element = ElementTraversal::firstChild(root);
while (element && !isMatchingElement(nodeList, *element))
element = ElementTraversal::nextSkippingChildren(*element, &root);
element = ElementTraversal::nextSibling(*element);
return element;
}
inline Element* nextMatchingChildElement(const HTMLCollection& nodeList, Element& current, const ContainerNode& root)
inline Element* nextMatchingChildElement(const HTMLCollection& nodeList, Element& current)
{
Element* next = &current;
do {
next = ElementTraversal::nextSkippingChildren(*next, &root);
next = ElementTraversal::nextSibling(*next);
} while (next && !isMatchingElement(nodeList, *next));
return next;
}
......@@ -345,7 +345,7 @@ inline Element* HTMLCollection::traverseNextElement(Element& previous, const Con
if (overridesItemAfter())
return virtualItemAfter(&previous);
if (shouldOnlyIncludeDirectChildren())
return nextMatchingChildElement(*this, previous, root);
return nextMatchingChildElement(*this, previous);
return nextMatchingElement(*this, previous, root);
}
......@@ -368,7 +368,7 @@ Element* HTMLCollection::traverseForwardToOffset(unsigned offset, Element& curre
}
if (shouldOnlyIncludeDirectChildren()) {
Element* next = &currentElement;
while ((next = nextMatchingChildElement(*this, *next, root))) {
while ((next = nextMatchingChildElement(*this, *next))) {
if (++currentOffset == offset)
return next;
}
......
......@@ -440,7 +440,7 @@ bool HTMLObjectElement::containsJavaApplet() const
if (MIMETypeRegistry::isJavaAppletMIMEType(getAttribute(typeAttr)))
return true;
for (HTMLElement* child = Traversal<HTMLElement>::firstWithin(*this); child; child = Traversal<HTMLElement>::nextSkippingChildren(*child, this)) {
for (HTMLElement* child = Traversal<HTMLElement>::firstChild(*this); child; child = Traversal<HTMLElement>::nextSibling(*child)) {
if (isHTMLParamElement(*child)
&& equalIgnoringCase(child->getNameAttribute(), "type")
&& MIMETypeRegistry::isJavaAppletMIMEType(child->getAttribute(valueAttr).string()))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment