Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1448)

Side by Side Diff: Source/core/svg/properties/SVGAnimatedProperty.h

Issue 18707002: Reduce number of header includes in SVG (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add Samsung copyright Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGZoomAndPan.h ('k') | Source/core/svg/properties/SVGAnimatedProperty.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
3 * 4 *
4 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
8 * 9 *
9 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 13 * Library General Public License for more details.
13 * 14 *
14 * You should have received a copy of the GNU Library General Public License 15 * 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 16 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
18 */ 19 */
19 20
20 #ifndef SVGAnimatedProperty_h 21 #ifndef SVGAnimatedProperty_h
21 #define SVGAnimatedProperty_h 22 #define SVGAnimatedProperty_h
22 23
23 #include "core/svg/SVGElement.h"
24 #include "core/svg/properties/SVGAnimatedPropertyDescription.h" 24 #include "core/svg/properties/SVGAnimatedPropertyDescription.h"
25 #include "core/svg/properties/SVGPropertyInfo.h" 25 #include "core/svg/properties/SVGPropertyInfo.h"
26 #include <wtf/RefCounted.h> 26 #include <wtf/RefCounted.h>
27 27
28 namespace WebCore { 28 namespace WebCore {
29 29
30 class SVGElement; 30 class SVGElement;
31 31
32 class SVGAnimatedProperty : public RefCounted<SVGAnimatedProperty> { 32 class SVGAnimatedProperty : public RefCounted<SVGAnimatedProperty> {
33 public: 33 public:
34 SVGElement* contextElement() const { return m_contextElement.get(); } 34 SVGElement* contextElement() const { return m_contextElement.get(); }
35 const QualifiedName& attributeName() const { return m_attributeName; } 35 const QualifiedName& attributeName() const { return m_attributeName; }
36 AnimatedPropertyType animatedPropertyType() const { return m_animatedPropert yType; } 36 AnimatedPropertyType animatedPropertyType() const { return m_animatedPropert yType; }
37 bool isAnimating() const { return m_isAnimating; } 37 bool isAnimating() const { return m_isAnimating; }
38 bool isReadOnly() const { return m_isReadOnly; } 38 bool isReadOnly() const { return m_isReadOnly; }
39 void setIsReadOnly() { m_isReadOnly = true; } 39 void setIsReadOnly() { m_isReadOnly = true; }
40 40
41 void commitChange() 41 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 42
49 virtual bool isAnimatedListTearOff() const { return false; } 43 virtual bool isAnimatedListTearOff() const { return false; }
50 44
51 // Caching facilities. 45 // Caching facilities.
52 typedef HashMap<SVGAnimatedPropertyDescription, SVGAnimatedProperty*, SVGAni matedPropertyDescriptionHash, SVGAnimatedPropertyDescriptionHashTraits> Cache; 46 typedef HashMap<SVGAnimatedPropertyDescription, SVGAnimatedProperty*, SVGAni matedPropertyDescriptionHash, SVGAnimatedPropertyDescriptionHashTraits> Cache;
53 47
54 virtual ~SVGAnimatedProperty() 48 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 49
70 template<typename OwnerType, typename TearOffType, typename PropertyType> 50 template<typename OwnerType, typename TearOffType, typename PropertyType>
71 static PassRefPtr<TearOffType> lookupOrCreateWrapper(OwnerType* element, con st SVGPropertyInfo* info, PropertyType& property) 51 static PassRefPtr<TearOffType> lookupOrCreateWrapper(OwnerType* element, con st SVGPropertyInfo* info, PropertyType& property)
72 { 52 {
73 ASSERT(info); 53 ASSERT(info);
74 SVGAnimatedPropertyDescription key(element, info->propertyIdentifier); 54 SVGAnimatedPropertyDescription key(element, info->propertyIdentifier);
75 RefPtr<SVGAnimatedProperty> wrapper = animatedPropertyCache()->get(key); 55 RefPtr<SVGAnimatedProperty> wrapper = animatedPropertyCache()->get(key);
76 if (!wrapper) { 56 if (!wrapper) {
77 wrapper = TearOffType::create(element, info->attributeName, info->an imatedPropertyType, property); 57 wrapper = TearOffType::create(element, info->attributeName, info->an imatedPropertyType, property);
78 if (info->animatedPropertyState == PropertyIsReadOnly) 58 if (info->animatedPropertyState == PropertyIsReadOnly)
(...skipping 11 matching lines...) Expand all
90 return static_cast<TearOffType*>(animatedPropertyCache()->get(key)); 70 return static_cast<TearOffType*>(animatedPropertyCache()->get(key));
91 } 71 }
92 72
93 template<typename OwnerType, typename TearOffType> 73 template<typename OwnerType, typename TearOffType>
94 static TearOffType* lookupWrapper(const OwnerType* element, const SVGPropert yInfo* info) 74 static TearOffType* lookupWrapper(const OwnerType* element, const SVGPropert yInfo* info)
95 { 75 {
96 return lookupWrapper<OwnerType, TearOffType>(const_cast<OwnerType*>(elem ent), info); 76 return lookupWrapper<OwnerType, TearOffType>(const_cast<OwnerType*>(elem ent), info);
97 } 77 }
98 78
99 protected: 79 protected:
100 SVGAnimatedProperty(SVGElement* contextElement, const QualifiedName& attribu teName, AnimatedPropertyType animatedPropertyType) 80 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 81
109 private: 82 private:
110 static Cache* animatedPropertyCache() 83 static Cache* animatedPropertyCache();
111 {
112 static Cache* s_cache = new Cache;
113 return s_cache;
114 }
115 84
116 RefPtr<SVGElement> m_contextElement; 85 RefPtr<SVGElement> m_contextElement;
117 const QualifiedName& m_attributeName; 86 const QualifiedName& m_attributeName;
118 AnimatedPropertyType m_animatedPropertyType; 87 AnimatedPropertyType m_animatedPropertyType;
119 88
120 protected: 89 protected:
121 bool m_isAnimating; 90 bool m_isAnimating;
122 bool m_isReadOnly; 91 bool m_isReadOnly;
123 }; 92 };
124 93
125 } 94 }
126 95
127 #endif // SVGAnimatedProperty_h 96 #endif // SVGAnimatedProperty_h
OLDNEW
« no previous file with comments | « Source/core/svg/SVGZoomAndPan.h ('k') | Source/core/svg/properties/SVGAnimatedProperty.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698