| 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 NumberSVGInterpolation_h | 5 #ifndef NumberSVGInterpolation_h |
| 6 #define NumberSVGInterpolation_h | 6 #define NumberSVGInterpolation_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/SVGNumberList.h" | 10 #include "core/svg/SVGNumberList.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 enum SVGNumberNegativeValuesMode { | 14 enum SVGNumberNegativeValuesMode { |
| 15 AllowNegativeNumbers, | 15 AllowNegativeNumbers, |
| 16 ForbidNegativeNumbers | 16 ForbidNegativeNumbers |
| 17 }; | 17 }; |
| 18 | 18 |
| 19 class NumberSVGInterpolation : public SVGInterpolation { | 19 class NumberSVGInterpolation : public SVGInterpolation { |
| 20 public: | 20 public: |
| 21 typedef SVGNumberList ListType; | 21 typedef SVGNumberList ListType; |
| 22 typedef void NonInterpolableType; | 22 typedef void NonInterpolableType; |
| 23 | 23 |
| 24 static PassRefPtrWillBeRawPtr<NumberSVGInterpolation> create(SVGPropertyBase
* start, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> a
ttribute, SVGNumberNegativeValuesMode negativeValuesMode) | 24 static PassRefPtr<NumberSVGInterpolation> create(SVGPropertyBase* start, SVG
PropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute, SV
GNumberNegativeValuesMode negativeValuesMode) |
| 25 { | 25 { |
| 26 return adoptRefWillBeNoop(new NumberSVGInterpolation(toInterpolableValue
(start), toInterpolableValue(end), attribute, negativeValuesMode)); | 26 return adoptRef(new NumberSVGInterpolation(toInterpolableValue(start), t
oInterpolableValue(end), attribute, negativeValuesMode)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 static bool canCreateFrom(SVGPropertyBase* value) | 29 static bool canCreateFrom(SVGPropertyBase* value) |
| 30 { | 30 { |
| 31 return true; | 31 return true; |
| 32 } | 32 } |
| 33 | 33 |
| 34 PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement&) const
final | 34 PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement&) const
final |
| 35 { | 35 { |
| 36 return fromInterpolableValue(*m_cachedValue, m_negativeValuesMode); | 36 return fromInterpolableValue(*m_cachedValue, m_negativeValuesMode); |
| 37 } | 37 } |
| 38 | 38 |
| 39 DEFINE_INLINE_VIRTUAL_TRACE() | 39 static PassOwnPtr<InterpolableNumber> toInterpolableValue(SVGPropertyBase* v
alue) |
| 40 { | |
| 41 SVGInterpolation::trace(visitor); | |
| 42 } | |
| 43 | |
| 44 static PassOwnPtrWillBeRawPtr<InterpolableNumber> toInterpolableValue(SVGPro
pertyBase* value) | |
| 45 { | 40 { |
| 46 return InterpolableNumber::create(toSVGNumber(value)->value()); | 41 return InterpolableNumber::create(toSVGNumber(value)->value()); |
| 47 } | 42 } |
| 48 | 43 |
| 49 static PassRefPtrWillBeRawPtr<SVGNumber> fromInterpolableValue(const Interpo
lableValue&, SVGNumberNegativeValuesMode = AllowNegativeNumbers); | 44 static PassRefPtrWillBeRawPtr<SVGNumber> fromInterpolableValue(const Interpo
lableValue&, SVGNumberNegativeValuesMode = AllowNegativeNumbers); |
| 50 | 45 |
| 51 private: | 46 private: |
| 52 NumberSVGInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pass
OwnPtrWillBeRawPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedPro
pertyBase> attribute, SVGNumberNegativeValuesMode negativeValuesMode) | 47 NumberSVGInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Inter
polableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute, SV
GNumberNegativeValuesMode negativeValuesMode) |
| 53 : SVGInterpolation(start, end, attribute) | 48 : SVGInterpolation(start, end, attribute) |
| 54 , m_negativeValuesMode(negativeValuesMode) | 49 , m_negativeValuesMode(negativeValuesMode) |
| 55 { | 50 { |
| 56 } | 51 } |
| 57 | 52 |
| 58 const SVGNumberNegativeValuesMode m_negativeValuesMode; | 53 const SVGNumberNegativeValuesMode m_negativeValuesMode; |
| 59 }; | 54 }; |
| 60 | 55 |
| 61 } | 56 } |
| 62 | 57 |
| 63 #endif // NumberSVGInterpolation_h | 58 #endif // NumberSVGInterpolation_h |
| OLD | NEW |