fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / khtml / svg / SVGAnimationElement.h
blob4d42b029d27019e8ec48957994a7ac0772f532b3
1 /*
2 Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
3 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 Copyright (C) 2008 Apple Inc. All rights reserved.
7 This file is part of the KDE project
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA.
25 #ifndef SVGAnimationElement_h
26 #define SVGAnimationElement_h
27 #if ENABLE(SVG_ANIMATION)
29 #include "ElementTimeControl.h"
30 #include "Path.h"
31 #include "SMILTime.h"
32 #include "SVGSMILElement.h"
33 #include "SVGExternalResourcesRequired.h"
34 #include "SVGStringList.h"
35 #include "SVGTests.h"
36 #include "UnitBezier.h"
38 namespace WebCore {
40 class ConditionEventListener;
41 class TimeContainer;
43 class SVGAnimationElement : public SVGSMILElement,
44 public SVGTests,
45 public SVGExternalResourcesRequired,
46 public ElementTimeControl
48 public:
49 SVGAnimationElement(const QualifiedName&, Document*);
50 virtual ~SVGAnimationElement();
52 virtual void parseMappedAttribute(MappedAttribute*);
53 virtual void attributeChanged(Attribute*, bool preserveDecls);
55 // SVGAnimationElement
56 float getStartTime() const;
57 float getCurrentTime() const;
58 float getSimpleDuration(ExceptionCode&) const;
60 // ElementTimeControl
61 virtual bool beginElement(ExceptionCode&);
62 virtual bool beginElementAt(float offset, ExceptionCode&);
63 virtual bool endElement(ExceptionCode&);
64 virtual bool endElementAt(float offset, ExceptionCode&);
66 static bool attributeIsCSS(const String& attributeName);
68 protected:
70 enum CalcMode { CalcModeDiscrete, CalcModeLinear, CalcModePaced, CalcModeSpline };
71 CalcMode calcMode() const;
73 enum AttributeType { AttributeTypeCSS, AttributeTypeXML, AttributeTypeAuto };
74 AttributeType attributeType() const;
76 String toValue() const;
77 String byValue() const;
78 String fromValue() const;
80 enum AnimationMode { NoAnimation, ToAnimation, ByAnimation, ValuesAnimation, FromToAnimation, FromByAnimation, PathAnimation };
81 AnimationMode animationMode() const;
83 virtual bool hasValidTarget() const;
85 String targetAttributeBaseValue() const;
86 void setTargetAttributeAnimatedValue(const String&);
87 bool targetAttributeIsCSS() const;
89 bool isAdditive() const;
90 bool isAccumulated() const;
92 // from SVGSMILElement
93 virtual void startedActiveInterval();
94 virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement);
95 virtual void endedActiveInterval();
97 ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
98 private:
99 virtual bool calculateFromAndToValues(const String& fromString, const String& toString) = 0;
100 virtual bool calculateFromAndByValues(const String& fromString, const String& byString) = 0;
101 virtual void calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement) = 0;
102 virtual float calculateDistance(const String& fromString, const String& toString) { return -1.f; }
103 virtual Path animationPath() const { return Path(); }
105 void currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to) const;
106 void calculateKeyTimesForCalcModePaced();
107 float calculatePercentFromKeyPoints(float percent) const;
108 void currentValuesFromKeyPoints(float percent, float& effectivePercent, String& from, String& to) const;
109 float calculatePercentForSpline(float percent, unsigned splineIndex) const;
111 protected:
112 bool m_animationValid;
114 Vector<String> m_values;
115 Vector<float> m_keyTimes;
116 Vector<float> m_keyPoints;
117 Vector<UnitBezier> m_keySplines;
118 String m_lastValuesAnimationFrom;
119 String m_lastValuesAnimationTo;
122 } // namespace WebCore
124 #endif // ENABLE(SVG)
125 #endif // SVGAnimationElement_h