| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NumberOptionalNumberSVGInterpolation_h | |
| 6 #define NumberOptionalNumberSVGInterpolation_h | |
| 7 | |
| 8 #include "core/animation/SVGInterpolation.h" | |
| 9 #include "core/svg/SVGNumber.h" | |
| 10 #include "core/svg/SVGNumberOptionalNumber.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 class SVGNumberOptionalNumber; | |
| 15 | |
| 16 class NumberOptionalNumberSVGInterpolation : public SVGInterpolation { | |
| 17 public: | |
| 18 static PassRefPtr<NumberOptionalNumberSVGInterpolation> create(SVGPropertyBa
se* start, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase>
attribute) | |
| 19 { | |
| 20 return adoptRef(new NumberOptionalNumberSVGInterpolation(toInterpolableV
alue(start), toInterpolableValue(end), attribute)); | |
| 21 } | |
| 22 | |
| 23 PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement&) const
final | |
| 24 { | |
| 25 return fromInterpolableValue(*m_cachedValue); | |
| 26 } | |
| 27 | |
| 28 private: | |
| 29 NumberOptionalNumberSVGInterpolation(PassOwnPtr<InterpolableValue> start, Pa
ssOwnPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase>
attribute) | |
| 30 : SVGInterpolation(start, end, attribute) | |
| 31 { | |
| 32 } | |
| 33 | |
| 34 static PassOwnPtr<InterpolableValue> toInterpolableValue(SVGPropertyBase* va
lue) | |
| 35 { | |
| 36 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> numberOptionalNumber = toSVG
NumberOptionalNumber(value); | |
| 37 OwnPtr<InterpolableList> result = InterpolableList::create(2); | |
| 38 result->set(0, InterpolableNumber::create(numberOptionalNumber->firstNum
ber()->value())); | |
| 39 result->set(1, InterpolableNumber::create(numberOptionalNumber->secondNu
mber()->value())); | |
| 40 return result.release(); | |
| 41 } | |
| 42 | |
| 43 static PassRefPtrWillBeRawPtr<SVGNumberOptionalNumber> fromInterpolableValue
(const InterpolableValue& value) | |
| 44 { | |
| 45 const InterpolableList& list = toInterpolableList(value); | |
| 46 return SVGNumberOptionalNumber::create( | |
| 47 SVGNumber::create(toInterpolableNumber(list.get(0))->value()), | |
| 48 SVGNumber::create(toInterpolableNumber(list.get(1))->value())); | |
| 49 } | |
| 50 }; | |
| 51 | |
| 52 } | |
| 53 | |
| 54 #endif // NumberOptionalNumberSVGInterpolation_h | |
| OLD | NEW |