2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 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.
6 * Copyright (C) 2008 Cameron McCormack <cam@mcc.id.au>
7 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
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
29 #include "ElementTimeControl.h"
32 #include "SVGAnimatedBoolean.h"
33 #include "SVGExternalResourcesRequired.h"
34 #include "SVGSMILElement.h"
35 #include "SVGStringList.h"
37 #include "UnitBezier.h"
48 PathAnimation // Used by AnimateMotion.
58 class ConditionEventListener;
61 class SVGAnimationElement : public SVGSMILElement,
63 public SVGExternalResourcesRequired,
64 public ElementTimeControl {
66 // SVGAnimationElement
67 float getStartTime() const;
68 float getCurrentTime() const;
69 float getSimpleDuration(ExceptionCode&) const;
72 virtual void beginElement();
73 virtual void beginElementAt(float offset);
74 virtual void endElement();
75 virtual void endElementAt(float offset);
77 static bool isTargetAttributeCSSProperty(SVGElement*, const QualifiedName&);
79 bool isAdditive() const;
80 bool isAccumulated() const;
81 AnimationMode animationMode() const;
82 CalcMode calcMode() const;
85 SVGAnimationElement(const QualifiedName&, Document*);
87 bool isSupportedAttribute(const QualifiedName&);
88 virtual void parseMappedAttribute(Attribute*);
95 AttributeType attributeType() const;
97 String toValue() const;
98 String byValue() const;
99 String fromValue() const;
101 String targetAttributeBaseValue() const;
102 void setTargetAttributeAnimatedValue(const String&);
104 // from SVGSMILElement
105 virtual void startedActiveInterval();
106 virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement);
107 virtual void endedActiveInterval();
110 virtual void attributeChanged(Attribute*, bool preserveDecls);
112 virtual bool calculateFromAndToValues(const String& fromString, const String& toString) = 0;
113 virtual bool calculateFromAndByValues(const String& fromString, const String& byString) = 0;
114 virtual void calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement) = 0;
115 virtual float calculateDistance(const String& /*fromString*/, const String& /*toString*/) { return -1.f; }
116 virtual Path animationPath() const { return Path(); }
118 void currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to);
119 void calculateKeyTimesForCalcModePaced();
120 float calculatePercentFromKeyPoints(float percent) const;
121 void currentValuesFromKeyPoints(float percent, float& effectivePercent, String& from, String& to) const;
122 float calculatePercentForSpline(float percent, unsigned splineIndex) const;
123 unsigned calculateKeyTimesIndex(float percent) const;
125 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGAnimationElement)
126 DECLARE_ANIMATED_BOOLEAN(ExternalResourcesRequired, externalResourcesRequired)
127 END_DECLARE_ANIMATED_PROPERTIES
130 virtual void synchronizeRequiredFeatures() { SVGTests::synchronizeRequiredFeatures(this); }
131 virtual void synchronizeRequiredExtensions() { SVGTests::synchronizeRequiredExtensions(this); }
132 virtual void synchronizeSystemLanguage() { SVGTests::synchronizeSystemLanguage(this); }
134 bool m_animationValid;
136 Vector<String> m_values;
137 Vector<float> m_keyTimes;
138 Vector<float> m_keyPoints;
139 Vector<UnitBezier> m_keySplines;
140 String m_lastValuesAnimationFrom;
141 String m_lastValuesAnimationTo;
144 } // namespace WebCore
146 #endif // ENABLE(SVG)
147 #endif // SVGAnimationElement_h