KHtml

SVGAnimationElement.h
1 /*
2  Copyright (C) 2004, 2005 Nikolas Zimmermann <[email protected]>
3  2004, 2005, 2006 Rob Buis <[email protected]>
4  Copyright (C) 2007 Eric Seidel <[email protected]>
5  Copyright (C) 2008 Apple Inc. All rights reserved.
6 
7  This file is part of the KDE project
8 
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.
13 
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.
18 
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.
23 */
24 
25 #ifndef SVGAnimationElement_h
26 #define SVGAnimationElement_h
27 #if ENABLE(SVG_ANIMATION)
28 
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"
37 
38 namespace WebCore
39 {
40 
41 class ConditionEventListener;
42 class TimeContainer;
43 
44 class SVGAnimationElement : public SVGSMILElement,
45  public SVGTests,
46  public SVGExternalResourcesRequired,
47  public ElementTimeControl
48 {
49 public:
50  SVGAnimationElement(const QualifiedName &, Document *);
51  virtual ~SVGAnimationElement();
52 
53  virtual void parseMappedAttribute(MappedAttribute *);
54  virtual void attributeChanged(Attribute *, bool preserveDecls);
55 
56  // SVGAnimationElement
57  float getStartTime() const;
58  float getCurrentTime() const;
59  float getSimpleDuration(ExceptionCode &) const;
60 
61  // ElementTimeControl
62  virtual bool beginElement(ExceptionCode &);
63  virtual bool beginElementAt(float offset, ExceptionCode &);
64  virtual bool endElement(ExceptionCode &);
65  virtual bool endElementAt(float offset, ExceptionCode &);
66 
67  static bool attributeIsCSS(const String &attributeName);
68 
69 protected:
70 
71  enum CalcMode { CalcModeDiscrete, CalcModeLinear, CalcModePaced, CalcModeSpline };
72  CalcMode calcMode() const;
73 
74  enum AttributeType { AttributeTypeCSS, AttributeTypeXML, AttributeTypeAuto };
75  AttributeType attributeType() const;
76 
77  String toValue() const;
78  String byValue() const;
79  String fromValue() const;
80 
81  enum AnimationMode { NoAnimation, ToAnimation, ByAnimation, ValuesAnimation, FromToAnimation, FromByAnimation, PathAnimation };
82  AnimationMode animationMode() const;
83 
84  virtual bool hasValidTarget() const;
85 
86  String targetAttributeBaseValue() const;
87  void setTargetAttributeAnimatedValue(const String &);
88  bool targetAttributeIsCSS() const;
89 
90  bool isAdditive() const;
91  bool isAccumulated() const;
92 
93  // from SVGSMILElement
94  virtual void startedActiveInterval();
95  virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement *resultElement);
96  virtual void endedActiveInterval();
97 
98  ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
99 private:
100  virtual bool calculateFromAndToValues(const String &fromString, const String &toString) = 0;
101  virtual bool calculateFromAndByValues(const String &fromString, const String &byString) = 0;
102  virtual void calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement *resultElement) = 0;
103  virtual float calculateDistance(const String &fromString, const String &toString)
104  {
105  return -1.f;
106  }
107  virtual Path animationPath() const
108  {
109  return Path();
110  }
111 
112  void currentValuesForValuesAnimation(float percent, float &effectivePercent, String &from, String &to) const;
113  void calculateKeyTimesForCalcModePaced();
114  float calculatePercentFromKeyPoints(float percent) const;
115  void currentValuesFromKeyPoints(float percent, float &effectivePercent, String &from, String &to) const;
116  float calculatePercentForSpline(float percent, unsigned splineIndex) const;
117 
118 protected:
119  bool m_animationValid;
120 
121  Vector<String> m_values;
122  Vector<float> m_keyTimes;
123  Vector<float> m_keyPoints;
124  Vector<UnitBezier> m_keySplines;
125  String m_lastValuesAnimationFrom;
126  String m_lastValuesAnimationTo;
127 };
128 
129 } // namespace WebCore
130 
131 #endif // ENABLE(SVG)
132 #endif // SVGAnimationElement_h
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.