1 /* 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann (at) kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis (at) 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 "SVGAnimatedBoolean.h" 26 #include "SVGAnimatedLength.h" 27 #include "SVGExternalResourcesRequired.h" 28 #include "SVGLangSpace.h" 29 #include "SVGStyledTransformableElement.h" 30 #include "SVGTests.h" 31 #include "SVGURIReference.h" 32 33 namespace WebCore { 34 35 class SVGElementInstance; 36 class SVGShadowTreeRootElement; 37 38 class SVGUseElement : public SVGStyledTransformableElement, 39 public SVGTests, 40 public SVGLangSpace, 41 public SVGExternalResourcesRequired, 42 public SVGURIReference { 43 public: 44 static PassRefPtr<SVGUseElement> create(const QualifiedName&, Document*); 45 46 SVGElementInstance* instanceRoot() const; 47 SVGElementInstance* animatedInstanceRoot() const; 48 SVGElementInstance* instanceForShadowTreeElement(Node*) const; 49 void invalidateShadowTree(); 50 51 RenderObject* rendererClipChild() const; 52 53 private: 54 SVGUseElement(const QualifiedName&, Document*); 55 56 virtual bool isValid() const { return SVGTests::isValid(); } 57 58 virtual void insertedIntoDocument(); 59 virtual void removedFromDocument(); 60 virtual void buildPendingResource(); 61 62 virtual void parseMappedAttribute(Attribute*); 63 virtual void svgAttributeChanged(const QualifiedName&); 64 virtual void synchronizeProperty(const QualifiedName&); 65 virtual void fillAttributeToPropertyTypeMap(); 66 virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap(); 67 68 virtual void recalcStyle(StyleChange = NoChange); 69 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 70 virtual void attach(); 71 virtual void detach(); 72 73 virtual void toClipPath(Path&) const; 74 75 static void removeDisallowedElementsFromSubtree(Node* element); 76 77 void setUpdatesBlocked(bool blocked) { m_updatesBlocked = blocked; } 78 79 friend class RenderSVGShadowTreeRootContainer; 80 bool isPendingResource() const { return m_isPendingResource; } 81 void buildShadowAndInstanceTree(SVGShadowTreeRootElement*); 82 void detachInstance(); 83 84 virtual bool selfHasRelativeLengths() const; 85 86 // Instance tree handling 87 void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundCycle); 88 bool hasCycleUseReferencing(SVGUseElement*, SVGElementInstance* targetInstance, SVGElement*& newTarget); 89 90 // Shadow tree handling 91 void buildShadowTree(SVGShadowTreeRootElement*, SVGElement* target, SVGElementInstance* targetInstance); 92 93 #if ENABLE(SVG) && ENABLE(SVG_USE) 94 void expandUseElementsInShadowTree(Node* element); 95 void expandSymbolElementsInShadowTree(Node* element); 96 #endif 97 98 // "Tree connector" 99 void associateInstancesWithShadowTreeElements(Node* target, SVGElementInstance* targetInstance); 100 SVGElementInstance* instanceForShadowTreeElement(Node* element, SVGElementInstance* instance) const; 101 102 void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const; 103 void transferEventListenersToShadowTree(SVGElementInstance* target); 104 105 void updateContainerOffsets(); 106 void updateContainerSizes(); 107 108 // Animated property declarations 109 DECLARE_ANIMATED_LENGTH(X, x) 110 DECLARE_ANIMATED_LENGTH(Y, y) 111 DECLARE_ANIMATED_LENGTH(Width, width) 112 DECLARE_ANIMATED_LENGTH(Height, height) 113 114 // SVGURIReference 115 DECLARE_ANIMATED_STRING(Href, href) 116 117 // SVGExternalResourcesRequired 118 DECLARE_ANIMATED_BOOLEAN(ExternalResourcesRequired, externalResourcesRequired) 119 120 bool m_updatesBlocked; 121 bool m_isPendingResource; 122 bool m_needsShadowTreeRecreation; 123 String m_resourceId; 124 RefPtr<SVGElementInstance> m_targetElementInstance; 125 }; 126 127 } 128 129 #endif 130 #endif 131