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 #include "core/SVGNames.h" 25 #include "core/fetch/DocumentResource.h" 26 #include "core/svg/SVGAnimatedBoolean.h" 27 #include "core/svg/SVGAnimatedLength.h" 28 #include "core/svg/SVGGraphicsElement.h" 29 #include "core/svg/SVGURIReference.h" 30 31 namespace blink { 32 33 class DocumentResource; 34 35 class SVGUseElement FINAL : public SVGGraphicsElement, 36 public SVGURIReference, 37 public DocumentResourceClient { 38 DEFINE_WRAPPERTYPEINFO(); 39 public: 40 static PassRefPtrWillBeRawPtr<SVGUseElement> create(Document&); 41 virtual ~SVGUseElement(); 42 43 void invalidateShadowTree(); 44 45 RenderObject* rendererClipChild() const; 46 47 SVGAnimatedLength* x() const { return m_x.get(); } 48 SVGAnimatedLength* y() const { return m_y.get(); } 49 SVGAnimatedLength* width() const { return m_width.get(); } 50 SVGAnimatedLength* height() const { return m_height.get(); } 51 52 virtual void buildPendingResource() OVERRIDE; 53 54 virtual void trace(Visitor*) OVERRIDE; 55 56 private: 57 explicit SVGUseElement(Document&); 58 59 virtual bool isStructurallyExternal() const OVERRIDE { return !hrefString().isNull() && isExternalURIReference(hrefString(), document()); } 60 61 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 62 virtual void removedFrom(ContainerNode*) OVERRIDE; 63 64 bool isSupportedAttribute(const QualifiedName&); 65 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 66 virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE; 67 68 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; 69 virtual void toClipPath(Path&) OVERRIDE; 70 71 void clearResourceReferences(); 72 void buildShadowAndInstanceTree(SVGElement* target); 73 74 void scheduleShadowTreeRecreation(); 75 virtual bool haveLoadedRequiredResources() OVERRIDE { return !isStructurallyExternal() || m_haveFiredLoadEvent; } 76 77 virtual bool selfHasRelativeLengths() const OVERRIDE; 78 79 // Instance tree handling 80 bool buildShadowTree(SVGElement* target, SVGElement* targetInstance, bool foundUse); 81 bool hasCycleUseReferencing(SVGUseElement*, ContainerNode* targetInstance, SVGElement*& newTarget); 82 bool expandUseElementsInShadowTree(SVGElement*); 83 void expandSymbolElementsInShadowTree(SVGElement*); 84 85 void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const; 86 87 void invalidateDependentShadowTrees(); 88 89 bool resourceIsStillLoading(); 90 Document* externalDocument() const; 91 bool instanceTreeIsLoading(SVGElement*); 92 virtual void notifyFinished(Resource*) OVERRIDE; 93 TreeScope* referencedScope() const; 94 void setDocumentResource(ResourcePtr<DocumentResource>); 95 96 virtual Timer<SVGElement>* svgLoadEventTimer() OVERRIDE { return &m_svgLoadEventTimer; } 97 98 RefPtr<SVGAnimatedLength> m_x; 99 RefPtr<SVGAnimatedLength> m_y; 100 RefPtr<SVGAnimatedLength> m_width; 101 RefPtr<SVGAnimatedLength> m_height; 102 103 bool m_haveFiredLoadEvent; 104 bool m_needsShadowTreeRecreation; 105 RefPtrWillBeMember<SVGElement> m_targetElementInstance; 106 ResourcePtr<DocumentResource> m_resource; 107 Timer<SVGElement> m_svgLoadEventTimer; 108 }; 109 110 } // namespace blink 111 112 #endif // SVGUseElement_h 113