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.
5 #ifndef NumberSVGInterpolation_h
6 #define NumberSVGInterpolation_h
8 #include "core/animation/SVGInterpolation.h"
9 #include "core/svg/SVGNumber.h"
10 #include "core/svg/SVGNumberList.h"
14 enum SVGNumberNegativeValuesMode
{
19 class NumberSVGInterpolation
: public SVGInterpolation
{
21 typedef SVGNumberList ListType
;
22 typedef void NonInterpolableType
;
24 static PassRefPtr
<NumberSVGInterpolation
> create(SVGPropertyBase
* start
, SVGPropertyBase
* end
, PassRefPtrWillBeRawPtr
<SVGAnimatedPropertyBase
> attribute
, SVGNumberNegativeValuesMode negativeValuesMode
)
26 return adoptRef(new NumberSVGInterpolation(toInterpolableValue(start
), toInterpolableValue(end
), attribute
, negativeValuesMode
));
29 static bool canCreateFrom(SVGPropertyBase
* value
)
34 PassRefPtrWillBeRawPtr
<SVGPropertyBase
> interpolatedValue(SVGElement
&) const final
36 return fromInterpolableValue(*m_cachedValue
, m_negativeValuesMode
);
39 static PassOwnPtr
<InterpolableNumber
> toInterpolableValue(SVGPropertyBase
* value
)
41 return InterpolableNumber::create(toSVGNumber(value
)->value());
44 static PassRefPtrWillBeRawPtr
<SVGNumber
> fromInterpolableValue(const InterpolableValue
&, SVGNumberNegativeValuesMode
= AllowNegativeNumbers
);
47 NumberSVGInterpolation(PassOwnPtr
<InterpolableValue
> start
, PassOwnPtr
<InterpolableValue
> end
, PassRefPtrWillBeRawPtr
<SVGAnimatedPropertyBase
> attribute
, SVGNumberNegativeValuesMode negativeValuesMode
)
48 : SVGInterpolation(start
, end
, attribute
)
49 , m_negativeValuesMode(negativeValuesMode
)
53 const SVGNumberNegativeValuesMode m_negativeValuesMode
;
58 #endif // NumberSVGInterpolation_h