OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
Stephen Chennney
2013/07/08 14:08:39
And here.
| |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #ifndef SVGAnimatedProperty_h | 20 #ifndef SVGAnimatedProperty_h |
21 #define SVGAnimatedProperty_h | 21 #define SVGAnimatedProperty_h |
22 | 22 |
23 #include "core/svg/SVGElement.h" | |
24 #include "core/svg/properties/SVGAnimatedPropertyDescription.h" | 23 #include "core/svg/properties/SVGAnimatedPropertyDescription.h" |
25 #include "core/svg/properties/SVGPropertyInfo.h" | 24 #include "core/svg/properties/SVGPropertyInfo.h" |
26 #include <wtf/RefCounted.h> | 25 #include <wtf/RefCounted.h> |
27 | 26 |
28 namespace WebCore { | 27 namespace WebCore { |
29 | 28 |
30 class SVGElement; | 29 class SVGElement; |
31 | 30 |
32 class SVGAnimatedProperty : public RefCounted<SVGAnimatedProperty> { | 31 class SVGAnimatedProperty : public RefCounted<SVGAnimatedProperty> { |
33 public: | 32 public: |
34 SVGElement* contextElement() const { return m_contextElement.get(); } | 33 SVGElement* contextElement() const { return m_contextElement.get(); } |
35 const QualifiedName& attributeName() const { return m_attributeName; } | 34 const QualifiedName& attributeName() const { return m_attributeName; } |
36 AnimatedPropertyType animatedPropertyType() const { return m_animatedPropert yType; } | 35 AnimatedPropertyType animatedPropertyType() const { return m_animatedPropert yType; } |
37 bool isAnimating() const { return m_isAnimating; } | 36 bool isAnimating() const { return m_isAnimating; } |
38 bool isReadOnly() const { return m_isReadOnly; } | 37 bool isReadOnly() const { return m_isReadOnly; } |
39 void setIsReadOnly() { m_isReadOnly = true; } | 38 void setIsReadOnly() { m_isReadOnly = true; } |
40 | 39 |
41 void commitChange() | 40 void commitChange(); |
42 { | |
43 ASSERT(m_contextElement); | |
44 ASSERT(!m_contextElement->m_deletionHasBegun); | |
45 m_contextElement->invalidateSVGAttributes(); | |
46 m_contextElement->svgAttributeChanged(m_attributeName); | |
47 } | |
48 | 41 |
49 virtual bool isAnimatedListTearOff() const { return false; } | 42 virtual bool isAnimatedListTearOff() const { return false; } |
50 | 43 |
51 // Caching facilities. | 44 // Caching facilities. |
52 typedef HashMap<SVGAnimatedPropertyDescription, SVGAnimatedProperty*, SVGAni matedPropertyDescriptionHash, SVGAnimatedPropertyDescriptionHashTraits> Cache; | 45 typedef HashMap<SVGAnimatedPropertyDescription, SVGAnimatedProperty*, SVGAni matedPropertyDescriptionHash, SVGAnimatedPropertyDescriptionHashTraits> Cache; |
53 | 46 |
54 virtual ~SVGAnimatedProperty() | 47 virtual ~SVGAnimatedProperty(); |
55 { | |
56 // Remove wrapper from cache. | |
57 Cache* cache = animatedPropertyCache(); | |
58 const Cache::const_iterator end = cache->end(); | |
59 for (Cache::const_iterator it = cache->begin(); it != end; ++it) { | |
60 if (it->value == this) { | |
61 cache->remove(it->key); | |
62 break; | |
63 } | |
64 } | |
65 | |
66 // Assure that animationEnded() was called, if animationStarted() was ca lled before. | |
67 ASSERT(!m_isAnimating); | |
68 } | |
69 | 48 |
70 template<typename OwnerType, typename TearOffType, typename PropertyType> | 49 template<typename OwnerType, typename TearOffType, typename PropertyType> |
71 static PassRefPtr<TearOffType> lookupOrCreateWrapper(OwnerType* element, con st SVGPropertyInfo* info, PropertyType& property) | 50 static PassRefPtr<TearOffType> lookupOrCreateWrapper(OwnerType* element, con st SVGPropertyInfo* info, PropertyType& property) |
72 { | 51 { |
73 ASSERT(info); | 52 ASSERT(info); |
74 SVGAnimatedPropertyDescription key(element, info->propertyIdentifier); | 53 SVGAnimatedPropertyDescription key(element, info->propertyIdentifier); |
75 RefPtr<SVGAnimatedProperty> wrapper = animatedPropertyCache()->get(key); | 54 RefPtr<SVGAnimatedProperty> wrapper = animatedPropertyCache()->get(key); |
76 if (!wrapper) { | 55 if (!wrapper) { |
77 wrapper = TearOffType::create(element, info->attributeName, info->an imatedPropertyType, property); | 56 wrapper = TearOffType::create(element, info->attributeName, info->an imatedPropertyType, property); |
78 if (info->animatedPropertyState == PropertyIsReadOnly) | 57 if (info->animatedPropertyState == PropertyIsReadOnly) |
(...skipping 11 matching lines...) Expand all Loading... | |
90 return static_cast<TearOffType*>(animatedPropertyCache()->get(key)); | 69 return static_cast<TearOffType*>(animatedPropertyCache()->get(key)); |
91 } | 70 } |
92 | 71 |
93 template<typename OwnerType, typename TearOffType> | 72 template<typename OwnerType, typename TearOffType> |
94 static TearOffType* lookupWrapper(const OwnerType* element, const SVGPropert yInfo* info) | 73 static TearOffType* lookupWrapper(const OwnerType* element, const SVGPropert yInfo* info) |
95 { | 74 { |
96 return lookupWrapper<OwnerType, TearOffType>(const_cast<OwnerType*>(elem ent), info); | 75 return lookupWrapper<OwnerType, TearOffType>(const_cast<OwnerType*>(elem ent), info); |
97 } | 76 } |
98 | 77 |
99 protected: | 78 protected: |
100 SVGAnimatedProperty(SVGElement* contextElement, const QualifiedName& attribu teName, AnimatedPropertyType animatedPropertyType) | 79 SVGAnimatedProperty(SVGElement*, const QualifiedName&, AnimatedPropertyType) ; |
101 : m_contextElement(contextElement) | |
102 , m_attributeName(attributeName) | |
103 , m_animatedPropertyType(animatedPropertyType) | |
104 , m_isAnimating(false) | |
105 , m_isReadOnly(false) | |
106 { | |
107 } | |
108 | 80 |
109 private: | 81 private: |
110 static Cache* animatedPropertyCache() | 82 static Cache* animatedPropertyCache(); |
111 { | |
112 static Cache* s_cache = new Cache; | |
113 return s_cache; | |
114 } | |
115 | 83 |
116 RefPtr<SVGElement> m_contextElement; | 84 RefPtr<SVGElement> m_contextElement; |
117 const QualifiedName& m_attributeName; | 85 const QualifiedName& m_attributeName; |
118 AnimatedPropertyType m_animatedPropertyType; | 86 AnimatedPropertyType m_animatedPropertyType; |
119 | 87 |
120 protected: | 88 protected: |
121 bool m_isAnimating; | 89 bool m_isAnimating; |
122 bool m_isReadOnly; | 90 bool m_isReadOnly; |
123 }; | 91 }; |
124 | 92 |
125 } | 93 } |
126 | 94 |
127 #endif // SVGAnimatedProperty_h | 95 #endif // SVGAnimatedProperty_h |
OLD | NEW |