|
1 /* |
|
2 Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
|
3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
|
4 |
|
5 This library is free software; you can redistribute it and/or |
|
6 modify it under the terms of the GNU Library General Public |
|
7 License as published by the Free Software Foundation; either |
|
8 version 2 of the License, or (at your option) any later version. |
|
9 |
|
10 This library is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 Library General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU Library General Public License |
|
16 along with this library; see the file COPYING.LIB. If not, write to |
|
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
18 Boston, MA 02110-1301, USA. |
|
19 */ |
|
20 |
|
21 #ifndef SVGUseElement_h |
|
22 #define SVGUseElement_h |
|
23 |
|
24 #if ENABLE(SVG) |
|
25 #include "SVGExternalResourcesRequired.h" |
|
26 #include "SVGLangSpace.h" |
|
27 #include "SVGStyledTransformableElement.h" |
|
28 #include "SVGTests.h" |
|
29 #include "SVGURIReference.h" |
|
30 |
|
31 namespace WebCore { |
|
32 |
|
33 class SVGElementInstance; |
|
34 class SVGLength; |
|
35 class SVGShadowTreeRootElement; |
|
36 |
|
37 class SVGUseElement : public SVGStyledTransformableElement, |
|
38 public SVGTests, |
|
39 public SVGLangSpace, |
|
40 public SVGExternalResourcesRequired, |
|
41 public SVGURIReference { |
|
42 public: |
|
43 SVGUseElement(const QualifiedName&, Document*); |
|
44 virtual ~SVGUseElement(); |
|
45 |
|
46 SVGElementInstance* instanceRoot() const; |
|
47 SVGElementInstance* animatedInstanceRoot() const; |
|
48 |
|
49 virtual bool isValid() const { return SVGTests::isValid(); } |
|
50 |
|
51 virtual void insertedIntoDocument(); |
|
52 virtual void removedFromDocument(); |
|
53 virtual void buildPendingResource(); |
|
54 |
|
55 virtual void parseMappedAttribute(Attribute*); |
|
56 virtual void svgAttributeChanged(const QualifiedName&); |
|
57 virtual void synchronizeProperty(const QualifiedName&); |
|
58 |
|
59 virtual void recalcStyle(StyleChange = NoChange); |
|
60 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); |
|
61 virtual void attach(); |
|
62 virtual void detach(); |
|
63 |
|
64 virtual Path toClipPath() const; |
|
65 RenderObject* rendererClipChild() const; |
|
66 |
|
67 static void removeDisallowedElementsFromSubtree(Node* element); |
|
68 SVGElementInstance* instanceForShadowTreeElement(Node* element) const; |
|
69 void invalidateShadowTree(); |
|
70 |
|
71 void setUpdatesBlocked(bool blocked) { m_updatesBlocked = blocked; } |
|
72 |
|
73 private: |
|
74 friend class RenderSVGShadowTreeRootContainer; |
|
75 bool isPendingResource() const { return m_isPendingResource; } |
|
76 void buildShadowAndInstanceTree(SVGShadowTreeRootElement*); |
|
77 |
|
78 private: |
|
79 virtual bool selfHasRelativeLengths() const; |
|
80 |
|
81 DECLARE_ANIMATED_PROPERTY(SVGUseElement, SVGNames::xAttr, SVGLength, X, x) |
|
82 DECLARE_ANIMATED_PROPERTY(SVGUseElement, SVGNames::yAttr, SVGLength, Y, y) |
|
83 DECLARE_ANIMATED_PROPERTY(SVGUseElement, SVGNames::widthAttr, SVGLength, Width, width) |
|
84 DECLARE_ANIMATED_PROPERTY(SVGUseElement, SVGNames::heightAttr, SVGLength, Height, height) |
|
85 |
|
86 // SVGURIReference |
|
87 DECLARE_ANIMATED_PROPERTY(SVGUseElement, XLinkNames::hrefAttr, String, Href, href) |
|
88 |
|
89 // SVGExternalResourcesRequired |
|
90 DECLARE_ANIMATED_PROPERTY(SVGUseElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) |
|
91 |
|
92 private: |
|
93 // Instance tree handling |
|
94 void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundCycle); |
|
95 void handleDeepUseReferencing(SVGUseElement* use, SVGElementInstance* targetInstance, bool& foundCycle); |
|
96 |
|
97 // Shadow tree handling |
|
98 void buildShadowTree(SVGShadowTreeRootElement*, SVGElement* target, SVGElementInstance* targetInstance); |
|
99 |
|
100 #if ENABLE(SVG) && ENABLE(SVG_USE) |
|
101 void expandUseElementsInShadowTree(SVGShadowTreeRootElement*, Node* element); |
|
102 void expandSymbolElementsInShadowTree(SVGShadowTreeRootElement*, Node* element); |
|
103 #endif |
|
104 |
|
105 // "Tree connector" |
|
106 void associateInstancesWithShadowTreeElements(Node* target, SVGElementInstance* targetInstance); |
|
107 SVGElementInstance* instanceForShadowTreeElement(Node* element, SVGElementInstance* instance) const; |
|
108 |
|
109 void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const; |
|
110 void transferEventListenersToShadowTree(SVGElementInstance* target); |
|
111 |
|
112 void updateContainerOffsets(); |
|
113 void updateContainerSizes(); |
|
114 |
|
115 bool m_updatesBlocked; |
|
116 bool m_isPendingResource; |
|
117 bool m_needsShadowTreeRecreation; |
|
118 String m_resourceId; |
|
119 RefPtr<SVGElementInstance> m_targetElementInstance; |
|
120 }; |
|
121 |
|
122 } |
|
123 |
|
124 #endif |
|
125 #endif |