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 "SVGResourcesCache.h"
26 #include <wtf/Forward.h>
27 #include <wtf/HashMap.h>
28 #include <wtf/HashSet.h>
29 #include <wtf/PassOwnPtr.h>
30 #include <wtf/text/AtomicStringHash.h>
31 #include <wtf/text/StringImpl.h>
36 class RenderSVGResourceContainer;
38 class SVGStyledElement;
42 class SVGDocumentExtensions {
43 WTF_MAKE_NONCOPYABLE(SVGDocumentExtensions); WTF_MAKE_FAST_ALLOCATED;
45 typedef HashSet<SVGStyledElement*> SVGPendingElements;
46 SVGDocumentExtensions(Document*);
47 ~SVGDocumentExtensions();
49 void addTimeContainer(SVGSVGElement*);
50 void removeTimeContainer(SVGSVGElement*);
52 void addResource(const AtomicString& id, RenderSVGResourceContainer*);
53 void removeResource(const AtomicString& id);
54 RenderSVGResourceContainer* resourceById(const AtomicString& id) const;
56 void startAnimations();
57 void pauseAnimations();
58 void unpauseAnimations();
59 bool sampleAnimationAtTime(const String& elementId, SVGSMILElement*, double time);
61 void addAnimationElementToTarget(SVGSMILElement*, SVGElement*);
62 void removeAnimationElementFromTarget(SVGSMILElement*, SVGElement*);
63 void removeAllAnimationElementsFromTarget(SVGElement*);
65 void reportWarning(const String&);
66 void reportError(const String&);
68 SVGResourcesCache* resourcesCache() const { return m_resourcesCache.get(); }
71 Document* m_document; // weak reference
72 HashSet<SVGSVGElement*> m_timeContainers; // For SVG 1.2 support this will need to be made more general.
73 HashMap<SVGElement*, HashSet<SVGSMILElement*>* > m_animatedElements;
74 HashMap<AtomicString, RenderSVGResourceContainer*> m_resources;
75 HashMap<AtomicString, SVGPendingElements*> m_pendingResources;
76 OwnPtr<SVGResourcesCache> m_resourcesCache;
79 // This HashMap contains a list of pending resources. Pending resources, are such
80 // which are referenced by any object in the SVG document, but do NOT exist yet.
81 // For instance, dynamically build gradients / patterns / clippers...
82 void addPendingResource(const AtomicString& id, SVGStyledElement*);
83 bool hasPendingResources(const AtomicString& id) const;
84 bool isElementInPendingResources(SVGStyledElement*) const;
85 void removeElementFromPendingResources(SVGStyledElement*);
86 PassOwnPtr<SVGPendingElements> removePendingResource(const AtomicString& id);