OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NumberOptionalNumberSVGInterpolation_h | 5 #ifndef NumberOptionalNumberSVGInterpolation_h |
6 #define NumberOptionalNumberSVGInterpolation_h | 6 #define NumberOptionalNumberSVGInterpolation_h |
7 | 7 |
8 #include "core/animation/SVGInterpolation.h" | 8 #include "core/animation/SVGInterpolation.h" |
9 #include "core/svg/SVGNumber.h" | 9 #include "core/svg/SVGNumber.h" |
10 #include "core/svg/SVGNumberOptionalNumber.h" | 10 #include "core/svg/SVGNumberOptionalNumber.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class SVGNumberOptionalNumber; | 14 class SVGNumberOptionalNumber; |
15 | 15 |
16 class NumberOptionalNumberSVGInterpolation : public SVGInterpolation { | 16 class NumberOptionalNumberSVGInterpolation : public SVGInterpolation { |
17 public: | 17 public: |
18 static PassRefPtrWillBeRawPtr<NumberOptionalNumberSVGInterpolation> create(S
VGPropertyBase* start, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedP
ropertyBase> attribute) | 18 static PassRefPtr<NumberOptionalNumberSVGInterpolation> create(SVGPropertyBa
se* start, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase>
attribute) |
19 { | 19 { |
20 return adoptRefWillBeNoop(new NumberOptionalNumberSVGInterpolation(toInt
erpolableValue(start), toInterpolableValue(end), attribute)); | 20 return adoptRef(new NumberOptionalNumberSVGInterpolation(toInterpolableV
alue(start), toInterpolableValue(end), attribute)); |
21 } | 21 } |
22 | 22 |
23 PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement&) const
final | 23 PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement&) const
final |
24 { | 24 { |
25 return fromInterpolableValue(*m_cachedValue); | 25 return fromInterpolableValue(*m_cachedValue); |
26 } | 26 } |
27 | 27 |
28 DEFINE_INLINE_VIRTUAL_TRACE() | |
29 { | |
30 SVGInterpolation::trace(visitor); | |
31 } | |
32 | |
33 private: | 28 private: |
34 NumberOptionalNumberSVGInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValu
e> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<
SVGAnimatedPropertyBase> attribute) | 29 NumberOptionalNumberSVGInterpolation(PassOwnPtr<InterpolableValue> start, Pa
ssOwnPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase>
attribute) |
35 : SVGInterpolation(start, end, attribute) | 30 : SVGInterpolation(start, end, attribute) |
36 { | 31 { |
37 } | 32 } |
38 | 33 |
39 static PassOwnPtrWillBeRawPtr<InterpolableValue> toInterpolableValue(SVGProp
ertyBase* value) | 34 static PassOwnPtr<InterpolableValue> toInterpolableValue(SVGPropertyBase* va
lue) |
40 { | 35 { |
41 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> numberOptionalNumber = toSVG
NumberOptionalNumber(value); | 36 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> numberOptionalNumber = toSVG
NumberOptionalNumber(value); |
42 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2
); | 37 OwnPtr<InterpolableList> result = InterpolableList::create(2); |
43 result->set(0, InterpolableNumber::create(numberOptionalNumber->firstNum
ber()->value())); | 38 result->set(0, InterpolableNumber::create(numberOptionalNumber->firstNum
ber()->value())); |
44 result->set(1, InterpolableNumber::create(numberOptionalNumber->secondNu
mber()->value())); | 39 result->set(1, InterpolableNumber::create(numberOptionalNumber->secondNu
mber()->value())); |
45 return result.release(); | 40 return result.release(); |
46 } | 41 } |
47 | 42 |
48 static PassRefPtrWillBeRawPtr<SVGNumberOptionalNumber> fromInterpolableValue
(const InterpolableValue& value) | 43 static PassRefPtrWillBeRawPtr<SVGNumberOptionalNumber> fromInterpolableValue
(const InterpolableValue& value) |
49 { | 44 { |
50 const InterpolableList& list = toInterpolableList(value); | 45 const InterpolableList& list = toInterpolableList(value); |
51 return SVGNumberOptionalNumber::create( | 46 return SVGNumberOptionalNumber::create( |
52 SVGNumber::create(toInterpolableNumber(list.get(0))->value()), | 47 SVGNumber::create(toInterpolableNumber(list.get(0))->value()), |
53 SVGNumber::create(toInterpolableNumber(list.get(1))->value())); | 48 SVGNumber::create(toInterpolableNumber(list.get(1))->value())); |
54 } | 49 } |
55 }; | 50 }; |
56 | 51 |
57 } | 52 } |
58 | 53 |
59 #endif // NumberOptionalNumberSVGInterpolation_h | 54 #endif // NumberOptionalNumberSVGInterpolation_h |
OLD | NEW |