2 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
22 #if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
23 #include "SVGAnimatedString.h"
25 #include "SVGAnimateElement.h"
29 SVGAnimatedStringAnimator::SVGAnimatedStringAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
30 : SVGAnimatedTypeAnimator(AnimatedString, animationElement, contextElement)
34 PassOwnPtr<SVGAnimatedType> SVGAnimatedStringAnimator::constructFromString(const String& string)
36 OwnPtr<SVGAnimatedType> animatedType = SVGAnimatedType::createString(new String);
37 animatedType->string() = string;
38 return animatedType.release();
41 void SVGAnimatedStringAnimator::calculateFromAndToValues(OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, const String& fromString, const String& toString)
43 ASSERT(m_contextElement);
44 ASSERT(m_animationElement);
46 from = constructFromString(fromString);
47 to = constructFromString(toString);
50 void SVGAnimatedStringAnimator::calculateFromAndByValues(OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, const String& fromString, const String& byString)
52 ASSERT(m_contextElement);
53 ASSERT(m_animationElement);
55 // Not specified what to do on 'by'-animations with string. Fallback to 'to'-animation right now.
56 from = constructFromString(fromString);
57 to = constructFromString(byString);
60 void SVGAnimatedStringAnimator::calculateAnimatedValue(float percentage, unsigned,
61 OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, OwnPtr<SVGAnimatedType>& animated)
63 ASSERT(m_animationElement);
64 ASSERT(m_contextElement);
65 SVGAnimateElement* animationElement = static_cast<SVGAnimateElement*>(m_animationElement);
67 AnimationMode animationMode = animationElement->animationMode();
68 String& animateString = animated->string();
69 if ((animationMode == FromToAnimation && percentage > 0.5) || animationMode == ToAnimation || percentage == 1)
70 animateString = to->string();
72 animateString = from->string();
75 float SVGAnimatedStringAnimator::calculateDistance(const String&, const String&)
77 // No paced animations for strings.
83 #endif // ENABLE(SVG) && ENABLE(SVG_ANIMATION)