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

Side by Side Diff: Source/WebCore/svg/SVGAnimateElement.cpp

Issue 9569016: Merge 108134 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1025/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « Source/WebCore/svg/SVGAnimateElement.h ('k') | Source/WebCore/svg/SVGAnimatedTypeAnimator.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) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 * Copyright (C) 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2008 Apple Inc. All rights reserved.
5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if (svgParent->isStyled()) 102 if (svgParent->isStyled())
103 getPropertyValue(svgParent, attributeName, value); 103 getPropertyValue(svgParent, attributeName, value);
104 } 104 }
105 105
106 bool SVGAnimateElement::hasValidAttributeType() 106 bool SVGAnimateElement::hasValidAttributeType()
107 { 107 {
108 SVGElement* targetElement = this->targetElement(); 108 SVGElement* targetElement = this->targetElement();
109 if (!targetElement) 109 if (!targetElement)
110 return false; 110 return false;
111 111
112 return determineAnimatedPropertyType(targetElement) != AnimatedUnknown; 112 return m_animatedPropertyType != AnimatedUnknown;
113 } 113 }
114 114
115 AnimatedPropertyType SVGAnimateElement::determineAnimatedPropertyType(SVGElement * targetElement) const 115 AnimatedPropertyType SVGAnimateElement::determineAnimatedPropertyType(SVGElement * targetElement) const
116 { 116 {
117 ASSERT(targetElement); 117 ASSERT(targetElement);
118 118
119 Vector<AnimatedPropertyType> propertyTypes; 119 Vector<AnimatedPropertyType> propertyTypes;
120 targetElement->animatedPropertyTypeForAttribute(attributeName(), propertyTyp es); 120 targetElement->animatedPropertyTypeForAttribute(attributeName(), propertyTyp es);
121 if (propertyTypes.isEmpty()) 121 if (propertyTypes.isEmpty())
122 return AnimatedUnknown; 122 return AnimatedUnknown;
(...skipping 29 matching lines...) Expand all
152 152
153 if (attributeValueIsCurrentColor(from)) 153 if (attributeValueIsCurrentColor(from))
154 m_fromPropertyValueType = CurrentColorValue; 154 m_fromPropertyValueType = CurrentColorValue;
155 if (attributeValueIsCurrentColor(to)) 155 if (attributeValueIsCurrentColor(to))
156 m_toPropertyValueType = CurrentColorValue; 156 m_toPropertyValueType = CurrentColorValue;
157 } 157 }
158 158
159 void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat , SVGSMILElement* resultElement) 159 void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat , SVGSMILElement* resultElement)
160 { 160 {
161 ASSERT(resultElement); 161 ASSERT(resultElement);
162 SVGElement* targetElement = this->targetElement();
163 if (!targetElement)
164 return;
165
166 ASSERT(m_animatedPropertyType == determineAnimatedPropertyType(targetElement ));
167
162 ASSERT(percentage >= 0 && percentage <= 1); 168 ASSERT(percentage >= 0 && percentage <= 1);
163 ASSERT(m_animatedPropertyType != AnimatedEnumeration); 169 ASSERT(m_animatedPropertyType != AnimatedEnumeration);
164 ASSERT(m_animatedPropertyType != AnimatedTransformList); 170 ASSERT(m_animatedPropertyType != AnimatedTransformList);
165 ASSERT(m_animatedPropertyType != AnimatedUnknown); 171 ASSERT(m_animatedPropertyType != AnimatedUnknown);
166 ASSERT(m_animator); 172 ASSERT(m_animator);
173 ASSERT(m_animator->type() == m_animatedPropertyType);
167 ASSERT(m_fromType); 174 ASSERT(m_fromType);
175 ASSERT(m_fromType->type() == m_animatedPropertyType);
168 ASSERT(m_toType); 176 ASSERT(m_toType);
169 177
170 SVGAnimateElement* resultAnimationElement = static_cast<SVGAnimateElement*>( resultElement); 178 SVGAnimateElement* resultAnimationElement = static_cast<SVGAnimateElement*>( resultElement);
171 ASSERT(resultAnimationElement->m_animatedType); 179 ASSERT(resultAnimationElement->m_animatedType);
172 ASSERT(resultAnimationElement->m_animatedPropertyType == m_animatedPropertyT ype); 180 ASSERT(resultAnimationElement->m_animatedPropertyType == m_animatedPropertyT ype);
173 ASSERT(resultAnimationElement->hasTagName(SVGNames::animateTag) 181 ASSERT(resultAnimationElement->hasTagName(SVGNames::animateTag)
174 || resultAnimationElement->hasTagName(SVGNames::animateColorTag) 182 || resultAnimationElement->hasTagName(SVGNames::animateColorTag)
175 || resultAnimationElement->hasTagName(SVGNames::setTag)); 183 || resultAnimationElement->hasTagName(SVGNames::setTag));
176 184
177 if (hasTagName(SVGNames::setTag)) 185 if (hasTagName(SVGNames::setTag))
178 percentage = 1; 186 percentage = 1;
179 187
180 SVGElement* targetElement = this->targetElement();
181 if (!targetElement)
182 return;
183
184 // Target element might have changed. 188 // Target element might have changed.
185 m_animator->setContextElement(targetElement); 189 m_animator->setContextElement(targetElement);
186 m_animator->calculateAnimatedValue(percentage, repeat, m_fromType, m_toType, resultAnimationElement->m_animatedType); 190 m_animator->calculateAnimatedValue(percentage, repeat, m_fromType, m_toType, resultAnimationElement->m_animatedType);
187 } 191 }
188 192
189 bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const String& toString) 193 bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const String& toString)
190 { 194 {
191 SVGElement* targetElement = this->targetElement(); 195 SVGElement* targetElement = this->targetElement();
192 if (!targetElement) 196 if (!targetElement)
193 return false; 197 return false;
194 198
195 m_animatedPropertyType = determineAnimatedPropertyType(targetElement);
196
197 ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString); 199 ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
200 ASSERT(m_animatedPropertyType == m_animator->type());
198 return true; 201 return true;
199 } 202 }
200 203
201 bool SVGAnimateElement::calculateFromAndByValues(const String& fromString, const String& byString) 204 bool SVGAnimateElement::calculateFromAndByValues(const String& fromString, const String& byString)
202 { 205 {
203 SVGElement* targetElement = this->targetElement(); 206 SVGElement* targetElement = this->targetElement();
204 if (!targetElement) 207 if (!targetElement)
205 return false; 208 return false;
206 209
207 ASSERT(!hasTagName(SVGNames::setTag)); 210 ASSERT(!hasTagName(SVGNames::setTag));
208 m_animatedPropertyType = determineAnimatedPropertyType(targetElement);
209 211
210 ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString); 212 ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
213 ASSERT(m_animatedPropertyType == m_animator->type());
211 return true; 214 return true;
212 } 215 }
213 216
214 void SVGAnimateElement::resetToBaseValue(const String& baseString) 217 void SVGAnimateElement::resetToBaseValue(const String& baseString)
215 { 218 {
216 SVGElement* targetElement = this->targetElement();
217 ASSERT(targetElement);
218 m_animatedPropertyType = determineAnimatedPropertyType(targetElement);
219
220 if (!m_animatedType) 219 if (!m_animatedType)
221 m_animatedType = ensureAnimator()->constructFromString(baseString); 220 m_animatedType = ensureAnimator()->constructFromString(baseString);
222 else 221 else
223 m_animatedType->setValueAsString(attributeName(), baseString); 222 m_animatedType->setValueAsString(attributeName(), baseString);
223 ASSERT(m_animatedPropertyType == m_animator->type());
224 } 224 }
225 225
226 void SVGAnimateElement::applyResultsToTarget() 226 void SVGAnimateElement::applyResultsToTarget()
227 { 227 {
228 ASSERT(m_animatedPropertyType != AnimatedEnumeration); 228 ASSERT(m_animatedPropertyType != AnimatedEnumeration);
229 ASSERT(m_animatedPropertyType != AnimatedTransformList); 229 ASSERT(m_animatedPropertyType != AnimatedTransformList);
230 ASSERT(m_animatedPropertyType != AnimatedUnknown); 230 ASSERT(m_animatedPropertyType != AnimatedUnknown);
231 ASSERT(m_animatedType); 231 ASSERT(m_animatedType);
232 232
233 setTargetAttributeAnimatedValue(m_animatedType->valueAsString()); 233 setTargetAttributeAnimatedValue(m_animatedType->valueAsString());
234 } 234 }
235 235
236 float SVGAnimateElement::calculateDistance(const String& fromString, const Strin g& toString) 236 float SVGAnimateElement::calculateDistance(const String& fromString, const Strin g& toString)
237 { 237 {
238 // FIXME: A return value of float is not enough to support paced animations on lists. 238 // FIXME: A return value of float is not enough to support paced animations on lists.
239 SVGElement* targetElement = this->targetElement(); 239 SVGElement* targetElement = this->targetElement();
240 if (!targetElement) 240 if (!targetElement)
241 return -1; 241 return -1;
242 m_animatedPropertyType = determineAnimatedPropertyType(targetElement); 242
243
244 return ensureAnimator()->calculateDistance(fromString, toString); 243 return ensureAnimator()->calculateDistance(fromString, toString);
245 } 244 }
246 245
246 void SVGAnimateElement::targetElementDidChange(SVGElement* targetElement)
247 {
248 m_animatedType.clear();
249 m_fromType.clear();
250 m_toType.clear();
251 m_animator.clear();
252 m_animatedPropertyType = targetElement ? determineAnimatedPropertyType(targe tElement) : AnimatedString;
253 }
254
247 SVGAnimatedTypeAnimator* SVGAnimateElement::ensureAnimator() 255 SVGAnimatedTypeAnimator* SVGAnimateElement::ensureAnimator()
248 { 256 {
249 if (!m_animator) 257 if (!m_animator)
250 m_animator = SVGAnimatorFactory::create(this, targetElement(), m_animate dPropertyType); 258 m_animator = SVGAnimatorFactory::create(this, targetElement(), m_animate dPropertyType);
259 ASSERT(m_animatedPropertyType == m_animator->type());
251 return m_animator.get(); 260 return m_animator.get();
252 } 261 }
253 262
254 } 263 }
255 #endif // ENABLE(SVG) 264 #endif // ENABLE(SVG)
OLDNEW
« no previous file with comments | « Source/WebCore/svg/SVGAnimateElement.h ('k') | Source/WebCore/svg/SVGAnimatedTypeAnimator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698