Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2014 Google, Inc. | 5 * Copyright (C) 2014 Google, Inc. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 812 if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr)) | 812 if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr)) |
| 813 view->setZoomAndPan(viewElement->zoomAndPan()); | 813 view->setZoomAndPan(viewElement->zoomAndPan()); |
| 814 else | 814 else |
| 815 view->setZoomAndPan(zoomAndPan()); | 815 view->setZoomAndPan(zoomAndPan()); |
| 816 } | 816 } |
| 817 | 817 |
| 818 // getElementById on SVGSVGElement is restricted to only the child subtree defin ed by the <svg> element. | 818 // getElementById on SVGSVGElement is restricted to only the child subtree defin ed by the <svg> element. |
| 819 // See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement | 819 // See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement |
| 820 Element* SVGSVGElement::getElementById(const AtomicString& id) const | 820 Element* SVGSVGElement::getElementById(const AtomicString& id) const |
| 821 { | 821 { |
| 822 if (!treeScope().containsMultipleElementsWithId(id)) { | 822 Element* element = treeScope().getElementById(id); |
| 823 Element* element = treeScope().getElementById(id); | 823 if (element && element->isDescendantOf(this)) |
| 824 if (!element || !element->isDescendantOf(this)) | 824 return element; |
| 825 return 0; | |
| 826 | 825 |
| 827 return element; | 826 // Fall back to traversing our subtree. Duplicate ids are allowed, the first found will |
| 827 // be returned. | |
| 828 for (Node* node = firstChild(); node; node = NodeTraversal::next(*node, this )) { | |
|
Inactive
2014/03/13 18:11:36
We may want to use ElementTraversal API in a follo
| |
| 829 if (!node->isElementNode()) | |
| 830 continue; | |
| 831 | |
| 832 Element* element = toElement(node); | |
| 833 if (element->getIdAttribute() == id) | |
| 834 return element; | |
| 828 } | 835 } |
| 829 | |
| 830 // If duplicate IDs are there, return the first descendant of the svg elemen t. | |
| 831 const Vector<Element*>& elements = treeScope().getAllElementsById(id); | |
| 832 Vector<Element*>::const_iterator end = elements.end(); | |
| 833 for (Vector<Element*>::const_iterator it = elements.begin(); it != end; ++it ) { | |
| 834 if ((*it)->isDescendantOf(this)) | |
| 835 return *it; | |
| 836 } | |
| 837 | |
| 838 return 0; | 836 return 0; |
| 839 } | 837 } |
| 840 | 838 |
| 841 } | 839 } |
| OLD | NEW |