• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
4  * Copyright (C) 2008 Apple Inc. All rights reserved.
5  * Copyright (C) Research In Motion Limited 2011. All rights reserved.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef SVGAnimateElement_h
24 #define SVGAnimateElement_h
25 
26 #include "SVGNames.h"
27 #include "core/svg/SVGAnimationElement.h"
28 #include "wtf/OwnPtr.h"
29 
30 namespace WebCore {
31 
32 class SVGAnimatedProperty;
33 class SVGAnimatedType;
34 class SVGAnimatedTypeAnimator;
35 
36 class SVGAnimateElement : public SVGAnimationElement {
37 public:
38     static PassRefPtr<SVGAnimateElement> create(Document&);
39     virtual ~SVGAnimateElement();
40 
41     AnimatedPropertyType determineAnimatedPropertyType(SVGElement*) const;
42 
43 protected:
44     SVGAnimateElement(const QualifiedName&, Document&);
45 
46     virtual void resetAnimatedType();
47     virtual void clearAnimatedType(SVGElement* targetElement);
48 
49     virtual bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString);
50     virtual bool calculateFromAndToValues(const String& fromString, const String& toString);
51     virtual bool calculateFromAndByValues(const String& fromString, const String& byString);
52     virtual void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement);
53     virtual void applyResultsToTarget();
54     virtual float calculateDistance(const String& fromString, const String& toString);
55     virtual bool isAdditive() const OVERRIDE;
56 
57     virtual void setTargetElement(SVGElement*) OVERRIDE;
58     virtual void setAttributeName(const QualifiedName&) OVERRIDE;
59 
60     AnimatedPropertyType m_animatedPropertyType;
61 
62 private:
63     void resetAnimatedPropertyType();
64     SVGAnimatedTypeAnimator* ensureAnimator();
65     bool animatedPropertyTypeSupportsAddition() const;
66 
67     virtual bool hasValidAttributeType();
68 
69     OwnPtr<SVGAnimatedType> m_fromType;
70     OwnPtr<SVGAnimatedType> m_toType;
71     OwnPtr<SVGAnimatedType> m_toAtEndOfDurationType;
72     OwnPtr<SVGAnimatedType> m_animatedType;
73 
74     SVGElementAnimatedPropertyList m_animatedProperties;
75     OwnPtr<SVGAnimatedTypeAnimator> m_animator;
76 };
77 
isSVGAnimateElement(const Node & node)78 inline bool isSVGAnimateElement(const Node& node)
79 {
80     return node.hasTagName(SVGNames::animateTag)
81         || node.hasTagName(SVGNames::animateColorTag)
82         || node.hasTagName(SVGNames::animateTransformTag)
83         || node.hasTagName(SVGNames::setTag);
84 }
85 
86 DEFINE_NODE_TYPE_CASTS_WITH_FUNCTION(SVGAnimateElement);
87 
88 } // namespace WebCore
89 
90 #endif // SVGAnimateElement_h
91