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 NumberOptionalNumberSVGInterpolation* create(SVGPropertyBase* start,
SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute) |
19 { | 19 { |
20 return adoptRefWillBeNoop(new NumberOptionalNumberSVGInterpolation(toInt
erpolableValue(start), toInterpolableValue(end), attribute)); | 20 return new NumberOptionalNumberSVGInterpolation(toInterpolableValue(star
t), 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() | 28 DEFINE_INLINE_VIRTUAL_TRACE() |
29 { | 29 { |
30 SVGInterpolation::trace(visitor); | 30 SVGInterpolation::trace(visitor); |
31 } | 31 } |
32 | 32 |
33 private: | 33 private: |
34 NumberOptionalNumberSVGInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValu
e> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<
SVGAnimatedPropertyBase> attribute) | 34 NumberOptionalNumberSVGInterpolation(InterpolableValue* start, InterpolableV
alue* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute) |
35 : SVGInterpolation(start, end, attribute) | 35 : SVGInterpolation(start, end, attribute) |
36 { | 36 { |
37 } | 37 } |
38 | 38 |
39 static PassOwnPtrWillBeRawPtr<InterpolableValue> toInterpolableValue(SVGProp
ertyBase* value) | 39 static InterpolableValue* toInterpolableValue(SVGPropertyBase* value) |
40 { | 40 { |
41 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> numberOptionalNumber = toSVG
NumberOptionalNumber(value); | 41 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> numberOptionalNumber = toSVG
NumberOptionalNumber(value); |
42 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2
); | 42 InterpolableList* result = InterpolableList::create(2); |
43 result->set(0, InterpolableNumber::create(numberOptionalNumber->firstNum
ber()->value())); | 43 result->set(0, InterpolableNumber::create(numberOptionalNumber->firstNum
ber()->value())); |
44 result->set(1, InterpolableNumber::create(numberOptionalNumber->secondNu
mber()->value())); | 44 result->set(1, InterpolableNumber::create(numberOptionalNumber->secondNu
mber()->value())); |
45 return result.release(); | 45 return result; |
46 } | 46 } |
47 | 47 |
48 static PassRefPtrWillBeRawPtr<SVGNumberOptionalNumber> fromInterpolableValue
(const InterpolableValue& value) | 48 static PassRefPtrWillBeRawPtr<SVGNumberOptionalNumber> fromInterpolableValue
(const InterpolableValue& value) |
49 { | 49 { |
50 const InterpolableList& list = toInterpolableList(value); | 50 const InterpolableList& list = toInterpolableList(value); |
51 return SVGNumberOptionalNumber::create( | 51 return SVGNumberOptionalNumber::create( |
52 SVGNumber::create(toInterpolableNumber(list.get(0))->value()), | 52 SVGNumber::create(toInterpolableNumber(list.get(0))->value()), |
53 SVGNumber::create(toInterpolableNumber(list.get(1))->value())); | 53 SVGNumber::create(toInterpolableNumber(list.get(1))->value())); |
54 } | 54 } |
55 }; | 55 }; |
56 | 56 |
57 } | 57 } |
58 | 58 |
59 #endif // NumberOptionalNumberSVGInterpolation_h | 59 #endif // NumberOptionalNumberSVGInterpolation_h |
OLD | NEW |