• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • khtml
  • svg
SVGDocumentExtensions.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2006 Apple Computer, Inc.
3 2006 Nikolas Zimmermann <zimmermann@kde.org>
4
5 This file is part of the WebKit project
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22
23#ifndef SVGDocumentExtensions_h
24#define SVGDocumentExtensions_h
25
26#if ENABLE(SVG)
27
28#include <memory>
29#include <wtf/Forward.h>
30#include <wtf/HashSet.h>
31#include <wtf/HashMap.h>
32
33#include "FloatRect.h"
34#include "StringHash.h"
35//#include "StringImpl.h"
36#include "AtomicString.h"
37#include "xml/Document.h"
38
39namespace DOM {
40 class EventListener;
41}
42
43namespace WebCore {
44
45//class AtomicString;
46//class Document;
47//class EventListener;
48//class Node;
49//class String;
50class SVGElement;
51class SVGElementInstance;
52class SVGStyledElement;
53class SVGSVGElement;
54class TimeScheduler;
55
56class DOMStringHash
57{
58 public:
59 static unsigned hash(DOMString key) { return qHash(key.implementation()); }
60 static bool equal(DOMString a, DOMString b) { return a == b; }
61 static const bool safeToCompareToEmptyOrDeleted = false;
62};
63
64class SVGDocumentExtensions {
65public:
66 SVGDocumentExtensions(Document*);
67 ~SVGDocumentExtensions();
68
69 DOM::EventListener* createSVGEventListener(const DOMString& functionName, const DOMString& code, DOM::NodeImpl*);
70
71 void addTimeContainer(SVGSVGElement*);
72 void removeTimeContainer(SVGSVGElement*);
73
74 void startAnimations();
75 void pauseAnimations();
76 void unpauseAnimations();
77
78 void reportWarning(const String&);
79 void reportError(const String&);
80
81private:
82 Document* m_doc; // weak reference
83 HashSet<SVGSVGElement*> m_timeContainers; // For SVG 1.2 support this will need to be made more general.
84 //HashMap<String, HashSet<SVGStyledElement*>*, DOMStringHash> m_pendingResources;
85 HashMap<SVGElement*, HashSet<SVGElementInstance*>*> m_elementInstances;
86
87 SVGDocumentExtensions(const SVGDocumentExtensions&);
88 SVGDocumentExtensions& operator=(const SVGDocumentExtensions&);
89
90 template<typename ValueType>
91 HashMap<const SVGElement*, HashMap<StringImpl*, ValueType>*>* baseValueMap() const
92 {
93 static HashMap<const SVGElement*, HashMap<StringImpl*, ValueType>*>* s_baseValueMap = new HashMap<const SVGElement*, HashMap<StringImpl*, ValueType>*>();
94 return s_baseValueMap;
95 }
96
97public:
98 // This HashMap contains a list of pending resources. Pending resources, are such
99 // which are referenced by any object in the SVG document, but do NOT exist yet.
100 // For instance, dynamically build gradients / patterns / clippers...
101 void addPendingResource(const AtomicString& id, SVGStyledElement*);
102 bool isPendingResource(const AtomicString& id) const;
103 std::auto_ptr<HashSet<SVGStyledElement*> > removePendingResource(const AtomicString& id);
104
105 // This HashMap maps elements to their instances, when they are used by <use> elements.
106 // This is needed to synchronize the original element with the internally cloned one.
107 void mapInstanceToElement(SVGElementInstance*, SVGElement*);
108 void removeInstanceMapping(SVGElementInstance*, SVGElement*);
109 HashSet<SVGElementInstance*>* instancesForElement(SVGElement*) const;
110
111 // Used by the ANIMATED_PROPERTY_* macros
112 template<typename ValueType>
113 ValueType baseValue(const SVGElement* element, const AtomicString& propertyName) const
114 {
115 HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->get(element);
116 if (propertyMap)
117 return propertyMap->get(propertyName.impl());
118
119 return 0;
120 }
121
122 template<typename ValueType>
123 void setBaseValue(const SVGElement* element, const AtomicString& propertyName, ValueType newValue)
124 {
125 HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->get(element);
126 if (!propertyMap) {
127 propertyMap = new HashMap<StringImpl*, ValueType>();
128 baseValueMap<ValueType>()->set(element, propertyMap);
129 }
130
131 propertyMap->set(propertyName.impl(), newValue);
132 }
133
134 template<typename ValueType>
135 void removeBaseValue(const SVGElement* element, const AtomicString& propertyName)
136 {
137 HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->get(element);
138 if (!propertyMap)
139 return;
140
141 propertyMap->remove(propertyName.impl());
142 }
143
144 template<typename ValueType>
145 bool hasBaseValue(const SVGElement* element, const AtomicString& propertyName) const
146 {
147 HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->get(element);
148 if (propertyMap)
149 return propertyMap->contains(propertyName.impl());
150
151 return false;
152 }
153};
154
155// Special handling for WebCore::String
156template<>
157inline String SVGDocumentExtensions::baseValue<String>(const SVGElement* element, const AtomicString& propertyName) const
158{
159 HashMap<StringImpl*, String>* propertyMap = baseValueMap<String>()->get(element);
160 if (propertyMap)
161 return propertyMap->get(propertyName.impl());
162
163 return String();
164}
165
166// Special handling for WebCore::FloatRect
167template<>
168inline FloatRect SVGDocumentExtensions::baseValue<FloatRect>(const SVGElement* element, const AtomicString& propertyName) const
169{
170 HashMap<StringImpl*, FloatRect>* propertyMap = baseValueMap<FloatRect>()->get(element);
171 if (propertyMap)
172 return propertyMap->get(propertyName.impl());
173
174 return FloatRect();
175}
176
177// Special handling for booleans
178template<>
179inline bool SVGDocumentExtensions::baseValue<bool>(const SVGElement* element, const AtomicString& propertyName) const
180{
181 HashMap<StringImpl*, bool>* propertyMap = baseValueMap<bool>()->get(element);
182 if (propertyMap)
183 return propertyMap->get(propertyName.impl());
184
185 return false;
186}
187
188// Special handling for doubles
189template<>
190inline double SVGDocumentExtensions::baseValue<double>(const SVGElement* element, const AtomicString& propertyName) const
191{
192 HashMap<StringImpl*, double>* propertyMap = baseValueMap<double>()->get(element);
193 if (propertyMap)
194 return propertyMap->get(propertyName.impl());
195
196 return 0.0;
197}
198
199}
200
201#endif // ENABLE(SVG)
202
203#endif
FloatRect.h
qHash
uint qHash(const KConfigIniBackend::BufferFragment &fragment)
DOM::EventListener
Introduced in DOM Level 2.
Definition: dom2_events.h:70
DOM
This library provides a full-featured HTML parser and widget.
Definition: design.h:55
WebCore
Definition: CSSHelper.h:7
WebCore::String
DOM::DOMString String
Definition: PlatformString.h:8
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal