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

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

Issue 678163002: Oilpan: move SVG property hierarchy to the heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased upto r185213 Created 6 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 G* * Redistributions in binary form must reproduce the above 10 G* * Redistributions in binary form must reproduce the above
(...skipping 19 matching lines...) Expand all
30 30
31 #ifndef SVGAnimatedProperty_h 31 #ifndef SVGAnimatedProperty_h
32 #define SVGAnimatedProperty_h 32 #define SVGAnimatedProperty_h
33 33
34 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 34 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
35 #include "bindings/core/v8/ScriptWrappable.h" 35 #include "bindings/core/v8/ScriptWrappable.h"
36 #include "core/dom/ExceptionCode.h" 36 #include "core/dom/ExceptionCode.h"
37 #include "core/svg/SVGParsingError.h" 37 #include "core/svg/SVGParsingError.h"
38 #include "core/svg/properties/SVGPropertyInfo.h" 38 #include "core/svg/properties/SVGPropertyInfo.h"
39 #include "core/svg/properties/SVGPropertyTearOff.h" 39 #include "core/svg/properties/SVGPropertyTearOff.h"
40 #include "platform/heap/Handle.h"
40 #include "wtf/Noncopyable.h" 41 #include "wtf/Noncopyable.h"
41 #include "wtf/PassRefPtr.h" 42 #include "wtf/PassRefPtr.h"
42 #include "wtf/RefCounted.h" 43 #include "wtf/RefCounted.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 class SVGElement; 47 class SVGElement;
47 48
48 class SVGAnimatedPropertyBase : public RefCounted<SVGAnimatedPropertyBase>, publ ic ScriptWrappableBase { 49 class SVGAnimatedPropertyBase : public RefCountedWillBeGarbageCollectedFinalized <SVGAnimatedPropertyBase>, public ScriptWrappableBase {
50 WTF_MAKE_NONCOPYABLE(SVGAnimatedPropertyBase);
49 public: 51 public:
50 virtual ~SVGAnimatedPropertyBase(); 52 virtual ~SVGAnimatedPropertyBase();
51 53
52 virtual SVGPropertyBase* currentValueBase() = 0; 54 virtual SVGPropertyBase* currentValueBase() = 0;
53 virtual bool isAnimating() const = 0; 55 virtual bool isAnimating() const = 0;
54 56
55 virtual PassRefPtr<SVGPropertyBase> createAnimatedValue() = 0; 57 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> createAnimatedValue() = 0;
56 virtual void setAnimatedValue(PassRefPtr<SVGPropertyBase>) = 0; 58 virtual void setAnimatedValue(PassRefPtrWillBeRawPtr<SVGPropertyBase>) = 0;
57 virtual void animationEnded(); 59 virtual void animationEnded();
58 60
59 virtual void setBaseValueAsString(const String& value, SVGParsingError& pars eError) = 0; 61 virtual void setBaseValueAsString(const String& value, SVGParsingError& pars eError) = 0;
60 virtual bool needsSynchronizeAttribute() = 0; 62 virtual bool needsSynchronizeAttribute() = 0;
61 virtual void synchronizeAttribute(); 63 virtual void synchronizeAttribute();
62 64
63 AnimatedPropertyType type() const 65 AnimatedPropertyType type() const
64 { 66 {
65 return m_type; 67 return m_type;
66 } 68 }
(...skipping 13 matching lines...) Expand all
80 return m_isReadOnly; 82 return m_isReadOnly;
81 } 83 }
82 84
83 void setReadOnly() 85 void setReadOnly()
84 { 86 {
85 m_isReadOnly = true; 87 m_isReadOnly = true;
86 } 88 }
87 89
88 bool isSpecified() const; 90 bool isSpecified() const;
89 91
92 virtual void trace(Visitor* visitor)
93 {
94 visitor->trace(m_contextElement);
95 }
96
90 protected: 97 protected:
91 SVGAnimatedPropertyBase(AnimatedPropertyType, SVGElement*, const QualifiedNa me& attributeName); 98 SVGAnimatedPropertyBase(AnimatedPropertyType, SVGElement*, const QualifiedNa me& attributeName);
92 99
93 private: 100 private:
94 const AnimatedPropertyType m_type; 101 const AnimatedPropertyType m_type;
95 bool m_isReadOnly; 102 bool m_isReadOnly;
96 103
97 // This reference is kept alive from V8 wrapper 104 // This reference is kept alive from V8 wrapper
98 SVGElement* m_contextElement; 105 RawPtrWillBeMember<SVGElement> m_contextElement;
99 106
100 const QualifiedName& m_attributeName; 107 const QualifiedName& m_attributeName;
101
102 WTF_MAKE_NONCOPYABLE(SVGAnimatedPropertyBase);
103 }; 108 };
104 109
105 template <typename Property> 110 template <typename Property>
106 class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase { 111 class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase {
107 public: 112 public:
108 Property* baseValue() 113 Property* baseValue()
109 { 114 {
110 return m_baseValue.get(); 115 return m_baseValue.get();
111 } 116 }
112 117
(...skipping 20 matching lines...) Expand all
133 void setBaseValueAsString(const String& value, SVGParsingError& parseError) override 138 void setBaseValueAsString(const String& value, SVGParsingError& parseError) override
134 { 139 {
135 TrackExceptionState es; 140 TrackExceptionState es;
136 141
137 m_baseValue->setValueAsString(value, es); 142 m_baseValue->setValueAsString(value, es);
138 143
139 if (es.hadException()) 144 if (es.hadException())
140 parseError = ParsingAttributeFailedError; 145 parseError = ParsingAttributeFailedError;
141 } 146 }
142 147
143 virtual PassRefPtr<SVGPropertyBase> createAnimatedValue() override 148 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> createAnimatedValue() overri de
144 { 149 {
145 return m_baseValue->clone(); 150 return m_baseValue->clone();
146 } 151 }
147 152
148 virtual void setAnimatedValue(PassRefPtr<SVGPropertyBase> passValue) overrid e 153 virtual void setAnimatedValue(PassRefPtrWillBeRawPtr<SVGPropertyBase> passVa lue) override
149 { 154 {
150 RefPtr<SVGPropertyBase> value = passValue; 155 RefPtrWillBeRawPtr<SVGPropertyBase> value = passValue;
151 ASSERT(value->type() == Property::classType()); 156 ASSERT(value->type() == Property::classType());
152 m_currentValue = static_pointer_cast<Property>(value.release()); 157 m_currentValue = static_pointer_cast<Property>(value.release());
153 } 158 }
154 159
155 virtual void animationEnded() override 160 virtual void animationEnded() override
156 { 161 {
157 m_currentValue.clear(); 162 m_currentValue.clear();
158 163
159 SVGAnimatedPropertyBase::animationEnded(); 164 SVGAnimatedPropertyBase::animationEnded();
160 } 165 }
161 166
167 virtual void trace(Visitor* visitor) override
168 {
169 visitor->trace(m_baseValue);
170 visitor->trace(m_currentValue);
171 SVGAnimatedPropertyBase::trace(visitor);
172 }
173
162 protected: 174 protected:
163 SVGAnimatedPropertyCommon(SVGElement* contextElement, const QualifiedName& a ttributeName, PassRefPtr<Property> initialValue) 175 SVGAnimatedPropertyCommon(SVGElement* contextElement, const QualifiedName& a ttributeName, PassRefPtrWillBeRawPtr<Property> initialValue)
164 : SVGAnimatedPropertyBase(Property::classType(), contextElement, attribu teName) 176 : SVGAnimatedPropertyBase(Property::classType(), contextElement, attribu teName)
165 , m_baseValue(initialValue) 177 , m_baseValue(initialValue)
166 { 178 {
167 } 179 }
168 180
169 private: 181 private:
170 RefPtr<Property> m_baseValue; 182 RefPtrWillBeMember<Property> m_baseValue;
171 RefPtr<Property> m_currentValue; 183 RefPtrWillBeMember<Property> m_currentValue;
172 }; 184 };
173 185
174 // Implementation of SVGAnimatedProperty which uses primitive types. 186 // Implementation of SVGAnimatedProperty which uses primitive types.
175 // This is for classes which return primitive type for its "animVal". 187 // This is for classes which return primitive type for its "animVal".
176 // Examples are SVGAnimatedBoolean, SVGAnimatedNumber, etc. 188 // Examples are SVGAnimatedBoolean, SVGAnimatedNumber, etc.
177 template <typename Property, typename TearOffType = typename Property::TearOffTy pe, typename PrimitiveType = typename Property::PrimitiveType> 189 template <typename Property, typename TearOffType = typename Property::TearOffTy pe, typename PrimitiveType = typename Property::PrimitiveType>
178 class SVGAnimatedProperty : public SVGAnimatedPropertyCommon<Property> { 190 class SVGAnimatedProperty : public SVGAnimatedPropertyCommon<Property> {
179 public: 191 public:
180 virtual bool needsSynchronizeAttribute() override 192 virtual bool needsSynchronizeAttribute() override
181 { 193 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 this->contextElement()->invalidateSVGAttributes(); 225 this->contextElement()->invalidateSVGAttributes();
214 this->contextElement()->svgAttributeChanged(this->attributeName()); 226 this->contextElement()->svgAttributeChanged(this->attributeName());
215 } 227 }
216 228
217 PrimitiveType animVal() 229 PrimitiveType animVal()
218 { 230 {
219 return this->currentValue()->value(); 231 return this->currentValue()->value();
220 } 232 }
221 233
222 protected: 234 protected:
223 SVGAnimatedProperty(SVGElement* contextElement, const QualifiedName& attribu teName, PassRefPtr<Property> initialValue) 235 SVGAnimatedProperty(SVGElement* contextElement, const QualifiedName& attribu teName, PassRefPtrWillBeRawPtr<Property> initialValue)
224 : SVGAnimatedPropertyCommon<Property>(contextElement, attributeName, ini tialValue) 236 : SVGAnimatedPropertyCommon<Property>(contextElement, attributeName, ini tialValue)
225 , m_baseValueUpdated(false) 237 , m_baseValueUpdated(false)
226 { 238 {
227 } 239 }
228 240
229 bool m_baseValueUpdated; 241 bool m_baseValueUpdated;
230 }; 242 };
231 243
232 // Implementation of SVGAnimatedProperty which uses tear-off value types. 244 // Implementation of SVGAnimatedProperty which uses tear-off value types.
233 // These classes has "void" for its PrimitiveType. 245 // These classes has "void" for its PrimitiveType.
234 // This is for classes which return special type for its "animVal". 246 // This is for classes which return special type for its "animVal".
235 // Examples are SVGAnimatedLength, SVGAnimatedRect, SVGAnimated*List, etc. 247 // Examples are SVGAnimatedLength, SVGAnimatedRect, SVGAnimated*List, etc.
236 template <typename Property, typename TearOffType> 248 template <typename Property, typename TearOffType>
237 class SVGAnimatedProperty<Property, TearOffType, void> : public SVGAnimatedPrope rtyCommon<Property> { 249 class SVGAnimatedProperty<Property, TearOffType, void> : public SVGAnimatedPrope rtyCommon<Property> {
238 public: 250 public:
239 static PassRefPtr<SVGAnimatedProperty<Property> > create(SVGElement* context Element, const QualifiedName& attributeName, PassRefPtr<Property> initialValue) 251 static PassRefPtrWillBeRawPtr<SVGAnimatedProperty<Property> > create(SVGElem ent* contextElement, const QualifiedName& attributeName, PassRefPtrWillBeRawPtr< Property> initialValue)
240 { 252 {
241 return adoptRef(new SVGAnimatedProperty<Property>(contextElement, attrib uteName, initialValue)); 253 return adoptRefWillBeNoop(new SVGAnimatedProperty<Property>(contextEleme nt, attributeName, initialValue));
242 } 254 }
243 255
244 virtual void setAnimatedValue(PassRefPtr<SVGPropertyBase> value) override 256 virtual void setAnimatedValue(PassRefPtrWillBeRawPtr<SVGPropertyBase> value) override
245 { 257 {
246 SVGAnimatedPropertyCommon<Property>::setAnimatedValue(value); 258 SVGAnimatedPropertyCommon<Property>::setAnimatedValue(value);
247 updateAnimValTearOffIfNeeded(); 259 updateAnimValTearOffIfNeeded();
248 } 260 }
249 261
250 virtual void animationEnded() override 262 virtual void animationEnded() override
251 { 263 {
252 SVGAnimatedPropertyCommon<Property>::animationEnded(); 264 SVGAnimatedPropertyCommon<Property>::animationEnded();
253 updateAnimValTearOffIfNeeded(); 265 updateAnimValTearOffIfNeeded();
254 } 266 }
(...skipping 21 matching lines...) Expand all
276 } 288 }
277 289
278 TearOffType* animVal() 290 TearOffType* animVal()
279 { 291 {
280 if (!m_animValTearOff) 292 if (!m_animValTearOff)
281 m_animValTearOff = TearOffType::create(this->currentValue(), this->c ontextElement(), PropertyIsAnimVal, this->attributeName()); 293 m_animValTearOff = TearOffType::create(this->currentValue(), this->c ontextElement(), PropertyIsAnimVal, this->attributeName());
282 294
283 return m_animValTearOff.get(); 295 return m_animValTearOff.get();
284 } 296 }
285 297
298 virtual void trace(Visitor* visitor) override
299 {
300 visitor->trace(m_baseValTearOff);
301 visitor->trace(m_animValTearOff);
302 SVGAnimatedPropertyCommon<Property>::trace(visitor);
303 }
304
286 protected: 305 protected:
287 SVGAnimatedProperty(SVGElement* contextElement, const QualifiedName& attribu teName, PassRefPtr<Property> initialValue) 306 SVGAnimatedProperty(SVGElement* contextElement, const QualifiedName& attribu teName, PassRefPtrWillBeRawPtr<Property> initialValue)
288 : SVGAnimatedPropertyCommon<Property>(contextElement, attributeName, ini tialValue) 307 : SVGAnimatedPropertyCommon<Property>(contextElement, attributeName, ini tialValue)
289 { 308 {
290 } 309 }
291 310
292 private: 311 private:
293 void updateAnimValTearOffIfNeeded() 312 void updateAnimValTearOffIfNeeded()
294 { 313 {
295 if (m_animValTearOff) 314 if (m_animValTearOff)
296 m_animValTearOff->setTarget(this->currentValue()); 315 m_animValTearOff->setTarget(this->currentValue());
297 } 316 }
298 317
299 // When still (not animated): 318 // When still (not animated):
300 // Both m_animValTearOff and m_baseValTearOff target m_baseValue. 319 // Both m_animValTearOff and m_baseValTearOff target m_baseValue.
301 // When animated: 320 // When animated:
302 // m_animValTearOff targets m_currentValue. 321 // m_animValTearOff targets m_currentValue.
303 // m_baseValTearOff targets m_baseValue. 322 // m_baseValTearOff targets m_baseValue.
304 RefPtr<TearOffType> m_baseValTearOff; 323 RefPtrWillBeMember<TearOffType> m_baseValTearOff;
305 RefPtr<TearOffType> m_animValTearOff; 324 RefPtrWillBeMember<TearOffType> m_animValTearOff;
306 }; 325 };
307 326
308 } 327 } // namespace blink
309 328
310 #endif // SVGAnimatedProperty_h 329 #endif // SVGAnimatedProperty_h
OLDNEW
« no previous file with comments | « Source/core/svg/graphics/filters/SVGFilterBuilder.cpp ('k') | Source/core/svg/properties/SVGListPropertyHelper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698