| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | |
| 3 * | |
| 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. | |
| 8 * | |
| 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. | |
| 13 * | |
| 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. | |
| 18 */ | |
| 19 | |
| 20 #include "config.h" | |
| 21 | |
| 22 #include "core/svg/SVGAnimatedRect.h" | |
| 23 | |
| 24 #include "core/svg/SVGAnimateElement.h" | |
| 25 #include "core/svg/SVGParserUtilities.h" | |
| 26 | |
| 27 namespace WebCore { | |
| 28 | |
| 29 SVGAnimatedRectAnimator::SVGAnimatedRectAnimator(SVGAnimationElement* animationE
lement, SVGElement* contextElement) | |
| 30 : SVGAnimatedTypeAnimator(AnimatedRect, animationElement, contextElement) | |
| 31 { | |
| 32 } | |
| 33 | |
| 34 PassOwnPtr<SVGAnimatedType> SVGAnimatedRectAnimator::constructFromString(const S
tring& string) | |
| 35 { | |
| 36 OwnPtr<SVGAnimatedType> animatedType = SVGAnimatedType::createRect(new SVGRe
ct); | |
| 37 parseRect(string, animatedType->rect()); | |
| 38 return animatedType.release(); | |
| 39 } | |
| 40 | |
| 41 PassOwnPtr<SVGAnimatedType> SVGAnimatedRectAnimator::startAnimValAnimation(const
SVGElementAnimatedPropertyList& animatedTypes) | |
| 42 { | |
| 43 return SVGAnimatedType::createRect(constructFromBaseValue<SVGAnimatedRect>(a
nimatedTypes)); | |
| 44 } | |
| 45 | |
| 46 void SVGAnimatedRectAnimator::stopAnimValAnimation(const SVGElementAnimatedPrope
rtyList& animatedTypes) | |
| 47 { | |
| 48 stopAnimValAnimationForType<SVGAnimatedRect>(animatedTypes); | |
| 49 } | |
| 50 | |
| 51 void SVGAnimatedRectAnimator::resetAnimValToBaseVal(const SVGElementAnimatedProp
ertyList& animatedTypes, SVGAnimatedType* type) | |
| 52 { | |
| 53 resetFromBaseValue<SVGAnimatedRect>(animatedTypes, type, &SVGAnimatedType::r
ect); | |
| 54 } | |
| 55 | |
| 56 void SVGAnimatedRectAnimator::animValWillChange(const SVGElementAnimatedProperty
List& animatedTypes) | |
| 57 { | |
| 58 animValWillChangeForType<SVGAnimatedRect>(animatedTypes); | |
| 59 } | |
| 60 | |
| 61 void SVGAnimatedRectAnimator::animValDidChange(const SVGElementAnimatedPropertyL
ist& animatedTypes) | |
| 62 { | |
| 63 animValDidChangeForType<SVGAnimatedRect>(animatedTypes); | |
| 64 } | |
| 65 | |
| 66 void SVGAnimatedRectAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAnimate
dType* to) | |
| 67 { | |
| 68 ASSERT(from->type() == AnimatedRect); | |
| 69 ASSERT(from->type() == to->type()); | |
| 70 | |
| 71 to->rect() += from->rect(); | |
| 72 } | |
| 73 | |
| 74 void SVGAnimatedRectAnimator::calculateAnimatedValue(float percentage, unsigned
repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEn
dOfDuration, SVGAnimatedType* animated) | |
| 75 { | |
| 76 ASSERT(m_animationElement); | |
| 77 ASSERT(m_contextElement); | |
| 78 | |
| 79 const SVGRect& fromRect = m_animationElement->animationMode() == ToAnimation
? animated->rect() : from->rect(); | |
| 80 const SVGRect& toRect = to->rect(); | |
| 81 const SVGRect& toAtEndOfDurationRect = toAtEndOfDuration->rect(); | |
| 82 SVGRect& animatedRect = animated->rect(); | |
| 83 | |
| 84 float animatedX = animatedRect.x(); | |
| 85 float animatedY = animatedRect.y(); | |
| 86 float animatedWidth = animatedRect.width(); | |
| 87 float animatedHeight = animatedRect.height(); | |
| 88 m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromRect.
x(), toRect.x(), toAtEndOfDurationRect.x(), animatedX); | |
| 89 m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromRect.
y(), toRect.y(), toAtEndOfDurationRect.y(), animatedY); | |
| 90 m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromRect.
width(), toRect.width(), toAtEndOfDurationRect.width(), animatedWidth); | |
| 91 m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromRect.
height(), toRect.height(), toAtEndOfDurationRect.height(), animatedHeight); | |
| 92 | |
| 93 animatedRect = SVGRect(animatedX, animatedY, animatedWidth, animatedHeight); | |
| 94 } | |
| 95 | |
| 96 float SVGAnimatedRectAnimator::calculateDistance(const String&, const String&) | |
| 97 { | |
| 98 // FIXME: Distance calculation is not possible for SVGRect right now. We nee
d the distance of for every single value. | |
| 99 return -1; | |
| 100 } | |
| 101 | |
| 102 } | |
| OLD | NEW |