23 #ifndef SVGDocumentExtensions_h
24 #define SVGDocumentExtensions_h
29 #include <wtf/Forward.h>
30 #include <wtf/HashSet.h>
31 #include <wtf/HashMap.h>
34 #include "StringHash.h"
36 #include "AtomicString.h"
37 #include "xml/Document.h"
51 class SVGElementInstance;
52 class SVGStyledElement;
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;
64 class SVGDocumentExtensions {
66 SVGDocumentExtensions(Document*);
67 ~SVGDocumentExtensions();
69 DOM::EventListener* createSVGEventListener(
const DOMString& functionName,
const DOMString& code, DOM::NodeImpl*);
71 void addTimeContainer(SVGSVGElement*);
72 void removeTimeContainer(SVGSVGElement*);
74 void startAnimations();
75 void pauseAnimations();
76 void unpauseAnimations();
78 void reportWarning(
const String&);
79 void reportError(
const String&);
83 HashSet<SVGSVGElement*> m_timeContainers;
85 HashMap<SVGElement*, HashSet<SVGElementInstance*>*> m_elementInstances;
87 SVGDocumentExtensions(
const SVGDocumentExtensions&);
88 SVGDocumentExtensions& operator=(
const SVGDocumentExtensions&);
90 template<
typename ValueType>
91 HashMap<const SVGElement*, HashMap<StringImpl*, ValueType>*>* baseValueMap()
const
93 static HashMap<const SVGElement*, HashMap<StringImpl*, ValueType>*>* s_baseValueMap =
new HashMap<const SVGElement*, HashMap<StringImpl*, ValueType>*>();
94 return s_baseValueMap;
101 void addPendingResource(
const AtomicString&
id, SVGStyledElement*);
102 bool isPendingResource(
const AtomicString&
id)
const;
103 std::auto_ptr<HashSet<SVGStyledElement*> > removePendingResource(
const AtomicString&
id);
107 void mapInstanceToElement(SVGElementInstance*, SVGElement*);
108 void removeInstanceMapping(SVGElementInstance*, SVGElement*);
109 HashSet<SVGElementInstance*>* instancesForElement(SVGElement*)
const;
112 template<
typename ValueType>
113 ValueType baseValue(
const SVGElement* element,
const AtomicString& propertyName)
const
115 HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->
get(element);
117 return propertyMap->get(propertyName.impl());
122 template<
typename ValueType>
123 void setBaseValue(
const SVGElement* element,
const AtomicString& propertyName, ValueType newValue)
125 HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->
get(element);
127 propertyMap =
new HashMap<StringImpl*, ValueType>();
128 baseValueMap<ValueType>()->set(element, propertyMap);
131 propertyMap->set(propertyName.impl(), newValue);
134 template<
typename ValueType>
135 void removeBaseValue(
const SVGElement* element,
const AtomicString& propertyName)
137 HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->
get(element);
141 propertyMap->remove(propertyName.impl());
144 template<
typename ValueType>
145 bool hasBaseValue(
const SVGElement* element,
const AtomicString& propertyName)
const
147 HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->
get(element);
149 return propertyMap->contains(propertyName.impl());
157 inline String SVGDocumentExtensions::baseValue<String>(
const SVGElement* element,
const AtomicString& propertyName)
const
159 HashMap<StringImpl*, String>* propertyMap = baseValueMap<String>()->
get(element);
161 return propertyMap->get(propertyName.impl());
168 inline FloatRect SVGDocumentExtensions::baseValue<FloatRect>(
const SVGElement* element,
const AtomicString& propertyName)
const
170 HashMap<StringImpl*, FloatRect>* propertyMap = baseValueMap<FloatRect>()->
get(element);
172 return propertyMap->get(propertyName.impl());
179 inline bool SVGDocumentExtensions::baseValue<bool>(
const SVGElement* element,
const AtomicString& propertyName)
const
181 HashMap<StringImpl*, bool>* propertyMap = baseValueMap<bool>()->
get(element);
183 return propertyMap->get(propertyName.impl());
190 inline double SVGDocumentExtensions::baseValue<double>(
const SVGElement* element,
const AtomicString& propertyName)
const
192 HashMap<StringImpl*, double>* propertyMap = baseValueMap<double>()->
get(element);
194 return propertyMap->get(propertyName.impl());
201 #endif // ENABLE(SVG)
uint qHash(const KPluginInfo &p)
Introduced in DOM Level 2.