~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/svg/SVGAnimatedIntegerOptionalInteger.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) Research In Motion Limited 2012. 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
#if ENABLE(SVG)
 
23
#include "SVGAnimatedIntegerOptionalInteger.h"
 
24
 
 
25
#include "SVGAnimateElement.h"
 
26
#include "SVGAnimatedInteger.h"
 
27
#include "SVGParserUtilities.h"
 
28
 
 
29
namespace WebCore {
 
30
 
 
31
SVGAnimatedIntegerOptionalIntegerAnimator::SVGAnimatedIntegerOptionalIntegerAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
 
32
    : SVGAnimatedTypeAnimator(AnimatedIntegerOptionalInteger, animationElement, contextElement)
 
33
{
 
34
}
 
35
 
 
36
PassOwnPtr<SVGAnimatedType> SVGAnimatedIntegerOptionalIntegerAnimator::constructFromString(const String& string)
 
37
{
 
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;
 
45
    } else {
 
46
        animatedInteger.first = static_cast<int>(roundf(firstNumber));
 
47
        animatedInteger.second = static_cast<int>(roundf(secondNumber));
 
48
    }
 
49
    return animtedType.release();
 
50
}
 
51
 
 
52
PassOwnPtr<SVGAnimatedType> SVGAnimatedIntegerOptionalIntegerAnimator::startAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
 
53
{
 
54
    return SVGAnimatedType::createIntegerOptionalInteger(constructFromBaseValues<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes));
 
55
}
 
56
 
 
57
void SVGAnimatedIntegerOptionalIntegerAnimator::stopAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
 
58
{
 
59
    stopAnimValAnimationForTypes<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes);
 
60
}
 
61
 
 
62
void SVGAnimatedIntegerOptionalIntegerAnimator::resetAnimValToBaseVal(const SVGElementAnimatedPropertyList& animatedTypes, SVGAnimatedType* type)
 
63
{
 
64
    resetFromBaseValues<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes, type, &SVGAnimatedType::integerOptionalInteger);
 
65
}
 
66
 
 
67
void SVGAnimatedIntegerOptionalIntegerAnimator::animValWillChange(const SVGElementAnimatedPropertyList& animatedTypes)
 
68
{
 
69
    animValWillChangeForTypes<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes);
 
70
}
 
71
 
 
72
void SVGAnimatedIntegerOptionalIntegerAnimator::animValDidChange(const SVGElementAnimatedPropertyList& animatedTypes)
 
73
{
 
74
    animValDidChangeForTypes<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes);
 
75
}
 
76
 
 
77
void SVGAnimatedIntegerOptionalIntegerAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAnimatedType* to)
 
78
{
 
79
    ASSERT(from->type() == AnimatedIntegerOptionalInteger);
 
80
    ASSERT(from->type() == to->type());
 
81
 
 
82
    const pair<int, int>& fromIntegerPair = from->integerOptionalInteger();
 
83
    pair<int, int>& toIntegerPair = to->integerOptionalInteger();
 
84
 
 
85
    toIntegerPair.first += fromIntegerPair.first;
 
86
    toIntegerPair.second += fromIntegerPair.second;
 
87
}
 
88
 
 
89
void SVGAnimatedIntegerOptionalIntegerAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEndOfDuration, SVGAnimatedType* animated)
 
90
{
 
91
    ASSERT(m_animationElement);
 
92
    ASSERT(m_contextElement);
 
93
 
 
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();
 
98
 
 
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);
 
101
}
 
102
 
 
103
float SVGAnimatedIntegerOptionalIntegerAnimator::calculateDistance(const String&, const String&)
 
104
{
 
105
    // FIXME: Distance calculation is not possible for SVGIntegerOptionalInteger right now. We need the distance for every single value.
 
106
    return -1;
 
107
}
 
108
 
 
109
}
 
110
 
 
111
#endif // ENABLE(SVG)