2
* Copyright (C) Research In Motion Limited 2012. 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.
23
#include "SVGAnimatedIntegerOptionalInteger.h"
25
#include "SVGAnimateElement.h"
26
#include "SVGAnimatedInteger.h"
27
#include "SVGParserUtilities.h"
31
SVGAnimatedIntegerOptionalIntegerAnimator::SVGAnimatedIntegerOptionalIntegerAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
32
: SVGAnimatedTypeAnimator(AnimatedIntegerOptionalInteger, animationElement, contextElement)
36
PassOwnPtr<SVGAnimatedType> SVGAnimatedIntegerOptionalIntegerAnimator::constructFromString(const String& string)
38
OwnPtr<SVGAnimatedType> animtedType = SVGAnimatedType::createIntegerOptionalInteger(new pair<int, int>);
39
pair<int, int>& animatedInteger = animtedType->integerOptionalInteger();
40
float firstNumber = 0;
41
float secondNumber = 0;
42
if (!parseNumberOptionalNumber(string, firstNumber, secondNumber)) {
43
animatedInteger.first = 0;
44
animatedInteger.second = 0;
46
animatedInteger.first = static_cast<int>(roundf(firstNumber));
47
animatedInteger.second = static_cast<int>(roundf(secondNumber));
49
return animtedType.release();
52
PassOwnPtr<SVGAnimatedType> SVGAnimatedIntegerOptionalIntegerAnimator::startAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
54
return SVGAnimatedType::createIntegerOptionalInteger(constructFromBaseValues<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes));
57
void SVGAnimatedIntegerOptionalIntegerAnimator::stopAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
59
stopAnimValAnimationForTypes<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes);
62
void SVGAnimatedIntegerOptionalIntegerAnimator::resetAnimValToBaseVal(const SVGElementAnimatedPropertyList& animatedTypes, SVGAnimatedType* type)
64
resetFromBaseValues<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes, type, &SVGAnimatedType::integerOptionalInteger);
67
void SVGAnimatedIntegerOptionalIntegerAnimator::animValWillChange(const SVGElementAnimatedPropertyList& animatedTypes)
69
animValWillChangeForTypes<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes);
72
void SVGAnimatedIntegerOptionalIntegerAnimator::animValDidChange(const SVGElementAnimatedPropertyList& animatedTypes)
74
animValDidChangeForTypes<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes);
77
void SVGAnimatedIntegerOptionalIntegerAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAnimatedType* to)
79
ASSERT(from->type() == AnimatedIntegerOptionalInteger);
80
ASSERT(from->type() == to->type());
82
const pair<int, int>& fromIntegerPair = from->integerOptionalInteger();
83
pair<int, int>& toIntegerPair = to->integerOptionalInteger();
85
toIntegerPair.first += fromIntegerPair.first;
86
toIntegerPair.second += fromIntegerPair.second;
89
void SVGAnimatedIntegerOptionalIntegerAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEndOfDuration, SVGAnimatedType* animated)
91
ASSERT(m_animationElement);
92
ASSERT(m_contextElement);
94
const pair<int, int>& fromIntegerPair = m_animationElement->animationMode() == ToAnimation ? animated->integerOptionalInteger() : from->integerOptionalInteger();
95
const pair<int, int>& toIntegerPair = to->integerOptionalInteger();
96
const pair<int, int>& toAtEndOfDurationIntegerPair = toAtEndOfDuration->integerOptionalInteger();
97
pair<int, int>& animatedIntegerPair = animated->integerOptionalInteger();
99
SVGAnimatedIntegerAnimator::calculateAnimatedInteger(m_animationElement, percentage, repeatCount, fromIntegerPair.first, toIntegerPair.first, toAtEndOfDurationIntegerPair.first, animatedIntegerPair.first);
100
SVGAnimatedIntegerAnimator::calculateAnimatedInteger(m_animationElement, percentage, repeatCount, fromIntegerPair.second, toIntegerPair.second, toAtEndOfDurationIntegerPair.second, animatedIntegerPair.second);
103
float SVGAnimatedIntegerOptionalIntegerAnimator::calculateDistance(const String&, const String&)
105
// FIXME: Distance calculation is not possible for SVGIntegerOptionalInteger right now. We need the distance for every single value.
111
#endif // ENABLE(SVG)