| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 void endElementAt(float offset); | 74 void endElementAt(float offset); |
| 75 | 75 |
| 76 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(begin, beginEvent); | 76 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(begin, beginEvent); |
| 77 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(end, endEvent); | 77 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(end, endEvent); |
| 78 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(repeat, repeatEvent); | 78 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(repeat, repeatEvent); |
| 79 | 79 |
| 80 static bool isTargetAttributeCSSProperty(SVGElement*, const QualifiedName&); | 80 static bool isTargetAttributeCSSProperty(SVGElement*, const QualifiedName&); |
| 81 | 81 |
| 82 virtual bool isAdditive(); | 82 virtual bool isAdditive(); |
| 83 bool isAccumulated() const; | 83 bool isAccumulated() const; |
| 84 AnimationMode animationMode() const { return m_animationMode; } | 84 AnimationMode getAnimationMode() const { return m_animationMode; } |
| 85 CalcMode calcMode() const { return m_calcMode; } | 85 CalcMode getCalcMode() const { return m_calcMode; } |
| 86 | 86 |
| 87 enum ShouldApplyAnimation { | 87 enum ShouldApplyAnimation { |
| 88 DontApplyAnimation, | 88 DontApplyAnimation, |
| 89 ApplyCSSAnimation, | 89 ApplyCSSAnimation, |
| 90 ApplyXMLAnimation, | 90 ApplyXMLAnimation, |
| 91 ApplyXMLandCSSAnimation | 91 ApplyXMLandCSSAnimation |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 ShouldApplyAnimation shouldApplyAnimation(SVGElement* targetElement, const Q
ualifiedName& attributeName); | 94 ShouldApplyAnimation shouldApplyAnimation(SVGElement* targetElement, const Q
ualifiedName& attributeName); |
| 95 | 95 |
| 96 AnimatedPropertyValueType fromPropertyValueType() const { return m_fromPrope
rtyValueType; } | 96 AnimatedPropertyValueType fromPropertyValueType() const { return m_fromPrope
rtyValueType; } |
| 97 AnimatedPropertyValueType toPropertyValueType() const { return m_toPropertyV
alueType; } | 97 AnimatedPropertyValueType toPropertyValueType() const { return m_toPropertyV
alueType; } |
| 98 | 98 |
| 99 template<typename AnimatedType, typename ParseTypeFromStringType> | 99 template<typename AnimatedType, typename ParseTypeFromStringType> |
| 100 void adjustForInheritance(ParseTypeFromStringType parseTypeFromString, Anima
tedPropertyValueType valueType, AnimatedType& animatedType, SVGElement* contextE
lement) | 100 void adjustForInheritance(ParseTypeFromStringType parseTypeFromString, Anima
tedPropertyValueType valueType, AnimatedType& animatedType, SVGElement* contextE
lement) |
| 101 { | 101 { |
| 102 if (valueType != InheritValue) | 102 if (valueType != InheritValue) |
| 103 return; | 103 return; |
| 104 // Replace 'inherit' by its computed property value. | 104 // Replace 'inherit' by its computed property value. |
| 105 String typeString; | 105 String typeString; |
| 106 adjustForInheritance(contextElement, attributeName(), typeString); | 106 adjustForInheritance(contextElement, attributeName(), typeString); |
| 107 animatedType = parseTypeFromString(this, typeString); | 107 animatedType = parseTypeFromString(this, typeString); |
| 108 } | 108 } |
| 109 | 109 |
| 110 template<typename AnimatedType> | 110 template<typename AnimatedType> |
| 111 void animateDiscreteType(float percentage, const AnimatedType& fromType, con
st AnimatedType& toType, AnimatedType& animatedType) | 111 void animateDiscreteType(float percentage, const AnimatedType& fromType, con
st AnimatedType& toType, AnimatedType& animatedType) |
| 112 { | 112 { |
| 113 if ((animationMode() == FromToAnimation && percentage > 0.5) || animatio
nMode() == ToAnimation || percentage == 1) { | 113 if ((getAnimationMode() == FromToAnimation && percentage > 0.5) || getAn
imationMode() == ToAnimation || percentage == 1) { |
| 114 animatedType = AnimatedType(toType); | 114 animatedType = AnimatedType(toType); |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 animatedType = AnimatedType(fromType); | 117 animatedType = AnimatedType(fromType); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void animateAdditiveNumber(float percentage, unsigned repeatCount, float fro
mNumber, float toNumber, float toAtEndOfDurationNumber, float& animatedNumber) | 120 void animateAdditiveNumber(float percentage, unsigned repeatCount, float fro
mNumber, float toNumber, float toAtEndOfDurationNumber, float& animatedNumber) |
| 121 { | 121 { |
| 122 float number; | 122 float number; |
| 123 if (calcMode() == CalcModeDiscrete) | 123 if (getCalcMode() == CalcModeDiscrete) |
| 124 number = percentage < 0.5 ? fromNumber : toNumber; | 124 number = percentage < 0.5 ? fromNumber : toNumber; |
| 125 else | 125 else |
| 126 number = (toNumber - fromNumber) * percentage + fromNumber; | 126 number = (toNumber - fromNumber) * percentage + fromNumber; |
| 127 | 127 |
| 128 if (isAccumulated() && repeatCount) | 128 if (isAccumulated() && repeatCount) |
| 129 number += toAtEndOfDurationNumber * repeatCount; | 129 number += toAtEndOfDurationNumber * repeatCount; |
| 130 | 130 |
| 131 if (isAdditive() && animationMode() != ToAnimation) | 131 if (isAdditive() && getAnimationMode() != ToAnimation) |
| 132 animatedNumber += number; | 132 animatedNumber += number; |
| 133 else | 133 else |
| 134 animatedNumber = number; | 134 animatedNumber = number; |
| 135 } | 135 } |
| 136 | 136 |
| 137 protected: | 137 protected: |
| 138 SVGAnimationElement(const QualifiedName&, Document&); | 138 SVGAnimationElement(const QualifiedName&, Document&); |
| 139 | 139 |
| 140 void computeCSSPropertyValue(SVGElement*, CSSPropertyID, String& value); | 140 void computeCSSPropertyValue(SVGElement*, CSSPropertyID, String& value); |
| 141 void determinePropertyValueTypes(const String& from, const String& to); | 141 void determinePropertyValueTypes(const String& from, const String& to); |
| 142 | 142 |
| 143 void parseAttribute(const QualifiedName&, const AtomicString&, const AtomicS
tring&) override; | 143 void parseAttribute(const QualifiedName&, const AtomicString&, const AtomicS
tring&) override; |
| 144 void svgAttributeChanged(const QualifiedName&) override; | 144 void svgAttributeChanged(const QualifiedName&) override; |
| 145 | 145 |
| 146 enum AttributeType { | 146 enum AttributeType { |
| 147 AttributeTypeCSS, | 147 AttributeTypeCSS, |
| 148 AttributeTypeXML, | 148 AttributeTypeXML, |
| 149 AttributeTypeAuto | 149 AttributeTypeAuto |
| 150 }; | 150 }; |
| 151 AttributeType attributeType() const { return m_attributeType; } | 151 AttributeType getAttributeType() const { return m_attributeType; } |
| 152 | 152 |
| 153 String toValue() const; | 153 String toValue() const; |
| 154 String byValue() const; | 154 String byValue() const; |
| 155 String fromValue() const; | 155 String fromValue() const; |
| 156 | 156 |
| 157 // from SVGSMILElement | 157 // from SVGSMILElement |
| 158 void startedActiveInterval() override; | 158 void startedActiveInterval() override; |
| 159 void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultE
lement) override; | 159 void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultE
lement) override; |
| 160 | 160 |
| 161 AnimatedPropertyValueType m_fromPropertyValueType; | 161 AnimatedPropertyValueType m_fromPropertyValueType; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 String m_lastValuesAnimationFrom; | 216 String m_lastValuesAnimationFrom; |
| 217 String m_lastValuesAnimationTo; | 217 String m_lastValuesAnimationTo; |
| 218 bool m_hasInvalidCSSAttributeType; | 218 bool m_hasInvalidCSSAttributeType; |
| 219 CalcMode m_calcMode; | 219 CalcMode m_calcMode; |
| 220 AnimationMode m_animationMode; | 220 AnimationMode m_animationMode; |
| 221 }; | 221 }; |
| 222 | 222 |
| 223 } // namespace blink | 223 } // namespace blink |
| 224 | 224 |
| 225 #endif // SVGAnimationElement_h | 225 #endif // SVGAnimationElement_h |
| OLD | NEW |