OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 18 matching lines...) Expand all Loading... |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/svg/SVGIntegerOptionalInteger.h" | 32 #include "core/svg/SVGIntegerOptionalInteger.h" |
33 | 33 |
34 #include "core/svg/SVGAnimationElement.h" | 34 #include "core/svg/SVGAnimationElement.h" |
35 #include "core/svg/SVGParserUtilities.h" | 35 #include "core/svg/SVGParserUtilities.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 SVGIntegerOptionalInteger::SVGIntegerOptionalInteger(PassRefPtr<SVGInteger> firs
tInteger, PassRefPtr<SVGInteger> secondInteger) | 39 SVGIntegerOptionalInteger::SVGIntegerOptionalInteger(PassRefPtrWillBeRawPtr<SVGI
nteger> firstInteger, PassRefPtrWillBeRawPtr<SVGInteger> secondInteger) |
40 : SVGPropertyBase(classType()) | 40 : SVGPropertyBase(classType()) |
41 , m_firstInteger(firstInteger) | 41 , m_firstInteger(firstInteger) |
42 , m_secondInteger(secondInteger) | 42 , m_secondInteger(secondInteger) |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 PassRefPtr<SVGIntegerOptionalInteger> SVGIntegerOptionalInteger::clone() const | 46 void SVGIntegerOptionalInteger::trace(Visitor* visitor) |
| 47 { |
| 48 visitor->trace(m_firstInteger); |
| 49 visitor->trace(m_secondInteger); |
| 50 SVGPropertyBase::trace(visitor); |
| 51 } |
| 52 |
| 53 PassRefPtrWillBeRawPtr<SVGIntegerOptionalInteger> SVGIntegerOptionalInteger::clo
ne() const |
47 { | 54 { |
48 return SVGIntegerOptionalInteger::create(m_firstInteger->clone(), m_secondIn
teger->clone()); | 55 return SVGIntegerOptionalInteger::create(m_firstInteger->clone(), m_secondIn
teger->clone()); |
49 } | 56 } |
50 | 57 |
51 PassRefPtr<SVGPropertyBase> SVGIntegerOptionalInteger::cloneForAnimation(const S
tring& value) const | 58 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGIntegerOptionalInteger::cloneForAnima
tion(const String& value) const |
52 { | 59 { |
53 float floatX, floatY; | 60 float floatX, floatY; |
54 if (!parseNumberOptionalNumber(value, floatX, floatY)) { | 61 if (!parseNumberOptionalNumber(value, floatX, floatY)) { |
55 return SVGIntegerOptionalInteger::create(SVGInteger::create(0), SVGInteg
er::create(0)); | 62 return SVGIntegerOptionalInteger::create(SVGInteger::create(0), SVGInteg
er::create(0)); |
56 } | 63 } |
57 | 64 |
58 int x = static_cast<int>(roundf(floatX)); | 65 int x = static_cast<int>(roundf(floatX)); |
59 int y = static_cast<int>(roundf(floatY)); | 66 int y = static_cast<int>(roundf(floatY)); |
60 | 67 |
61 return SVGIntegerOptionalInteger::create(SVGInteger::create(x), SVGInteger::
create(y)); | 68 return SVGIntegerOptionalInteger::create(SVGInteger::create(x), SVGInteger::
create(y)); |
(...skipping 15 matching lines...) Expand all Loading... |
77 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
value + "') is invalid."); | 84 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
value + "') is invalid."); |
78 x = y = 0; | 85 x = y = 0; |
79 } | 86 } |
80 | 87 |
81 m_firstInteger->setValue(x); | 88 m_firstInteger->setValue(x); |
82 m_secondInteger->setValue(y); | 89 m_secondInteger->setValue(y); |
83 } | 90 } |
84 | 91 |
85 void SVGIntegerOptionalInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> othe
r, SVGElement*) | 92 void SVGIntegerOptionalInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> othe
r, SVGElement*) |
86 { | 93 { |
87 RefPtr<SVGIntegerOptionalInteger> otherIntegerOptionalInteger = toSVGInteger
OptionalInteger(other); | 94 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> otherIntegerOptionalInteger =
toSVGIntegerOptionalInteger(other); |
88 | 95 |
89 m_firstInteger->setValue(m_firstInteger->value() + otherIntegerOptionalInteg
er->m_firstInteger->value()); | 96 m_firstInteger->setValue(m_firstInteger->value() + otherIntegerOptionalInteg
er->m_firstInteger->value()); |
90 m_secondInteger->setValue(m_secondInteger->value() + otherIntegerOptionalInt
eger->m_secondInteger->value()); | 97 m_secondInteger->setValue(m_secondInteger->value() + otherIntegerOptionalInt
eger->m_secondInteger->value()); |
91 } | 98 } |
92 | 99 |
93 void SVGIntegerOptionalInteger::calculateAnimatedValue(SVGAnimationElement* anim
ationElement, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase
> from, PassRefPtr<SVGPropertyBase> to, PassRefPtr<SVGPropertyBase> toAtEndOfDur
ation, SVGElement*) | 100 void SVGIntegerOptionalInteger::calculateAnimatedValue(SVGAnimationElement* anim
ationElement, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVG
PropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBe
RawPtr<SVGPropertyBase> toAtEndOfDuration, SVGElement*) |
94 { | 101 { |
95 ASSERT(animationElement); | 102 ASSERT(animationElement); |
96 | 103 |
97 RefPtr<SVGIntegerOptionalInteger> fromInteger = toSVGIntegerOptionalInteger(
from); | 104 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> fromInteger = toSVGIntegerOpti
onalInteger(from); |
98 RefPtr<SVGIntegerOptionalInteger> toInteger = toSVGIntegerOptionalInteger(to
); | 105 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> toInteger = toSVGIntegerOption
alInteger(to); |
99 RefPtr<SVGIntegerOptionalInteger> toAtEndOfDurationInteger = toSVGIntegerOpt
ionalInteger(toAtEndOfDuration); | 106 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> toAtEndOfDurationInteger = toS
VGIntegerOptionalInteger(toAtEndOfDuration); |
100 | 107 |
101 float x = m_firstInteger->value(); | 108 float x = m_firstInteger->value(); |
102 float y = m_secondInteger->value(); | 109 float y = m_secondInteger->value(); |
103 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->firstInteger()->value(), toInteger->firstInteger()->value(), toAtEndOfDuration
Integer->firstInteger()->value(), x); | 110 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->firstInteger()->value(), toInteger->firstInteger()->value(), toAtEndOfDuration
Integer->firstInteger()->value(), x); |
104 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->secondInteger()->value(), toInteger->secondInteger()->value(), toAtEndOfDurati
onInteger->secondInteger()->value(), y); | 111 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->secondInteger()->value(), toInteger->secondInteger()->value(), toAtEndOfDurati
onInteger->secondInteger()->value(), y); |
105 m_firstInteger->setValue(static_cast<int>(roundf(x))); | 112 m_firstInteger->setValue(static_cast<int>(roundf(x))); |
106 m_secondInteger->setValue(static_cast<int>(roundf(y))); | 113 m_secondInteger->setValue(static_cast<int>(roundf(y))); |
107 } | 114 } |
108 | 115 |
109 float SVGIntegerOptionalInteger::calculateDistance(PassRefPtr<SVGPropertyBase> o
ther, SVGElement*) | 116 float SVGIntegerOptionalInteger::calculateDistance(PassRefPtrWillBeRawPtr<SVGPro
pertyBase> other, SVGElement*) |
110 { | 117 { |
111 // FIXME: Distance calculation is not possible for SVGIntegerOptionalInteger
right now. We need the distance for every single value. | 118 // FIXME: Distance calculation is not possible for SVGIntegerOptionalInteger
right now. We need the distance for every single value. |
112 return -1; | 119 return -1; |
113 } | 120 } |
114 | 121 |
115 } | 122 } |
OLD | NEW |