KHTML
SVGAnimationElement.h
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 00003 2004, 2005, 2006 Rob Buis <buis@kde.org> 00004 Copyright (C) 2007 Eric Seidel <eric@webkit.org> 00005 Copyright (C) 2008 Apple Inc. All rights reserved. 00006 00007 This file is part of the KDE project 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Library General Public 00011 License as published by the Free Software Foundation; either 00012 version 2 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Library General Public License for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with this library; see the file COPYING.LIB. If not, write to 00021 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00022 Boston, MA 02110-1301, USA. 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 // SVGAnimationElement 00056 float getStartTime() const; 00057 float getCurrentTime() const; 00058 float getSimpleDuration(ExceptionCode&) const; 00059 00060 // ElementTimeControl 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 // from SVGSMILElement 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 } // namespace WebCore 00123 00124 #endif // ENABLE(SVG) 00125 #endif // SVGAnimationElement_h
KDE 4.6 API Reference