Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / svg / SVGAnimatedTypeAnimator.h
1 /*
2  * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
3  * Copyright (C) 2013 Samsung Electronics. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef SVGAnimatedTypeAnimator_h
22 #define SVGAnimatedTypeAnimator_h
23
24 #include "core/svg/properties/SVGPropertyInfo.h"
25 #include "platform/heap/Handle.h"
26 #include "wtf/PassOwnPtr.h"
27 #include "wtf/RefPtr.h"
28 #include "wtf/Vector.h"
29 #include "wtf/text/WTFString.h"
30
31 namespace blink {
32
33 class SVGAnimatedPropertyBase;
34 class SVGPropertyBase;
35 class SVGElement;
36 class SVGAnimationElement;
37
38 class SVGAnimatedTypeAnimator final : public NoBaseWillBeGarbageCollectedFinalized<SVGAnimatedTypeAnimator> {
39     WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
40 public:
41     static PassOwnPtrWillBeRawPtr<SVGAnimatedTypeAnimator> create(SVGAnimationElement* animationElement, SVGElement* targetElement)
42     {
43         return adoptPtrWillBeNoop(new SVGAnimatedTypeAnimator(animationElement, targetElement));
44     }
45     ~SVGAnimatedTypeAnimator();
46
47     PassRefPtr<SVGPropertyBase> constructFromString(const String&);
48
49     PassRefPtr<SVGPropertyBase> startAnimValAnimation(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >&);
50     void stopAnimValAnimation(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >&);
51     PassRefPtr<SVGPropertyBase> resetAnimValToBaseVal(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >&);
52
53     void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGPropertyBase*, SVGPropertyBase*, SVGPropertyBase*, SVGPropertyBase*);
54     float calculateDistance(const String& fromString, const String& toString);
55
56     void calculateFromAndToValues(RefPtr<SVGPropertyBase>& from, RefPtr<SVGPropertyBase>& to, const String& fromString, const String& toString);
57     void calculateFromAndByValues(RefPtr<SVGPropertyBase>& from, RefPtr<SVGPropertyBase>& to, const String& fromString, const String& byString);
58
59     void setContextElement(SVGElement* contextElement) { m_contextElement = contextElement; }
60     AnimatedPropertyType type() const { return m_type; }
61
62     bool isAnimatingSVGDom() const { return m_animatedProperty; }
63     bool isAnimatingCSSProperty() const { return !m_animatedProperty; }
64
65     void trace(Visitor*);
66
67 private:
68     SVGAnimatedTypeAnimator(SVGAnimationElement*, SVGElement*);
69
70     friend class ParsePropertyFromString;
71     PassRefPtr<SVGPropertyBase> createPropertyForAnimation(const String&);
72     PassRefPtr<SVGPropertyBase> resetAnimation(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >&);
73
74     AnimatedPropertyType m_type;
75     RawPtrWillBeMember<SVGAnimationElement> m_animationElement;
76     RawPtrWillBeMember<SVGElement> m_contextElement;
77     RefPtr<SVGAnimatedPropertyBase> m_animatedProperty;
78 };
79
80 } // namespace blink
81
82 #endif // SVGAnimatedTypeAnimator_h