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

Unified Diff: Source/core/svg/SVGSVGElement.cpp

Issue 178323002: Simply SVGSVGElement::getElementById method (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGSVGElement.cpp
diff --git a/Source/core/svg/SVGSVGElement.cpp b/Source/core/svg/SVGSVGElement.cpp
index 30cf7fa27e2e365a56436721ca0275a31bc85b6a..9d701fc76d015771c73f01323e514c0bc8cc333f 100644
--- a/Source/core/svg/SVGSVGElement.cpp
+++ b/Source/core/svg/SVGSVGElement.cpp
@@ -767,20 +767,14 @@ void SVGSVGElement::inheritViewAttributes(SVGViewElement* viewElement)
// See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement
Element* SVGSVGElement::getElementById(const AtomicString& id) const
{
- Element* element = treeScope().getElementById(id);
- if (element && element->isDescendantOf(this))
- return element;
-
- // Fall back to traversing our subtree. Duplicate ids are allowed, the first found will
- // be returned.
- for (Node* node = firstChild(); node; node = NodeTraversal::next(*node, this)) {
- if (!node->isElementNode())
- continue;
-
- Element* element = toElement(node);
- if (element->getIdAttribute() == id)
+ Vector<Element*> elements = treeScope().getAllElementsById(id);
Inactive 2014/02/24 20:12:42 This may cause a performance regression in the non
+
+ for (Vector<Element*>::iterator it = elements.begin(); it != elements.end(); ++it) {
pdr. 2014/02/24 18:39:43 I'm not sure how much it matters here, but I typic
+ Element* element = *it;
+ if (element->isDescendantOf(this))
return element;
}
+
return 0;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698