Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / svg / SVGDocumentExtensions.h
blobf7168c6f4fb87c6ce45f8b2fb67e5206de4bd1b7
1 /*
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
24 #include "core/layout/svg/SVGResourcesCache.h"
25 #include "platform/geometry/FloatPoint.h"
26 #include "platform/heap/Handle.h"
27 #include "wtf/Forward.h"
28 #include "wtf/HashMap.h"
29 #include "wtf/HashSet.h"
30 #include "wtf/text/AtomicStringHash.h"
32 namespace blink {
34 class Document;
35 class LayoutSVGResourceContainer;
36 class SubtreeLayoutScope;
37 class SVGSVGElement;
38 class Element;
40 class SVGDocumentExtensions : public NoBaseWillBeGarbageCollectedFinalized<SVGDocumentExtensions> {
41 WTF_MAKE_NONCOPYABLE(SVGDocumentExtensions); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(SVGDocumentExtensions);
42 public:
43 typedef WillBeHeapHashSet<RawPtrWillBeMember<Element>> SVGPendingElements;
44 explicit SVGDocumentExtensions(Document*);
45 ~SVGDocumentExtensions();
47 void addTimeContainer(SVGSVGElement*);
48 void removeTimeContainer(SVGSVGElement*);
50 void addResource(const AtomicString& id, LayoutSVGResourceContainer*);
51 void removeResource(const AtomicString& id);
52 LayoutSVGResourceContainer* resourceById(const AtomicString& id) const;
54 static void serviceOnAnimationFrame(Document&, double monotonicAnimationStartTime);
56 void startAnimations();
57 void pauseAnimations();
58 void dispatchSVGLoadEventToOutermostSVGElements();
60 void reportWarning(const String&);
61 void reportError(const String&);
63 SVGResourcesCache& resourcesCache() { return m_resourcesCache; }
65 void addSVGRootWithRelativeLengthDescendents(SVGSVGElement*);
66 void removeSVGRootWithRelativeLengthDescendents(SVGSVGElement*);
67 bool isSVGRootWithRelativeLengthDescendents(SVGSVGElement*) const;
68 void invalidateSVGRootsWithRelativeLengthDescendents(SubtreeLayoutScope*);
70 bool zoomAndPanEnabled() const;
72 void startPan(const FloatPoint& start);
73 void updatePan(const FloatPoint& pos) const;
75 static SVGSVGElement* rootElement(const Document&);
76 SVGSVGElement* rootElement() const;
78 DECLARE_TRACE();
80 private:
81 RawPtrWillBeMember<Document> m_document;
82 WillBeHeapHashSet<RawPtrWillBeMember<SVGSVGElement>> m_timeContainers; // For SVG 1.2 support this will need to be made more general.
83 HashMap<AtomicString, LayoutSVGResourceContainer*> m_resources;
84 WillBeHeapHashMap<AtomicString, OwnPtrWillBeMember<SVGPendingElements>> m_pendingResources; // Resources that are pending.
85 WillBeHeapHashMap<AtomicString, OwnPtrWillBeMember<SVGPendingElements>> m_pendingResourcesForRemoval; // Resources that are pending and scheduled for removal.
86 SVGResourcesCache m_resourcesCache;
87 WillBeHeapHashSet<RawPtrWillBeMember<SVGSVGElement>> m_relativeLengthSVGRoots; // Root SVG elements with relative length descendants.
88 FloatPoint m_translate;
89 #if ENABLE(ASSERT)
90 bool m_inRelativeLengthSVGRootsInvalidation;
91 #endif
93 public:
94 // This HashMap contains a list of pending resources. Pending resources, are such
95 // which are referenced by any object in the SVG document, but do NOT exist yet.
96 // For instance, dynamically build gradients / patterns / clippers...
97 void addPendingResource(const AtomicString& id, Element*);
98 bool hasPendingResource(const AtomicString& id) const;
99 bool isElementPendingResources(Element*) const;
100 bool isElementPendingResource(Element*, const AtomicString& id) const;
101 void clearHasPendingResourcesIfPossible(Element*);
102 void removeElementFromPendingResources(Element*);
103 PassOwnPtrWillBeRawPtr<SVGPendingElements> removePendingResource(const AtomicString& id);
105 void serviceAnimations(double monotonicAnimationStartTime);
107 // The following two functions are used for scheduling a pending resource to be removed.
108 void markPendingResourcesForRemoval(const AtomicString&);
109 Element* removeElementFromPendingResourcesForRemoval(const AtomicString&);
111 private:
112 PassOwnPtrWillBeRawPtr<SVGPendingElements> removePendingResourceForRemoval(const AtomicString&);
117 #endif