Commit 491fa909 authored by ch.dumez@samsung.com's avatar ch.dumez@samsung.com

Use new Traversal<*Element> API in svg code for clarity

Use new Traversal<*Element> API in svg code for clarity. It results in shorter /
simpler code. It also makes it clearer what type of Element we are actually
interested in.

R=
BUG=346733

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

git-svn-id: svn://svn.chromium.org/blink/trunk@169621 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent a31ee25a
...@@ -753,11 +753,9 @@ void SVGElement::collectStyleForPresentationAttribute(const QualifiedName& name, ...@@ -753,11 +753,9 @@ void SVGElement::collectStyleForPresentationAttribute(const QualifiedName& name,
bool SVGElement::haveLoadedRequiredResources() bool SVGElement::haveLoadedRequiredResources()
{ {
Node* child = firstChild(); for (SVGElement* child = Traversal<SVGElement>::firstChild(*this); child; child = Traversal<SVGElement>::nextSibling(*child)) {
while (child) { if (!child->haveLoadedRequiredResources())
if (child->isSVGElement() && !toSVGElement(child)->haveLoadedRequiredResources())
return false; return false;
child = child->nextSibling();
} }
return true; return true;
} }
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "core/css/CSSHelper.h" #include "core/css/CSSHelper.h"
#include "core/dom/Document.h" #include "core/dom/Document.h"
#include "core/dom/ElementTraversal.h" #include "core/dom/ElementTraversal.h"
#include "core/dom/NodeTraversal.h"
#include "core/dom/StaticNodeList.h" #include "core/dom/StaticNodeList.h"
#include "core/editing/FrameSelection.h" #include "core/editing/FrameSelection.h"
#include "core/events/EventListener.h" #include "core/events/EventListener.h"
...@@ -825,11 +824,7 @@ Element* SVGSVGElement::getElementById(const AtomicString& id) const ...@@ -825,11 +824,7 @@ Element* SVGSVGElement::getElementById(const AtomicString& id) const
// Fall back to traversing our subtree. Duplicate ids are allowed, the first found will // Fall back to traversing our subtree. Duplicate ids are allowed, the first found will
// be returned. // be returned.
for (Node* node = firstChild(); node; node = NodeTraversal::next(*node, this)) { for (Element* element = ElementTraversal::firstWithin(*this); element; element = ElementTraversal::next(*element, this)) {
if (!node->isElementNode())
continue;
Element* element = toElement(node);
if (element->getIdAttribute() == id) if (element->getIdAttribute() == id)
return element; return element;
} }
......
...@@ -580,13 +580,9 @@ void SVGUseElement::buildInstanceTree(SVGElement* target, SVGElementInstance* ta ...@@ -580,13 +580,9 @@ void SVGUseElement::buildInstanceTree(SVGElement* target, SVGElementInstance* ta
// is the SVGGElement object for the 'g', and then two child SVGElementInstance objects, each of which has // is the SVGGElement object for the 'g', and then two child SVGElementInstance objects, each of which has
// its correspondingElement that is an SVGRectElement object. // its correspondingElement that is an SVGRectElement object.
for (Node* node = target->firstChild(); node; node = node->nextSibling()) { for (SVGElement* element = Traversal<SVGElement>::firstChild(*target); element; element = Traversal<SVGElement>::nextSibling(*element)) {
SVGElement* element = 0; // Skip any disallowed element.
if (node->isSVGElement()) if (isDisallowedElement(element))
element = toSVGElement(node);
// Skip any non-svg nodes or any disallowed element.
if (!element || isDisallowedElement(element))
continue; continue;
// Create SVGElementInstance object, for both container/non-container nodes. // Create SVGElementInstance object, for both container/non-container nodes.
...@@ -820,17 +816,10 @@ void SVGUseElement::associateInstancesWithShadowTreeElements(Node* target, SVGEl ...@@ -820,17 +816,10 @@ void SVGUseElement::associateInstancesWithShadowTreeElements(Node* target, SVGEl
targetInstance->setShadowTreeElement(element); targetInstance->setShadowTreeElement(element);
element->setCorrespondingElement(originalElement); element->setCorrespondingElement(originalElement);
Node* node = target->firstChild(); SVGElement* child = Traversal<SVGElement>::firstChild(*target);
for (SVGElementInstance* instance = targetInstance->firstChild(); node && instance; instance = instance->nextSibling()) { for (SVGElementInstance* instance = targetInstance->firstChild(); child && instance; instance = instance->nextSibling()) {
// Skip any non-svg elements in shadow tree associateInstancesWithShadowTreeElements(child, instance);
while (node && !node->isSVGElement()) child = Traversal<SVGElement>::nextSibling(*child);
node = node->nextSibling();
if (!node)
break;
associateInstancesWithShadowTreeElements(node, instance);
node = node->nextSibling();
} }
} }
......
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