Generate more SVG type checks and conversions.
[WebKit-https.git] / Source / WebCore / svg / SVGUseElement.h
index 89a79a6..f435e6e 100644 (file)
 #define SVGUseElement_h
 
 #if ENABLE(SVG)
+#include "CachedResourceHandle.h"
+#include "CachedSVGDocumentClient.h"
 #include "SVGAnimatedBoolean.h"
 #include "SVGAnimatedLength.h"
 #include "SVGExternalResourcesRequired.h"
-#include "SVGLangSpace.h"
-#include "SVGStyledTransformableElement.h"
-#include "SVGTests.h"
+#include "SVGGraphicsElement.h"
+#include "SVGNames.h"
 #include "SVGURIReference.h"
+#include "StyleResolveTree.h"
 
 namespace WebCore {
 
+class CachedSVGDocument;
 class SVGElementInstance;
-class SVGShadowTreeRootElement;
 
-class SVGUseElement : public SVGStyledTransformableElement,
-                      public SVGTests,
-                      public SVGLangSpace,
-                      public SVGExternalResourcesRequired,
-                      public SVGURIReference {
+class SVGUseElement FINAL : public SVGGraphicsElement,
+                            public SVGExternalResourcesRequired,
+                            public SVGURIReference,
+                            public CachedSVGDocumentClient {
 public:
-    static PassRefPtr<SVGUseElement> create(const QualifiedName&, Document*);
+    static PassRefPtr<SVGUseElement> create(const QualifiedName&, Document*, bool wasInsertedByParser);
+    virtual ~SVGUseElement();
 
     SVGElementInstance* instanceRoot();
     SVGElementInstance* animatedInstanceRoot() const;
     SVGElementInstance* instanceForShadowTreeElement(Node*) const;
     void invalidateShadowTree();
+    void invalidateDependentShadowTrees();
 
     RenderObject* rendererClipChild() const;
 
 private:
-    SVGUseElement(const QualifiedName&, Document*);
+    SVGUseElement(const QualifiedName&, Document*, bool wasInsertedByParser);
 
     virtual bool isValid() const { return SVGTests::isValid(); }
-    virtual bool supportsFocus() const { return true; }
+    virtual bool supportsFocus() const OVERRIDE { return true; }
 
-    virtual void insertedIntoDocument();
-    virtual void removedFromDocument();
+    virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
+    virtual void removedFrom(ContainerNode*) OVERRIDE;
     virtual void buildPendingResource();
 
     bool isSupportedAttribute(const QualifiedName&);
-    virtual void parseMappedAttribute(Attribute*);
+    virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     virtual void svgAttributeChanged(const QualifiedName&);
 
-    virtual void recalcStyle(StyleChange = NoChange);
-    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
-    virtual void attach();
-    virtual void detach();
+    virtual bool willRecalcStyle(Style::Change);
 
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     virtual void toClipPath(Path&);
 
-    static void removeDisallowedElementsFromSubtree(Node* element);
-
-    void setUpdatesBlocked(bool blocked) { m_updatesBlocked = blocked; }
-
-    friend class RenderSVGShadowTreeRootContainer;
-    void buildShadowAndInstanceTree(SVGShadowTreeRootElement*);
+    void clearResourceReferences();
+    void buildShadowAndInstanceTree(SVGElement* target);
     void detachInstance();
 
+    virtual bool haveLoadedRequiredResources() { return SVGExternalResourcesRequired::haveLoadedRequiredResources(); }
+
+    virtual void finishParsingChildren();
     virtual bool selfHasRelativeLengths() const;
 
     // Instance tree handling
-    void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundCycle);
+    void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundCycle, bool foundUse);
     bool hasCycleUseReferencing(SVGUseElement*, SVGElementInstance* targetInstance, SVGElement*& newTarget);
 
     // Shadow tree handling
-    void buildShadowTree(SVGShadowTreeRootElement*, SVGElement* target, SVGElementInstance* targetInstance);
+    void buildShadowTree(SVGElement* target, SVGElementInstance* targetInstance);
 
-#if ENABLE(SVG) && ENABLE(SVG_USE)
     void expandUseElementsInShadowTree(Node* element);
     void expandSymbolElementsInShadowTree(Node* element);
-#endif
 
     // "Tree connector" 
     void associateInstancesWithShadowTreeElements(Node* target, SVGElementInstance* targetInstance);
@@ -100,9 +98,6 @@ private:
     void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const;
     void transferEventListenersToShadowTree(SVGElementInstance* target);
 
-    void updateContainerOffsets();
-    void updateContainerSizes();
-
     BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGUseElement)
         DECLARE_ANIMATED_LENGTH(X, x)
         DECLARE_ANIMATED_LENGTH(Y, y)
@@ -112,15 +107,25 @@ private:
         DECLARE_ANIMATED_BOOLEAN(ExternalResourcesRequired, externalResourcesRequired)
     END_DECLARE_ANIMATED_PROPERTIES
 
-    // SVGTests
-    virtual void synchronizeRequiredFeatures() { SVGTests::synchronizeRequiredFeatures(this); }
-    virtual void synchronizeRequiredExtensions() { SVGTests::synchronizeRequiredExtensions(this); }
-    virtual void synchronizeSystemLanguage() { SVGTests::synchronizeSystemLanguage(this); }
-
-    bool m_updatesBlocked;
+    bool cachedDocumentIsStillLoading();
+    Document* externalDocument() const;
+    bool instanceTreeIsLoading(SVGElementInstance*);
+    virtual void notifyFinished(CachedResource*);
+    Document* referencedDocument() const;
+    void setCachedDocument(CachedResourceHandle<CachedSVGDocument>);
+
+    // SVGExternalResourcesRequired
+    virtual void setHaveFiredLoadEvent(bool haveFiredLoadEvent) { m_haveFiredLoadEvent = haveFiredLoadEvent; }
+    virtual bool isParserInserted() const { return m_wasInsertedByParser; }
+    virtual bool haveFiredLoadEvent() const { return m_haveFiredLoadEvent; }
+    virtual Timer<SVGElement>* svgLoadEventTimer() OVERRIDE { return &m_svgLoadEventTimer; }
+
+    bool m_wasInsertedByParser;
+    bool m_haveFiredLoadEvent;
     bool m_needsShadowTreeRecreation;
-    String m_resourceId;
     RefPtr<SVGElementInstance> m_targetElementInstance;
+    CachedResourceHandle<CachedSVGDocument> m_cachedDocument;
+    Timer<SVGElement> m_svgLoadEventTimer;
 };
 
 }