initial import
[vuplus_webkit] / Source / WebCore / svg / SVGAnimateElement.h
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 #if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
27
28 #include "SVGAnimatedType.h"
29 #include "SVGAnimatedTypeAnimator.h"
30 #include "SVGAnimationElement.h"
31 #include <wtf/OwnPtr.h>
32
33 namespace WebCore {
34     
35 // If we have 'currentColor' or 'inherit' as animation value, we need to grab the value during the animation
36 // since the value can be animated itself.
37 enum AnimatedPropertyValueType {
38     RegularPropertyValue,
39     CurrentColorValue,
40     InheritValue
41 };
42
43 class SVGAnimateElement : public SVGAnimationElement {
44 public:
45     static PassRefPtr<SVGAnimateElement> create(const QualifiedName&, Document*);
46
47     virtual ~SVGAnimateElement();
48     
49     static void adjustForCurrentColor(SVGElement* targetElement, Color&);
50     void adjustForInheritance(SVGElement* targetElement, const QualifiedName&, String& value);
51     
52     AnimatedPropertyType determineAnimatedPropertyType(SVGElement*) const;
53     void determinePropertyValueTypes(const String&, const String&);
54     
55     AnimatedPropertyValueType fromPropertyValueType() { return m_fromPropertyValueType; }
56     AnimatedPropertyValueType toPropertyValueType() { return m_toPropertyValueType; }
57
58 protected:
59     SVGAnimateElement(const QualifiedName&, Document*);
60
61     virtual void resetToBaseValue(const String&);
62     virtual bool calculateFromAndToValues(const String& fromString, const String& toString);
63     virtual bool calculateFromAndByValues(const String& fromString, const String& byString);
64     virtual void calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement);
65     virtual void applyResultsToTarget();
66     virtual float calculateDistance(const String& fromString, const String& toString);
67
68 private:
69     SVGAnimatedTypeAnimator* ensureAnimator();
70     
71     virtual bool hasValidAttributeType();
72     AnimatedPropertyType m_animatedPropertyType;
73
74     AnimatedPropertyValueType m_fromPropertyValueType;
75     AnimatedPropertyValueType m_toPropertyValueType;
76
77     OwnPtr<SVGAnimatedType> m_fromType;
78     OwnPtr<SVGAnimatedType> m_toType;
79     OwnPtr<SVGAnimatedType> m_animatedType;
80     
81     OwnPtr<SVGAnimatedTypeAnimator> m_animator;
82 };
83
84 } // namespace WebCore
85
86 #endif // ENABLE(SVG)
87 #endif // SVGAnimateElement_h