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

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

Issue 190793011: Use isSVG*Element() helpers more in SVG code (Part 4) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGAElement.cpp ('k') | Source/core/svg/SVGAnimateMotionElement.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) 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 20 matching lines...) Expand all
31 #include "core/svg/SVGAnimatedTypeAnimator.h" 31 #include "core/svg/SVGAnimatedTypeAnimator.h"
32 #include "core/svg/SVGAnimatorFactory.h" 32 #include "core/svg/SVGAnimatorFactory.h"
33 #include "core/svg/SVGDocumentExtensions.h" 33 #include "core/svg/SVGDocumentExtensions.h"
34 34
35 namespace WebCore { 35 namespace WebCore {
36 36
37 SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, Document& doc ument) 37 SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, Document& doc ument)
38 : SVGAnimationElement(tagName, document) 38 : SVGAnimationElement(tagName, document)
39 , m_animatedPropertyType(AnimatedString) 39 , m_animatedPropertyType(AnimatedString)
40 { 40 {
41 ASSERT(hasTagName(SVGNames::animateTag) || hasTagName(SVGNames::setTag) || h asTagName(SVGNames::animateTransformTag)); 41 ASSERT(isSVGAnimateElement(*this));
42 ScriptWrappable::init(this); 42 ScriptWrappable::init(this);
43 } 43 }
44 44
45 PassRefPtr<SVGAnimateElement> SVGAnimateElement::create(Document& document) 45 PassRefPtr<SVGAnimateElement> SVGAnimateElement::create(Document& document)
46 { 46 {
47 return adoptRef(new SVGAnimateElement(SVGNames::animateTag, document)); 47 return adoptRef(new SVGAnimateElement(SVGNames::animateTag, document));
48 } 48 }
49 49
50 SVGAnimateElement::~SVGAnimateElement() 50 SVGAnimateElement::~SVGAnimateElement()
51 { 51 {
(...skipping 13 matching lines...) Expand all
65 void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat Count, SVGSMILElement* resultElement) 65 void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat Count, SVGSMILElement* resultElement)
66 { 66 {
67 ASSERT(resultElement); 67 ASSERT(resultElement);
68 SVGElement* targetElement = this->targetElement(); 68 SVGElement* targetElement = this->targetElement();
69 if (!targetElement || !isSVGAnimateElement(*resultElement)) 69 if (!targetElement || !isSVGAnimateElement(*resultElement))
70 return; 70 return;
71 71
72 ASSERT(m_animatedPropertyType == determineAnimatedPropertyType()); 72 ASSERT(m_animatedPropertyType == determineAnimatedPropertyType());
73 73
74 ASSERT(percentage >= 0 && percentage <= 1); 74 ASSERT(percentage >= 0 && percentage <= 1);
75 ASSERT(m_animatedPropertyType != AnimatedTransformList || hasTagName(SVGName s::animateTransformTag)); 75 ASSERT(m_animatedPropertyType != AnimatedTransformList || isSVGAnimateTransf ormElement(*this));
76 ASSERT(m_animatedPropertyType != AnimatedUnknown); 76 ASSERT(m_animatedPropertyType != AnimatedUnknown);
77 ASSERT(m_animator); 77 ASSERT(m_animator);
78 ASSERT(m_animator->type() == m_animatedPropertyType); 78 ASSERT(m_animator->type() == m_animatedPropertyType);
79 ASSERT(m_fromProperty); 79 ASSERT(m_fromProperty);
80 ASSERT(m_fromProperty->type() == m_animatedPropertyType); 80 ASSERT(m_fromProperty->type() == m_animatedPropertyType);
81 ASSERT(m_toProperty); 81 ASSERT(m_toProperty);
82 82
83 SVGAnimateElement* resultAnimationElement = toSVGAnimateElement(resultElemen t); 83 SVGAnimateElement* resultAnimationElement = toSVGAnimateElement(resultElemen t);
84 ASSERT(resultAnimationElement->m_animatedProperty); 84 ASSERT(resultAnimationElement->m_animatedProperty);
85 ASSERT(resultAnimationElement->m_animatedPropertyType == m_animatedPropertyT ype); 85 ASSERT(resultAnimationElement->m_animatedPropertyType == m_animatedPropertyT ype);
86 86
87 if (hasTagName(SVGNames::setTag)) 87 if (isSVGSetElement(*this))
88 percentage = 1; 88 percentage = 1;
89 89
90 if (calcMode() == CalcModeDiscrete) 90 if (calcMode() == CalcModeDiscrete)
91 percentage = percentage < 0.5 ? 0 : 1; 91 percentage = percentage < 0.5 ? 0 : 1;
92 92
93 // Target element might have changed. 93 // Target element might have changed.
94 m_animator->setContextElement(targetElement); 94 m_animator->setContextElement(targetElement);
95 95
96 // Be sure to detach list wrappers before we modfiy their underlying value. If we'd do 96 // Be sure to detach list wrappers before we modfiy their underlying value. If we'd do
97 // if after calculateAnimatedValue() ran the cached pointers in the list pro pery tear 97 // if after calculateAnimatedValue() ran the cached pointers in the list pro pery tear
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (!targetElement) 131 if (!targetElement)
132 return false; 132 return false;
133 133
134 if (animationMode() == ByAnimation && !isAdditive()) 134 if (animationMode() == ByAnimation && !isAdditive())
135 return false; 135 return false;
136 136
137 // from-by animation may only be used with attributes that support addition (e.g. most numeric attributes). 137 // from-by animation may only be used with attributes that support addition (e.g. most numeric attributes).
138 if (animationMode() == FromByAnimation && !animatedPropertyTypeSupportsAddit ion()) 138 if (animationMode() == FromByAnimation && !animatedPropertyTypeSupportsAddit ion())
139 return false; 139 return false;
140 140
141 ASSERT(!hasTagName(SVGNames::setTag)); 141 ASSERT(!isSVGSetElement(*this));
142 142
143 determinePropertyValueTypes(fromString, byString); 143 determinePropertyValueTypes(fromString, byString);
144 ensureAnimator()->calculateFromAndByValues(m_fromProperty, m_toProperty, fro mString, byString); 144 ensureAnimator()->calculateFromAndByValues(m_fromProperty, m_toProperty, fro mString, byString);
145 ASSERT(m_animatedPropertyType == m_animator->type()); 145 ASSERT(m_animatedPropertyType == m_animator->type());
146 return true; 146 return true;
147 } 147 }
148 148
149 #ifndef NDEBUG 149 #ifndef NDEBUG
150 static inline bool propertyTypesAreConsistent(AnimatedPropertyType expectedPrope rtyType, const SVGElementAnimatedPropertyList& animatedTypes) 150 static inline bool propertyTypesAreConsistent(AnimatedPropertyType expectedPrope rtyType, const SVGElementAnimatedPropertyList& animatedTypes)
151 { 151 {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 m_animator->stopAnimValAnimation(m_animatedProperties); 313 m_animator->stopAnimValAnimation(m_animatedProperties);
314 notifyTargetAndInstancesAboutAnimValChange(targetElement, attributeName( )); 314 notifyTargetAndInstancesAboutAnimValChange(targetElement, attributeName( ));
315 } 315 }
316 316
317 m_animatedProperties.clear(); 317 m_animatedProperties.clear();
318 m_animatedProperty.clear(); 318 m_animatedProperty.clear();
319 } 319 }
320 320
321 void SVGAnimateElement::applyResultsToTarget() 321 void SVGAnimateElement::applyResultsToTarget()
322 { 322 {
323 ASSERT(m_animatedPropertyType != AnimatedTransformList || hasTagName(SVGName s::animateTransformTag)); 323 ASSERT(m_animatedPropertyType != AnimatedTransformList || isSVGAnimateTransf ormElement(*this));
324 ASSERT(m_animatedPropertyType != AnimatedUnknown); 324 ASSERT(m_animatedPropertyType != AnimatedUnknown);
325 ASSERT(m_animator); 325 ASSERT(m_animator);
326 326
327 // Early exit if our animated type got destructed by a previous endedActiveI nterval(). 327 // Early exit if our animated type got destructed by a previous endedActiveI nterval().
328 if (!m_animatedProperty) 328 if (!m_animatedProperty)
329 return; 329 return;
330 330
331 if (m_animatedProperties.isEmpty()) { 331 if (m_animatedProperties.isEmpty()) {
332 // CSS properties animation code-path. 332 // CSS properties animation code-path.
333 // Convert the result of the animation to a String and apply it as CSS p roperty on the target & all instances. 333 // Convert the result of the animation to a String and apply it as CSS p roperty on the target & all instances.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 400
401 SVGAnimatedTypeAnimator* SVGAnimateElement::ensureAnimator() 401 SVGAnimatedTypeAnimator* SVGAnimateElement::ensureAnimator()
402 { 402 {
403 if (!m_animator) 403 if (!m_animator)
404 m_animator = SVGAnimatorFactory::create(this, targetElement(), m_animate dPropertyType); 404 m_animator = SVGAnimatorFactory::create(this, targetElement(), m_animate dPropertyType);
405 ASSERT(m_animatedPropertyType == m_animator->type()); 405 ASSERT(m_animatedPropertyType == m_animator->type());
406 return m_animator.get(); 406 return m_animator.get();
407 } 407 }
408 408
409 } 409 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGAElement.cpp ('k') | Source/core/svg/SVGAnimateMotionElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698