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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp

Issue 2284263002: Simplify SVGAnimatedTypeAnimator interface (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | third_party/WebKit/Source/core/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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 // Values-animation accumulates using the last values entry corresponding to the end of duration time. 116 // Values-animation accumulates using the last values entry corresponding to the end of duration time.
117 SVGPropertyBase* toAtEndOfDurationProperty = m_toAtEndOfDurationProperty ? m _toAtEndOfDurationProperty.get() : m_toProperty.get(); 117 SVGPropertyBase* toAtEndOfDurationProperty = m_toAtEndOfDurationProperty ? m _toAtEndOfDurationProperty.get() : m_toProperty.get();
118 m_animator.calculateAnimatedValue(percentage, repeatCount, m_fromProperty.ge t(), m_toProperty.get(), toAtEndOfDurationProperty, resultAnimationElement->m_an imatedProperty.get()); 118 m_animator.calculateAnimatedValue(percentage, repeatCount, m_fromProperty.ge t(), m_toProperty.get(), toAtEndOfDurationProperty, resultAnimationElement->m_an imatedProperty.get());
119 } 119 }
120 120
121 bool SVGAnimateElement::calculateToAtEndOfDurationValue(const String& toAtEndOfD urationString) 121 bool SVGAnimateElement::calculateToAtEndOfDurationValue(const String& toAtEndOfD urationString)
122 { 122 {
123 if (toAtEndOfDurationString.isEmpty()) 123 if (toAtEndOfDurationString.isEmpty())
124 return false; 124 return false;
125 m_toAtEndOfDurationProperty = m_animator.constructFromString(toAtEndOfDurati onString); 125 m_toAtEndOfDurationProperty = m_animator.createAnimatedValueFromString(toAtE ndOfDurationString);
126 return true; 126 return true;
127 } 127 }
128 128
129 bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const String& toString) 129 bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const String& toString)
130 { 130 {
131 SVGElement* targetElement = this->targetElement(); 131 SVGElement* targetElement = this->targetElement();
132 if (!targetElement) 132 if (!targetElement)
133 return false; 133 return false;
134 134
135 determinePropertyValueTypes(fromString, toString); 135 determinePropertyValueTypes(fromString, toString);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 if (shouldApply == DontApplyAnimation) 181 if (shouldApply == DontApplyAnimation)
182 return; 182 return;
183 if (shouldApply == ApplyXMLAnimation || shouldApply == ApplyXMLandCSSAnimati on) { 183 if (shouldApply == ApplyXMLAnimation || shouldApply == ApplyXMLandCSSAnimati on) {
184 // SVG DOM animVal animation code-path. 184 // SVG DOM animVal animation code-path.
185 SVGElementInstances animatedElements = findElementInstances(targetElemen t); 185 SVGElementInstances animatedElements = findElementInstances(targetElemen t);
186 ASSERT(!animatedElements.isEmpty()); 186 ASSERT(!animatedElements.isEmpty());
187 187
188 for (SVGElement* element : animatedElements) 188 for (SVGElement* element : animatedElements)
189 addReferenceTo(element); 189 addReferenceTo(element);
190 190
191 if (!m_animatedProperty) 191 m_animatedProperty = m_animator.createAnimatedValue();
192 m_animatedProperty = m_animator.startAnimValAnimation(); 192 targetElement->setAnimatedAttribute(attributeName, m_animatedProperty);
193 else
194 m_animatedProperty = m_animator.resetAnimValToBaseVal();
195
196 return; 193 return;
197 } 194 }
198 DCHECK_EQ(shouldApply, ApplyCSSAnimation); 195 DCHECK_EQ(shouldApply, ApplyCSSAnimation);
199 196
200 // CSS properties animation code-path. 197 // CSS properties animation code-path.
201 String baseValue; 198 String baseValue;
202 DCHECK(isTargetAttributeCSSProperty(targetElement, attributeName)); 199 DCHECK(isTargetAttributeCSSProperty(targetElement, attributeName));
203 computeCSSPropertyValue(targetElement, cssPropertyID(attributeName.localName ()), baseValue); 200 computeCSSPropertyValue(targetElement, cssPropertyID(attributeName.localName ()), baseValue);
204 201
205 m_animatedProperty = m_animator.constructFromString(baseValue); 202 m_animatedProperty = m_animator.createAnimatedValueFromString(baseValue);
206 } 203 }
207 204
208 void SVGAnimateElement::clearAnimatedType() 205 void SVGAnimateElement::clearAnimatedType()
209 { 206 {
210 if (!m_animatedProperty) 207 if (!m_animatedProperty)
211 return; 208 return;
212 209
213 // The animated property lock is held for the "result animation" (see SMILTi meContainer::updateAnimations()) 210 // The animated property lock is held for the "result animation" (see SMILTi meContainer::updateAnimations())
214 // while we're processing an animation group. We will very likely crash late r if we clear the animated type 211 // while we're processing an animation group. We will very likely crash late r if we clear the animated type
215 // while the lock is held. See crbug.com/581546. 212 // while the lock is held. See crbug.com/581546.
216 DCHECK(!animatedTypeIsLocked()); 213 DCHECK(!animatedTypeIsLocked());
217 214
218 SVGElement* targetElement = this->targetElement(); 215 SVGElement* targetElement = this->targetElement();
219 if (!targetElement) { 216 if (!targetElement) {
220 m_animatedProperty.clear(); 217 m_animatedProperty.clear();
221 return; 218 return;
222 } 219 }
223 220
224 ShouldApplyAnimationType shouldApply = shouldApplyAnimation(targetElement, a ttributeName()); 221 ShouldApplyAnimationType shouldApply = shouldApplyAnimation(targetElement, a ttributeName());
225 if (shouldApply == ApplyXMLandCSSAnimation || m_animator.isAnimatingCSSPrope rty()) { 222 if (shouldApply == ApplyXMLandCSSAnimation || m_animator.isAnimatingCSSPrope rty()) {
226 // CSS properties animation code-path. 223 // CSS properties animation code-path.
227 if (shouldApply != DontApplyAnimation) { 224 if (shouldApply != DontApplyAnimation) {
228 CSSPropertyID id = cssPropertyID(attributeName().localName()); 225 CSSPropertyID id = cssPropertyID(attributeName().localName());
229 targetElement->ensureAnimatedSMILStyleProperties()->removeProperty(i d); 226 targetElement->ensureAnimatedSMILStyleProperties()->removeProperty(i d);
230 targetElement->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReas onForTracing::create(StyleChangeReason::Animation)); 227 targetElement->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReas onForTracing::create(StyleChangeReason::Animation));
231 } 228 }
232 } 229 }
233 if (shouldApply == ApplyXMLandCSSAnimation || m_animator.isAnimatingSVGDom() ) { 230 if (shouldApply == ApplyXMLandCSSAnimation || m_animator.isAnimatingSVGDom() ) {
234 // SVG DOM animVal animation code-path. 231 // SVG DOM animVal animation code-path.
235 m_animator.stopAnimValAnimation(); 232 targetElement->clearAnimatedAttribute(attributeName());
236 if (shouldApply != DontApplyAnimation) 233 if (shouldApply != DontApplyAnimation)
237 targetElement->invalidateAnimatedAttribute(attributeName()); 234 targetElement->invalidateAnimatedAttribute(attributeName());
238 } 235 }
239 236
240 m_animatedProperty.clear(); 237 m_animatedProperty.clear();
241 m_animator.clear(); 238 m_animator.clear();
242 } 239 }
243 240
244 void SVGAnimateElement::applyResultsToTarget() 241 void SVGAnimateElement::applyResultsToTarget()
245 { 242 {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 { 327 {
331 visitor->trace(m_fromProperty); 328 visitor->trace(m_fromProperty);
332 visitor->trace(m_toProperty); 329 visitor->trace(m_toProperty);
333 visitor->trace(m_toAtEndOfDurationProperty); 330 visitor->trace(m_toAtEndOfDurationProperty);
334 visitor->trace(m_animatedProperty); 331 visitor->trace(m_animatedProperty);
335 visitor->trace(m_animator); 332 visitor->trace(m_animator);
336 SVGAnimationElement::trace(visitor); 333 SVGAnimationElement::trace(visitor);
337 } 334 }
338 335
339 } // namespace blink 336 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/svg/SVGAnimatedTypeAnimator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698