2 Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
23 #ifndef SVGUseElement_h
24 #define SVGUseElement_h
28 #include "SVGExternalResourcesRequired.h"
29 #include "SVGLangSpace.h"
30 #include "SVGStyledTransformableElement.h"
32 #include "SVGURIReference.h"
36 class SVGElementInstance;
39 class SVGUseElement : public SVGStyledTransformableElement,
42 public SVGExternalResourcesRequired,
43 public SVGURIReference
46 SVGUseElement(const QualifiedName&, Document*);
47 virtual ~SVGUseElement();
49 SVGElementInstance* instanceRoot() const;
50 SVGElementInstance* animatedInstanceRoot() const;
52 virtual bool isValid() const { return SVGTests::isValid(); }
54 // Derived from: 'Element'
55 virtual void insertedIntoDocument();
56 virtual void removedFromDocument();
57 virtual void buildPendingResource();
59 // 'SVGUseElement' functions
60 virtual void parseMappedAttribute(MappedAttribute*);
61 virtual void notifyAttributeChange() const;
63 virtual void attributeChanged(Attribute*, bool preserveDecls = false);
64 virtual void recalcStyle(StyleChange = NoChange);
66 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
67 virtual void attach();
68 virtual void detach();
70 virtual Path toClipPath() const;
73 virtual const SVGElement* contextElement() const { return this; }
76 ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
77 ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
79 ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, X, x)
80 ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Y, y)
81 ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Width, width)
82 ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Height, height)
85 friend class SVGElement;
86 SVGElementInstance* instanceForShadowTreeElement(Node* element) const;
89 // Instance tree handling
90 void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundCycle);
91 void handleDeepUseReferencing(SVGElement* use, SVGElementInstance* targetInstance, bool& foundCycle);
93 // Shadow tree handling
94 PassRefPtr<SVGSVGElement> buildShadowTreeForSymbolTag(SVGElement* target, SVGElementInstance* targetInstance);
95 void alterShadowTreeForSVGTag(SVGElement* target);
96 void removeDisallowedElementsFromSubtree(Node* element);
98 void buildShadowTree(SVGElement* target, SVGElementInstance* targetInstance);
99 #if ENABLE(SVG) && ENABLE(SVG_USE)
100 void expandUseElementsInShadowTree(Node* element);
101 void expandSymbolElementsInShadowTree(Node* element);
103 void attachShadowTree();
106 void associateInstancesWithShadowTreeElements(Node* target, SVGElementInstance* targetInstance);
108 SVGElementInstance* instanceForShadowTreeElement(Node* element, SVGElementInstance* instance) const;
109 void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const;
111 RefPtr<SVGElement> m_shadowTreeRootElement;
112 RefPtr<SVGElementInstance> m_targetElementInstance;
115 } // namespace WebCore
117 #endif // ENABLE(SVG)