don't discard iframe children.
[kdelibs.git] / khtml / svg / SVGUseElement.h
blobfd6ab3dd3d1803a8cdbb248397a46eb0f74294a3
1 /*
2 Copyright (C) 2004, 2005, 2006, 2007, 2008 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
26 #if ENABLE(SVG)
27 #include "SVGExternalResourcesRequired.h"
28 #include "SVGLangSpace.h"
29 #include "SVGStyledTransformableElement.h"
30 #include "SVGTests.h"
31 #include "SVGURIReference.h"
33 namespace WebCore {
35 class SVGElementInstance;
36 class SVGLength;
38 class SVGUseElement : public SVGStyledTransformableElement,
39 public SVGTests,
40 public SVGLangSpace,
41 public SVGExternalResourcesRequired,
42 public SVGURIReference {
43 public:
44 SVGUseElement(const QualifiedName&, Document*);
45 virtual ~SVGUseElement();
47 SVGElementInstance* instanceRoot() const;
48 SVGElementInstance* animatedInstanceRoot() const;
50 virtual bool isValid() const { return SVGTests::isValid(); }
52 virtual void insertedIntoDocument();
53 virtual void removedFromDocument();
54 virtual void buildPendingResource();
56 virtual void parseMappedAttribute(MappedAttribute*);
57 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
59 virtual void svgAttributeChanged(const QualifiedName&);
60 virtual void recalcStyle(StyleChange = NoChange);
62 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
63 virtual void attach();
64 virtual void detach();
66 virtual Path toClipPath() const;
68 static void removeDisallowedElementsFromSubtree(Node* element);
70 // KHTML ElementImpl pure virtual method
71 virtual quint32 id() const { return SVGNames::useTag.id(); }
72 virtual DOMString tagName() const { return SVGNames::useTag.tagName(); }
74 protected:
75 virtual const SVGElement* contextElement() const { return this; }
77 private:
78 ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
79 ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
81 ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, X, x)
82 ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Y, y)
83 ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Width, width)
84 ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Height, height)
86 private:
87 friend class SVGElement;
88 SVGElementInstance* instanceForShadowTreeElement(Node* element) const;
90 private:
91 // Instance tree handling
92 void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundCycle);
93 void handleDeepUseReferencing(SVGElement* use, SVGElementInstance* targetInstance, bool& foundCycle);
95 // Shadow tree handling
96 PassRefPtr<SVGSVGElement> buildShadowTreeForSymbolTag(SVGElement* target, SVGElementInstance* targetInstance);
97 void alterShadowTreeForSVGTag(SVGElement* target);
99 void buildShadowTree(SVGElement* target, SVGElementInstance* targetInstance);
101 #if ENABLE(SVG) && ENABLE(SVG_USE)
102 void expandUseElementsInShadowTree(Node* element);
103 void expandSymbolElementsInShadowTree(Node* element);
104 #endif
106 void attachShadowTree();
108 // "Tree connector"
109 void associateInstancesWithShadowTreeElements(Node* target, SVGElementInstance* targetInstance);
111 SVGElementInstance* instanceForShadowTreeElement(Node* element, SVGElementInstance* instance) const;
112 void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const;
114 RefPtr<SVGElement> m_shadowTreeRootElement;
115 RefPtr<SVGElementInstance> m_targetElementInstance;
118 } // namespace WebCore
120 #endif // ENABLE(SVG)
121 #endif