2 * Copyright (C) 2006 Apple Inc. All rights reserved.
3 * Copyright (C) 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
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.
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.
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.
21 #ifndef SVGDocumentExtensions_h
22 #define SVGDocumentExtensions_h
25 #include <wtf/Forward.h>
26 #include <wtf/HashMap.h>
27 #include <wtf/HashSet.h>
28 #include <wtf/PassOwnPtr.h>
29 #include <wtf/text/AtomicStringHash.h>
30 #include <wtf/text/StringImpl.h>
35 class RenderSVGResourceContainer;
38 class SVGFontFaceElement;
40 class SVGResourcesCache;
44 class SVGDocumentExtensions {
45 WTF_MAKE_NONCOPYABLE(SVGDocumentExtensions); WTF_MAKE_FAST_ALLOCATED;
47 typedef HashSet<SVGElement*> SVGPendingElements;
48 SVGDocumentExtensions(Document*);
49 ~SVGDocumentExtensions();
51 void addTimeContainer(SVGSVGElement*);
52 void removeTimeContainer(SVGSVGElement*);
54 void addResource(const AtomicString& id, RenderSVGResourceContainer*);
55 void removeResource(const AtomicString& id);
56 RenderSVGResourceContainer* resourceById(const AtomicString& id) const;
58 void startAnimations();
59 void pauseAnimations();
60 void unpauseAnimations();
61 void dispatchSVGLoadEventToOutermostSVGElements();
63 void addAnimationElementToTarget(SVGSMILElement*, SVGElement*);
64 void removeAnimationElementFromTarget(SVGSMILElement*, SVGElement*);
65 void removeAllAnimationElementsFromTarget(SVGElement*);
67 void reportWarning(const String&);
68 void reportError(const String&);
70 SVGResourcesCache* resourcesCache() const { return m_resourcesCache.get(); }
72 HashSet<SVGElement*>* setOfElementsReferencingTarget(SVGElement* referencedElement) const;
73 void addElementReferencingTarget(SVGElement* referencingElement, SVGElement* referencedElement);
74 void removeAllTargetReferencesForElement(SVGElement* referencingElement);
75 void removeAllElementReferencesForTarget(SVGElement* referencedElement);
78 const HashSet<SVGFontFaceElement*>& svgFontFaceElements() const { return m_svgFontFaceElements; }
79 void registerSVGFontFaceElement(SVGFontFaceElement*);
80 void unregisterSVGFontFaceElement(SVGFontFaceElement*);
84 Document* m_document; // weak reference
85 HashSet<SVGSVGElement*> m_timeContainers; // For SVG 1.2 support this will need to be made more general.
86 HashMap<SVGElement*, HashSet<SVGSMILElement*>* > m_animatedElements;
88 HashSet<SVGFontFaceElement*> m_svgFontFaceElements;
90 HashMap<AtomicString, RenderSVGResourceContainer*> m_resources;
91 HashMap<AtomicString, SVGPendingElements*> m_pendingResources; // Resources that are pending.
92 HashMap<AtomicString, SVGPendingElements*> m_pendingResourcesForRemoval; // Resources that are pending and scheduled for removal.
93 HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > > m_elementDependencies;
94 OwnPtr<SVGResourcesCache> m_resourcesCache;
97 // This HashMap contains a list of pending resources. Pending resources, are such
98 // which are referenced by any object in the SVG document, but do NOT exist yet.
99 // For instance, dynamically built gradients / patterns / clippers...
100 void addPendingResource(const AtomicString& id, SVGElement*);
101 bool hasPendingResource(const AtomicString& id) const;
102 bool isElementPendingResources(SVGElement*) const;
103 bool isElementPendingResource(SVGElement*, const AtomicString& id) const;
104 void removeElementFromPendingResources(SVGElement*);
105 PassOwnPtr<SVGPendingElements> removePendingResource(const AtomicString& id);
107 // The following two functions are used for scheduling a pending resource to be removed.
108 void markPendingResourcesForRemoval(const AtomicString&);
109 SVGElement* removeElementFromPendingResourcesForRemoval(const AtomicString&);
112 PassOwnPtr<SVGPendingElements> removePendingResourceForRemoval(const AtomicString&);