Chromium Code Reviews| Index: Source/core/svg/SVGSVGElement.cpp |
| diff --git a/Source/core/svg/SVGSVGElement.cpp b/Source/core/svg/SVGSVGElement.cpp |
| index 30cf7fa27e2e365a56436721ca0275a31bc85b6a..07e0befa9b59f09788cf3ea023cf515049ec56c7 100644 |
| --- a/Source/core/svg/SVGSVGElement.cpp |
| +++ b/Source/core/svg/SVGSVGElement.cpp |
| @@ -767,20 +767,20 @@ 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) |
| + if (!treeScope().containsMultipleElementsWithId(id)) { |
| + Element* element = treeScope().getElementById(id); |
| + if (element && element->isDescendantOf(this)) |
| return element; |
| + } else { |
|
Inactive
2014/02/24 22:14:04
you need to return 0 before the else. And then the
|
| + Vector<Element*> elements = treeScope().getAllElementsById(id); |
|
Inactive
2014/02/24 22:14:04
Should be a const Vector<Element*>& to avoid copyi
|
| + Vector<Element*>::iterator end = elements.end(); |
| + for (Vector<Element*>::iterator it = elements.begin(); it != end; ++it) { |
| + Element* element = *it; |
|
Inactive
2014/02/24 22:14:04
You don't really need this assignment, you can use
|
| + if (element->isDescendantOf(this)) |
| + return element; |
| + } |
| } |
| + |
| return 0; |
| } |