2 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
3 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
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.
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.
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.
21 #ifndef SVGAnimatedTypeAnimator_h
22 #define SVGAnimatedTypeAnimator_h
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"
33 class SVGAnimatedPropertyBase;
34 class SVGPropertyBase;
36 class SVGAnimationElement;
38 class SVGAnimatedTypeAnimator final : public NoBaseWillBeGarbageCollectedFinalized<SVGAnimatedTypeAnimator> {
39 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
41 static PassOwnPtrWillBeRawPtr<SVGAnimatedTypeAnimator> create(SVGAnimationElement* animationElement, SVGElement* targetElement)
43 return adoptPtrWillBeNoop(new SVGAnimatedTypeAnimator(animationElement, targetElement));
45 ~SVGAnimatedTypeAnimator();
47 PassRefPtr<SVGPropertyBase> constructFromString(const String&);
49 PassRefPtr<SVGPropertyBase> startAnimValAnimation(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >&);
50 void stopAnimValAnimation(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >&);
51 PassRefPtr<SVGPropertyBase> resetAnimValToBaseVal(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >&);
53 void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGPropertyBase*, SVGPropertyBase*, SVGPropertyBase*, SVGPropertyBase*);
54 float calculateDistance(const String& fromString, const String& toString);
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);
59 void setContextElement(SVGElement* contextElement) { m_contextElement = contextElement; }
60 AnimatedPropertyType type() const { return m_type; }
62 bool isAnimatingSVGDom() const { return m_animatedProperty; }
63 bool isAnimatingCSSProperty() const { return !m_animatedProperty; }
68 SVGAnimatedTypeAnimator(SVGAnimationElement*, SVGElement*);
70 friend class ParsePropertyFromString;
71 PassRefPtr<SVGPropertyBase> createPropertyForAnimation(const String&);
72 PassRefPtr<SVGPropertyBase> resetAnimation(const WillBeHeapVector<RawPtrWillBeMember<SVGElement> >&);
74 AnimatedPropertyType m_type;
75 RawPtrWillBeMember<SVGAnimationElement> m_animationElement;
76 RawPtrWillBeMember<SVGElement> m_contextElement;
77 RefPtr<SVGAnimatedPropertyBase> m_animatedProperty;
82 #endif // SVGAnimatedTypeAnimator_h