KHTML
SVGAnimationElement.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SVGAnimationElement_h
00026 #define SVGAnimationElement_h
00027 #if ENABLE(SVG_ANIMATION)
00028
00029 #include "ElementTimeControl.h"
00030 #include "Path.h"
00031 #include "SMILTime.h"
00032 #include "SVGSMILElement.h"
00033 #include "SVGExternalResourcesRequired.h"
00034 #include "SVGStringList.h"
00035 #include "SVGTests.h"
00036 #include "UnitBezier.h"
00037
00038 namespace WebCore {
00039
00040 class ConditionEventListener;
00041 class TimeContainer;
00042
00043 class SVGAnimationElement : public SVGSMILElement,
00044 public SVGTests,
00045 public SVGExternalResourcesRequired,
00046 public ElementTimeControl
00047 {
00048 public:
00049 SVGAnimationElement(const QualifiedName&, Document*);
00050 virtual ~SVGAnimationElement();
00051
00052 virtual void parseMappedAttribute(MappedAttribute*);
00053 virtual void attributeChanged(Attribute*, bool preserveDecls);
00054
00055
00056 float getStartTime() const;
00057 float getCurrentTime() const;
00058 float getSimpleDuration(ExceptionCode&) const;
00059
00060
00061 virtual bool beginElement(ExceptionCode&);
00062 virtual bool beginElementAt(float offset, ExceptionCode&);
00063 virtual bool endElement(ExceptionCode&);
00064 virtual bool endElementAt(float offset, ExceptionCode&);
00065
00066 static bool attributeIsCSS(const String& attributeName);
00067
00068 protected:
00069
00070 enum CalcMode { CalcModeDiscrete, CalcModeLinear, CalcModePaced, CalcModeSpline };
00071 CalcMode calcMode() const;
00072
00073 enum AttributeType { AttributeTypeCSS, AttributeTypeXML, AttributeTypeAuto };
00074 AttributeType attributeType() const;
00075
00076 String toValue() const;
00077 String byValue() const;
00078 String fromValue() const;
00079
00080 enum AnimationMode { NoAnimation, ToAnimation, ByAnimation, ValuesAnimation, FromToAnimation, FromByAnimation, PathAnimation };
00081 AnimationMode animationMode() const;
00082
00083 virtual bool hasValidTarget() const;
00084
00085 String targetAttributeBaseValue() const;
00086 void setTargetAttributeAnimatedValue(const String&);
00087 bool targetAttributeIsCSS() const;
00088
00089 bool isAdditive() const;
00090 bool isAccumulated() const;
00091
00092
00093 virtual void startedActiveInterval();
00094 virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement);
00095 virtual void endedActiveInterval();
00096
00097 ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
00098 private:
00099 virtual bool calculateFromAndToValues(const String& fromString, const String& toString) = 0;
00100 virtual bool calculateFromAndByValues(const String& fromString, const String& byString) = 0;
00101 virtual void calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement) = 0;
00102 virtual float calculateDistance(const String& fromString, const String& toString) { return -1.f; }
00103 virtual Path animationPath() const { return Path(); }
00104
00105 void currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to) const;
00106 void calculateKeyTimesForCalcModePaced();
00107 float calculatePercentFromKeyPoints(float percent) const;
00108 void currentValuesFromKeyPoints(float percent, float& effectivePercent, String& from, String& to) const;
00109 float calculatePercentForSpline(float percent, unsigned splineIndex) const;
00110
00111 protected:
00112 bool m_animationValid;
00113
00114 Vector<String> m_values;
00115 Vector<float> m_keyTimes;
00116 Vector<float> m_keyPoints;
00117 Vector<UnitBezier> m_keySplines;
00118 String m_lastValuesAnimationFrom;
00119 String m_lastValuesAnimationTo;
00120 };
00121
00122 }
00123
00124 #endif // ENABLE(SVG)
00125 #endif // SVGAnimationElement_h