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

Side by Side Diff: Source/core/svg/SVGSVGElement.cpp

Issue 205983004: Use new Traversal<*Element> API in svg code for clarity (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix typo Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGElement.cpp ('k') | Source/core/svg/SVGUseElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 #include "config.h" 23 #include "config.h"
24 24
25 #include "core/svg/SVGSVGElement.h" 25 #include "core/svg/SVGSVGElement.h"
26 26
27 #include "HTMLNames.h" 27 #include "HTMLNames.h"
28 #include "SVGNames.h" 28 #include "SVGNames.h"
29 #include "bindings/v8/ScriptEventListener.h" 29 #include "bindings/v8/ScriptEventListener.h"
30 #include "core/css/CSSHelper.h" 30 #include "core/css/CSSHelper.h"
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/dom/ElementTraversal.h" 32 #include "core/dom/ElementTraversal.h"
33 #include "core/dom/NodeTraversal.h"
34 #include "core/dom/StaticNodeList.h" 33 #include "core/dom/StaticNodeList.h"
35 #include "core/editing/FrameSelection.h" 34 #include "core/editing/FrameSelection.h"
36 #include "core/events/EventListener.h" 35 #include "core/events/EventListener.h"
37 #include "core/events/ThreadLocalEventNames.h" 36 #include "core/events/ThreadLocalEventNames.h"
38 #include "core/frame/LocalFrame.h" 37 #include "core/frame/LocalFrame.h"
39 #include "core/page/FrameTree.h" 38 #include "core/page/FrameTree.h"
40 #include "core/frame/FrameView.h" 39 #include "core/frame/FrameView.h"
41 #include "core/frame/UseCounter.h" 40 #include "core/frame/UseCounter.h"
42 #include "core/rendering/RenderObject.h" 41 #include "core/rendering/RenderObject.h"
43 #include "core/rendering/RenderPart.h" 42 #include "core/rendering/RenderPart.h"
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 // getElementById on SVGSVGElement is restricted to only the child subtree defin ed by the <svg> element. 817 // 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 818 // See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement
820 Element* SVGSVGElement::getElementById(const AtomicString& id) const 819 Element* SVGSVGElement::getElementById(const AtomicString& id) const
821 { 820 {
822 Element* element = treeScope().getElementById(id); 821 Element* element = treeScope().getElementById(id);
823 if (element && element->isDescendantOf(this)) 822 if (element && element->isDescendantOf(this))
824 return element; 823 return element;
825 824
826 // Fall back to traversing our subtree. Duplicate ids are allowed, the first found will 825 // Fall back to traversing our subtree. Duplicate ids are allowed, the first found will
827 // be returned. 826 // be returned.
828 for (Node* node = firstChild(); node; node = NodeTraversal::next(*node, this )) { 827 for (Element* element = ElementTraversal::firstWithin(*this); element; eleme nt = ElementTraversal::next(*element, this)) {
829 if (!node->isElementNode())
830 continue;
831
832 Element* element = toElement(node);
833 if (element->getIdAttribute() == id) 828 if (element->getIdAttribute() == id)
834 return element; 829 return element;
835 } 830 }
836 return 0; 831 return 0;
837 } 832 }
838 833
839 } 834 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGElement.cpp ('k') | Source/core/svg/SVGUseElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698