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

Side by Side Diff: Source/core/svg/SVGAnimatedTypeAnimator.cpp

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
« no previous file with comments | « Source/core/svg/SVGAnimatedTypeAnimator.h ('k') | Source/core/svg/SVGBoolean.h » ('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 2011-2012. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * 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.
9 * 9 *
10 * 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,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * 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
16 * 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
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #include "config.h" 21 #include "config.h"
22 #include "core/svg/SVGAnimatedTypeAnimator.h" 22 #include "core/svg/SVGAnimatedTypeAnimator.h"
23 23
24 #include "core/css/parser/CSSParser.h" 24 #include "core/css/parser/CSSParser.h"
25 #include "core/svg/SVGAnimateTransformElement.h" 25 #include "core/svg/SVGAnimateTransformElement.h"
26 #include "core/svg/SVGAnimatedColor.h" 26 #include "core/svg/SVGAnimatedColor.h"
27 #include "core/svg/SVGAnimationElement.h" 27 #include "core/svg/SVGAnimationElement.h"
28 #include "core/svg/SVGElement.h"
29 #include "core/svg/SVGLength.h" 28 #include "core/svg/SVGLength.h"
30 #include "core/svg/SVGLengthList.h" 29 #include "core/svg/SVGLengthList.h"
31 #include "core/svg/SVGNumber.h" 30 #include "core/svg/SVGNumber.h"
32 #include "core/svg/SVGPointList.h" 31 #include "core/svg/SVGPointList.h"
33 #include "core/svg/SVGString.h" 32 #include "core/svg/SVGString.h"
34 #include "core/svg/SVGTransformList.h" 33 #include "core/svg/SVGTransformList.h"
35 34
36 namespace blink { 35 namespace blink {
37 36
38 SVGAnimatedTypeAnimator::SVGAnimatedTypeAnimator(SVGAnimationElement* animationE lement, SVGElement* contextElement) 37 SVGAnimatedTypeAnimator::SVGAnimatedTypeAnimator(SVGAnimationElement* animationE lement, SVGElement* contextElement)
(...skipping 15 matching lines...) Expand all
54 53
55 ASSERT(m_type != AnimatedPoint 54 ASSERT(m_type != AnimatedPoint
56 && m_type != AnimatedStringList 55 && m_type != AnimatedStringList
57 && m_type != AnimatedTransform); 56 && m_type != AnimatedTransform);
58 } 57 }
59 58
60 SVGAnimatedTypeAnimator::~SVGAnimatedTypeAnimator() 59 SVGAnimatedTypeAnimator::~SVGAnimatedTypeAnimator()
61 { 60 {
62 } 61 }
63 62
64 PassRefPtr<SVGPropertyBase> SVGAnimatedTypeAnimator::createPropertyForAnimation( const String& value) 63 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGAnimatedTypeAnimator::createPropertyF orAnimation(const String& value)
65 { 64 {
66 if (isAnimatingSVGDom()) { 65 if (isAnimatingSVGDom()) {
67 // SVG DOM animVal animation code-path. 66 // SVG DOM animVal animation code-path.
68 67
69 if (m_type == AnimatedTransformList) { 68 if (m_type == AnimatedTransformList) {
70 // TransformList must be animated via <animateTransform>, 69 // TransformList must be animated via <animateTransform>,
71 // and its {from,by,to} attribute values needs to be parsed w.r.t. i ts "type" attribute. 70 // and its {from,by,to} attribute values needs to be parsed w.r.t. i ts "type" attribute.
72 // Spec: http://www.w3.org/TR/SVG/single-page.html#animate-AnimateTr ansformElement 71 // Spec: http://www.w3.org/TR/SVG/single-page.html#animate-AnimateTr ansformElement
73 ASSERT(m_animationElement); 72 ASSERT(m_animationElement);
74 SVGTransformType transformType = toSVGAnimateTransformElement(m_anim ationElement)->transformType(); 73 SVGTransformType transformType = toSVGAnimateTransformElement(m_anim ationElement)->transformType();
75 return SVGTransformList::create(transformType, value); 74 return SVGTransformList::create(transformType, value);
76 } 75 }
77 76
78 ASSERT(m_animatedProperty); 77 ASSERT(m_animatedProperty);
79 return m_animatedProperty->currentValueBase()->cloneForAnimation(value); 78 return m_animatedProperty->currentValueBase()->cloneForAnimation(value);
80 } 79 }
81 80
82 ASSERT(isAnimatingCSSProperty()); 81 ASSERT(isAnimatingCSSProperty());
83 82
84 // CSS properties animation code-path. 83 // CSS properties animation code-path.
85 // Create a basic instance of the corresponding SVG property. 84 // Create a basic instance of the corresponding SVG property.
86 // The instance will not have full context info. (e.g. SVGLengthMode) 85 // The instance will not have full context info. (e.g. SVGLengthMode)
87 86
88 switch (m_type) { 87 switch (m_type) {
89 case AnimatedColor: 88 case AnimatedColor:
90 return SVGColorProperty::create(value.isEmpty() ? StyleColor::currentCol or() : CSSParser::colorFromRGBColorString(value)); 89 return SVGColorProperty::create(value.isEmpty() ? StyleColor::currentCol or() : CSSParser::colorFromRGBColorString(value));
91 case AnimatedNumber: { 90 case AnimatedNumber: {
92 RefPtr<SVGNumber> property = SVGNumber::create(); 91 RefPtrWillBeRawPtr<SVGNumber> property = SVGNumber::create();
93 property->setValueAsString(value, IGNORE_EXCEPTION); 92 property->setValueAsString(value, IGNORE_EXCEPTION);
94 return property.release(); 93 return property.release();
95 } 94 }
96 case AnimatedLength: { 95 case AnimatedLength: {
97 RefPtr<SVGLength> property = SVGLength::create(LengthModeOther); 96 RefPtrWillBeRawPtr<SVGLength> property = SVGLength::create(LengthModeOth er);
98 property->setValueAsString(value, IGNORE_EXCEPTION); 97 property->setValueAsString(value, IGNORE_EXCEPTION);
99 return property.release(); 98 return property.release();
100 } 99 }
101 case AnimatedLengthList: { 100 case AnimatedLengthList: {
102 RefPtr<SVGLengthList> property = SVGLengthList::create(LengthModeOther); 101 RefPtrWillBeRawPtr<SVGLengthList> property = SVGLengthList::create(Lengt hModeOther);
103 property->setValueAsString(value, IGNORE_EXCEPTION); 102 property->setValueAsString(value, IGNORE_EXCEPTION);
104 return property.release(); 103 return property.release();
105 } 104 }
106 case AnimatedString: { 105 case AnimatedString: {
107 RefPtr<SVGString> property = SVGString::create(); 106 RefPtrWillBeRawPtr<SVGString> property = SVGString::create();
108 property->setValueAsString(value, IGNORE_EXCEPTION); 107 property->setValueAsString(value, IGNORE_EXCEPTION);
109 return property.release(); 108 return property.release();
110 } 109 }
111 110
112 // These types don't appear in the table in SVGElement::animatedPropertyType ForCSSAttribute() and thus don't need support. 111 // These types don't appear in the table in SVGElement::animatedPropertyType ForCSSAttribute() and thus don't need support.
113 case AnimatedAngle: 112 case AnimatedAngle:
114 case AnimatedBoolean: 113 case AnimatedBoolean:
115 case AnimatedEnumeration: 114 case AnimatedEnumeration:
116 case AnimatedInteger: 115 case AnimatedInteger:
117 case AnimatedIntegerOptionalInteger: 116 case AnimatedIntegerOptionalInteger:
(...skipping 10 matching lines...) Expand all
128 ASSERT_NOT_REACHED(); 127 ASSERT_NOT_REACHED();
129 128
130 case AnimatedUnknown: 129 case AnimatedUnknown:
131 ASSERT_NOT_REACHED(); 130 ASSERT_NOT_REACHED();
132 }; 131 };
133 132
134 ASSERT_NOT_REACHED(); 133 ASSERT_NOT_REACHED();
135 return nullptr; 134 return nullptr;
136 } 135 }
137 136
138 PassRefPtr<SVGPropertyBase> SVGAnimatedTypeAnimator::constructFromString(const S tring& value) 137 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGAnimatedTypeAnimator::constructFromSt ring(const String& value)
139 { 138 {
140 return createPropertyForAnimation(value); 139 return createPropertyForAnimation(value);
141 } 140 }
142 141
143 void SVGAnimatedTypeAnimator::calculateFromAndToValues(RefPtr<SVGPropertyBase>& from, RefPtr<SVGPropertyBase>& to, const String& fromString, const String& toStr ing) 142 void SVGAnimatedTypeAnimator::calculateFromAndToValues(RefPtrWillBeMember<SVGPro pertyBase>& from, RefPtrWillBeMember<SVGPropertyBase>& to, const String& fromStr ing, const String& toString)
144 { 143 {
145 from = constructFromString(fromString); 144 from = constructFromString(fromString);
146 to = constructFromString(toString); 145 to = constructFromString(toString);
147 } 146 }
148 147
149 void SVGAnimatedTypeAnimator::calculateFromAndByValues(RefPtr<SVGPropertyBase>& from, RefPtr<SVGPropertyBase>& to, const String& fromString, const String& byStr ing) 148 void SVGAnimatedTypeAnimator::calculateFromAndByValues(RefPtrWillBeMember<SVGPro pertyBase>& from, RefPtrWillBeMember<SVGPropertyBase>& to, const String& fromStr ing, const String& byString)
150 { 149 {
151 from = constructFromString(fromString); 150 from = constructFromString(fromString);
152 to = constructFromString(byString); 151 to = constructFromString(byString);
153 // FIXME(oilpan): Below .get() should be removed after transition types are gone. 152 // FIXME(oilpan): Below .get() should be removed after transition types are gone.
154 to->add(from.get(), m_contextElement); 153 to->add(from.get(), m_contextElement);
155 } 154 }
156 155
157 namespace { 156 namespace {
158 157
159 void setAnimatedValueOnAllTargetProperties(const WillBeHeapVector<RawPtrWillBeMe mber<SVGElement> >& list, const QualifiedName& attributeName, PassRefPtr<SVGProp ertyBase> passValue) 158 void setAnimatedValueOnAllTargetProperties(const WillBeHeapVector<RawPtrWillBeMe mber<SVGElement> >& list, const QualifiedName& attributeName, PassRefPtrWillBeRa wPtr<SVGPropertyBase> passValue)
160 { 159 {
161 RefPtr<SVGPropertyBase> value = passValue; 160 RefPtrWillBeRawPtr<SVGPropertyBase> value = passValue;
162 161
163 WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::const_iterator it = list. begin(); 162 WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::const_iterator it = list. begin();
164 WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::const_iterator itEnd = li st.end(); 163 WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::const_iterator itEnd = li st.end();
165 for (; it != itEnd; ++it) { 164 for (; it != itEnd; ++it) {
166 RefPtr<SVGAnimatedPropertyBase> animatedProperty = (*it)->propertyFromAt tribute(attributeName); 165 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> animatedProperty = (*it)->pr opertyFromAttribute(attributeName);
167 if (animatedProperty) 166 if (animatedProperty)
168 animatedProperty->setAnimatedValue(value); 167 animatedProperty->setAnimatedValue(value);
169 } 168 }
170 } 169 }
171 170
172 } 171 }
173 172
174 PassRefPtr<SVGPropertyBase> SVGAnimatedTypeAnimator::resetAnimation(const WillBe HeapVector<RawPtrWillBeMember<SVGElement> >& list) 173 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGAnimatedTypeAnimator::resetAnimation( const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >& list)
175 { 174 {
176 ASSERT(isAnimatingSVGDom()); 175 ASSERT(isAnimatingSVGDom());
177 RefPtr<SVGPropertyBase> animatedValue = m_animatedProperty->createAnimatedVa lue(); 176 RefPtrWillBeRawPtr<SVGPropertyBase> animatedValue = m_animatedProperty->crea teAnimatedValue();
178 ASSERT(animatedValue->type() == m_type); 177 ASSERT(animatedValue->type() == m_type);
179 setAnimatedValueOnAllTargetProperties(list, m_animatedProperty->attributeNam e(), animatedValue); 178 setAnimatedValueOnAllTargetProperties(list, m_animatedProperty->attributeNam e(), animatedValue);
180 179
181 return animatedValue.release(); 180 return animatedValue.release();
182 } 181 }
183 182
184 PassRefPtr<SVGPropertyBase> SVGAnimatedTypeAnimator::startAnimValAnimation(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >& list) 183 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGAnimatedTypeAnimator::startAnimValAni mation(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >& list)
185 { 184 {
186 ASSERT(isAnimatingSVGDom()); 185 ASSERT(isAnimatingSVGDom());
187 SVGElement::InstanceUpdateBlocker blocker(m_contextElement); 186 SVGElement::InstanceUpdateBlocker blocker(m_contextElement);
188 187
189 return resetAnimation(list); 188 return resetAnimation(list);
190 } 189 }
191 190
192 void SVGAnimatedTypeAnimator::stopAnimValAnimation(const WillBeHeapVector<RawPtr WillBeMember<SVGElement> >& list) 191 void SVGAnimatedTypeAnimator::stopAnimValAnimation(const WillBeHeapVector<RawPtr WillBeMember<SVGElement> >& list)
193 { 192 {
194 ASSERT(isAnimatingSVGDom()); 193 ASSERT(isAnimatingSVGDom());
195 SVGElement::InstanceUpdateBlocker blocker(m_contextElement); 194 SVGElement::InstanceUpdateBlocker blocker(m_contextElement);
196 195
197 WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::const_iterator it = list. begin(); 196 WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::const_iterator it = list. begin();
198 WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::const_iterator itEnd = li st.end(); 197 WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::const_iterator itEnd = li st.end();
199 for (; it != itEnd; ++it) { 198 for (; it != itEnd; ++it) {
200 RefPtr<SVGAnimatedPropertyBase> animatedProperty = (*it)->propertyFromAt tribute(m_animatedProperty->attributeName()); 199 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> animatedProperty = (*it)->pr opertyFromAttribute(m_animatedProperty->attributeName());
201 if (animatedProperty) 200 if (animatedProperty)
202 animatedProperty->animationEnded(); 201 animatedProperty->animationEnded();
203 } 202 }
204 } 203 }
205 204
206 PassRefPtr<SVGPropertyBase> SVGAnimatedTypeAnimator::resetAnimValToBaseVal(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >& list) 205 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGAnimatedTypeAnimator::resetAnimValToB aseVal(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >& list)
207 { 206 {
208 SVGElement::InstanceUpdateBlocker blocker(m_contextElement); 207 SVGElement::InstanceUpdateBlocker blocker(m_contextElement);
209 208
210 return resetAnimation(list); 209 return resetAnimation(list);
211 } 210 }
212 211
213 class ParsePropertyFromString { 212 class ParsePropertyFromString {
213 STACK_ALLOCATED();
214 public: 214 public:
215 explicit ParsePropertyFromString(SVGAnimatedTypeAnimator* animator) 215 explicit ParsePropertyFromString(SVGAnimatedTypeAnimator* animator)
216 : m_animator(animator) 216 : m_animator(animator)
217 { 217 {
218 } 218 }
219 219
220 PassRefPtr<SVGPropertyBase> operator()(SVGAnimationElement*, const String& v alue) 220 PassRefPtrWillBeRawPtr<SVGPropertyBase> operator()(SVGAnimationElement*, con st String& value)
221 { 221 {
222 return m_animator->createPropertyForAnimation(value); 222 return m_animator->createPropertyForAnimation(value);
223 } 223 }
224 224
225 private: 225 private:
226 SVGAnimatedTypeAnimator* m_animator; 226 RawPtrWillBeMember<SVGAnimatedTypeAnimator> m_animator;
227 }; 227 };
228 228
229 void SVGAnimatedTypeAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGPropertyBase* from, SVGPropertyBase* to, SVGPropertyBase* toAtEn dOfDuration, SVGPropertyBase* animated) 229 void SVGAnimatedTypeAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGPropertyBase* from, SVGPropertyBase* to, SVGPropertyBase* toAtEn dOfDuration, SVGPropertyBase* animated)
230 { 230 {
231 ASSERT(m_animationElement); 231 ASSERT(m_animationElement);
232 ASSERT(m_contextElement); 232 ASSERT(m_contextElement);
233 233
234 RefPtr<SVGPropertyBase> fromValue = m_animationElement->animationMode() == T oAnimation ? animated : from; 234 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = m_animationElement->animatio nMode() == ToAnimation ? animated : from;
235 RefPtr<SVGPropertyBase> toValue = to; 235 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = to;
236 RefPtr<SVGPropertyBase> toAtEndOfDurationValue = toAtEndOfDuration; 236 RefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue = toAtEndOfDurati on;
237 RefPtr<SVGPropertyBase> animatedValue = animated; 237 RefPtrWillBeRawPtr<SVGPropertyBase> animatedValue = animated;
238 238
239 // Apply CSS inheritance rules. 239 // Apply CSS inheritance rules.
240 ParsePropertyFromString parsePropertyFromString(this); 240 ParsePropertyFromString parsePropertyFromString(this);
241 m_animationElement->adjustForInheritance<RefPtr<SVGPropertyBase>, ParsePrope rtyFromString>(parsePropertyFromString, m_animationElement->fromPropertyValueTyp e(), fromValue, m_contextElement); 241 m_animationElement->adjustForInheritance<RefPtrWillBeRawPtr<SVGPropertyBase> , ParsePropertyFromString>(parsePropertyFromString, m_animationElement->fromProp ertyValueType(), fromValue, m_contextElement);
242 m_animationElement->adjustForInheritance<RefPtr<SVGPropertyBase>, ParsePrope rtyFromString>(parsePropertyFromString, m_animationElement->toPropertyValueType( ), toValue, m_contextElement); 242 m_animationElement->adjustForInheritance<RefPtrWillBeRawPtr<SVGPropertyBase> , ParsePropertyFromString>(parsePropertyFromString, m_animationElement->toProper tyValueType(), toValue, m_contextElement);
243 243
244 animatedValue->calculateAnimatedValue(m_animationElement, percentage, repeat Count, fromValue, toValue, toAtEndOfDurationValue, m_contextElement); 244 animatedValue->calculateAnimatedValue(m_animationElement, percentage, repeat Count, fromValue, toValue, toAtEndOfDurationValue, m_contextElement);
245 } 245 }
246 246
247 float SVGAnimatedTypeAnimator::calculateDistance(const String& fromString, const String& toString) 247 float SVGAnimatedTypeAnimator::calculateDistance(const String& fromString, const String& toString)
248 { 248 {
249 ASSERT(m_animationElement); 249 ASSERT(m_animationElement);
250 ASSERT(m_contextElement); 250 ASSERT(m_contextElement);
251 RefPtr<SVGPropertyBase> fromValue = createPropertyForAnimation(fromString); 251 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = createPropertyForAnimation(f romString);
252 RefPtr<SVGPropertyBase> toValue = createPropertyForAnimation(toString); 252 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = createPropertyForAnimation(toS tring);
253 return fromValue->calculateDistance(toValue, m_contextElement); 253 return fromValue->calculateDistance(toValue, m_contextElement);
254 } 254 }
255 255
256 void SVGAnimatedTypeAnimator::trace(Visitor* visitor) 256 void SVGAnimatedTypeAnimator::trace(Visitor* visitor)
257 { 257 {
258 visitor->trace(m_animationElement); 258 visitor->trace(m_animationElement);
259 visitor->trace(m_contextElement); 259 visitor->trace(m_contextElement);
260 visitor->trace(m_animatedProperty);
260 } 261 }
261 262
262 } 263 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGAnimatedTypeAnimator.h ('k') | Source/core/svg/SVGBoolean.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698