OLD | NEW |
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) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2008 Apple Inc. All rights reserved. |
6 * Copyright (C) 2008 Cameron McCormack <cam@mcc.id.au> | 6 * Copyright (C) 2008 Cameron McCormack <cam@mcc.id.au> |
7 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 DontApplyAnimation, | 85 DontApplyAnimation, |
86 ApplyCSSAnimation, | 86 ApplyCSSAnimation, |
87 ApplyXMLAnimation | 87 ApplyXMLAnimation |
88 }; | 88 }; |
89 | 89 |
90 ShouldApplyAnimation shouldApplyAnimation(SVGElement* targetElement, const Q
ualifiedName& attributeName); | 90 ShouldApplyAnimation shouldApplyAnimation(SVGElement* targetElement, const Q
ualifiedName& attributeName); |
91 | 91 |
92 AnimatedPropertyValueType fromPropertyValueType() const { return m_fromPrope
rtyValueType; } | 92 AnimatedPropertyValueType fromPropertyValueType() const { return m_fromPrope
rtyValueType; } |
93 AnimatedPropertyValueType toPropertyValueType() const { return m_toPropertyV
alueType; } | 93 AnimatedPropertyValueType toPropertyValueType() const { return m_toPropertyV
alueType; } |
94 | 94 |
95 // FIXME: In C++11, remove this as we can use default template argument. | |
96 template<typename AnimatedType> | |
97 void adjustForInheritance(AnimatedType (*parseTypeFromString)(SVGAnimationEl
ement*, const String&), | |
98 AnimatedPropertyValueType valueType, AnimatedType&
animatedType, SVGElement* contextElement) | |
99 { | |
100 ASSERT(parseTypeFromString); | |
101 adjustForInheritance<AnimatedType, AnimatedType (*)(SVGAnimationElement*
, const String&)>(parseTypeFromString, valueType, animatedType, contextElement); | |
102 } | |
103 | |
104 template<typename AnimatedType, typename ParseTypeFromStringType> | 95 template<typename AnimatedType, typename ParseTypeFromStringType> |
105 void adjustForInheritance(ParseTypeFromStringType parseTypeFromString, Anima
tedPropertyValueType valueType, AnimatedType& animatedType, SVGElement* contextE
lement) | 96 void adjustForInheritance(ParseTypeFromStringType parseTypeFromString, Anima
tedPropertyValueType valueType, AnimatedType& animatedType, SVGElement* contextE
lement) |
106 { | 97 { |
107 if (valueType != InheritValue) | 98 if (valueType != InheritValue) |
108 return; | 99 return; |
109 // Replace 'inherit' by its computed property value. | 100 // Replace 'inherit' by its computed property value. |
110 String typeString; | 101 String typeString; |
111 adjustForInheritance(contextElement, attributeName(), typeString); | 102 adjustForInheritance(contextElement, attributeName(), typeString); |
112 animatedType = parseTypeFromString(this, typeString); | 103 animatedType = parseTypeFromString(this, typeString); |
113 } | 104 } |
114 | 105 |
115 template<typename AnimatedType> | 106 template<typename AnimatedType> |
116 bool adjustFromToListValues(const AnimatedType& fromList, const AnimatedType
& toList, AnimatedType& animatedList, float percentage, bool resizeAnimatedListI
fNeeded = true) | |
117 { | |
118 // If no 'to' value is given, nothing to animate. | |
119 unsigned toListSize = toList.size(); | |
120 if (!toListSize) | |
121 return false; | |
122 | |
123 // If the 'from' value is given and it's length doesn't match the 'to' v
alue list length, fallback to a discrete animation. | |
124 unsigned fromListSize = fromList.size(); | |
125 if (fromListSize != toListSize && fromListSize) { | |
126 if (percentage < 0.5) { | |
127 if (animationMode() != ToAnimation) | |
128 animatedList = AnimatedType(fromList); | |
129 } else | |
130 animatedList = AnimatedType(toList); | |
131 | |
132 return false; | |
133 } | |
134 | |
135 ASSERT(!fromListSize || fromListSize == toListSize); | |
136 if (resizeAnimatedListIfNeeded && animatedList.size() < toListSize) | |
137 animatedList.resize(toListSize); | |
138 | |
139 return true; | |
140 } | |
141 | |
142 template<typename AnimatedType> | |
143 void animateDiscreteType(float percentage, const AnimatedType& fromType, con
st AnimatedType& toType, AnimatedType& animatedType) | 107 void animateDiscreteType(float percentage, const AnimatedType& fromType, con
st AnimatedType& toType, AnimatedType& animatedType) |
144 { | 108 { |
145 if ((animationMode() == FromToAnimation && percentage > 0.5) || animatio
nMode() == ToAnimation || percentage == 1) { | 109 if ((animationMode() == FromToAnimation && percentage > 0.5) || animatio
nMode() == ToAnimation || percentage == 1) { |
146 animatedType = AnimatedType(toType); | 110 animatedType = AnimatedType(toType); |
147 return; | 111 return; |
148 } | 112 } |
149 animatedType = AnimatedType(fromType); | 113 animatedType = AnimatedType(fromType); |
150 } | 114 } |
151 | 115 |
152 void animateAdditiveNumber(float percentage, unsigned repeatCount, float fro
mNumber, float toNumber, float toAtEndOfDurationNumber, float& animatedNumber) | 116 void animateAdditiveNumber(float percentage, unsigned repeatCount, float fro
mNumber, float toNumber, float toAtEndOfDurationNumber, float& animatedNumber) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 String m_lastValuesAnimationFrom; | 205 String m_lastValuesAnimationFrom; |
242 String m_lastValuesAnimationTo; | 206 String m_lastValuesAnimationTo; |
243 bool m_hasInvalidCSSAttributeType; | 207 bool m_hasInvalidCSSAttributeType; |
244 CalcMode m_calcMode; | 208 CalcMode m_calcMode; |
245 AnimationMode m_animationMode; | 209 AnimationMode m_animationMode; |
246 }; | 210 }; |
247 | 211 |
248 } // namespace WebCore | 212 } // namespace WebCore |
249 | 213 |
250 #endif // SVGAnimationElement_h | 214 #endif // SVGAnimationElement_h |
OLD | NEW |