• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 Apple Inc. All rights reserved.
3  * Copyright (C) 2006, 2008 Nikolas Zimmermann <zimmermann@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 SVGDocumentExtensions_h
22 #define SVGDocumentExtensions_h
23 
24 #if ENABLE(SVG)
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>
32 
33 namespace WebCore {
34 
35 class Document;
36 class RenderSVGResourceContainer;
37 class SVGElement;
38 class SVGStyledElement;
39 class SVGSMILElement;
40 class SVGSVGElement;
41 
42 class SVGDocumentExtensions {
43     WTF_MAKE_NONCOPYABLE(SVGDocumentExtensions); WTF_MAKE_FAST_ALLOCATED;
44 public:
45     typedef HashSet<RefPtr<SVGStyledElement> > SVGPendingElements;
46     SVGDocumentExtensions(Document*);
47     ~SVGDocumentExtensions();
48 
49     void addTimeContainer(SVGSVGElement*);
50     void removeTimeContainer(SVGSVGElement*);
51 
52     void addResource(const AtomicString& id, RenderSVGResourceContainer*);
53     void removeResource(const AtomicString& id);
54     RenderSVGResourceContainer* resourceById(const AtomicString& id) const;
55 
56     void startAnimations();
57     void pauseAnimations();
58     void unpauseAnimations();
59     bool sampleAnimationAtTime(const String& elementId, SVGSMILElement*, double time);
60 
61     void addAnimationElementToTarget(SVGSMILElement*, SVGElement*);
62     void removeAnimationElementFromTarget(SVGSMILElement*, SVGElement*);
63     void removeAllAnimationElementsFromTarget(SVGElement*);
64 
65     void reportWarning(const String&);
66     void reportError(const String&);
67 
resourcesCache()68     SVGResourcesCache* resourcesCache() const { return m_resourcesCache.get(); }
69 
70 private:
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;
77 
78 public:
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, PassRefPtr<SVGStyledElement>);
83     bool isPendingResource(const AtomicString& id) const;
84     PassOwnPtr<SVGPendingElements> removePendingResource(const AtomicString& id);
85 };
86 
87 }
88 
89 #endif
90 #endif
91