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 #include "config.h" | 5 #include "config.h" |
6 #include "core/animation/IntegerOptionalIntegerSVGInterpolation.h" | 6 #include "core/animation/IntegerOptionalIntegerSVGInterpolation.h" |
7 | 7 |
8 #include "core/SVGNames.h" | 8 #include "core/SVGNames.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 // For order, the values must be integers greater than zero. | 14 // For order, the values must be integers greater than zero. |
15 // For filterRes, negative values are an error. Zero values disable rendering of
the element which referenced the filter. | 15 // For filterRes, negative values are an error. Zero values disable rendering of
the element which referenced the filter. |
16 PassRefPtrWillBeRawPtr<SVGInteger> toPositiveInteger(const InterpolableValue* nu
mber, int min) | 16 PassRefPtrWillBeRawPtr<SVGInteger> toPositiveInteger(const InterpolableValue* nu
mber, int min) |
17 { | 17 { |
18 return SVGInteger::create(clampTo<int>(roundf(toInterpolableNumber(number)->
value()), min)); | 18 return SVGInteger::create(clampTo<int>(roundf(toInterpolableNumber(number)->
value()), min)); |
19 } | 19 } |
20 | 20 |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 PassOwnPtrWillBeRawPtr<InterpolableValue> IntegerOptionalIntegerSVGInterpolation
::toInterpolableValue(SVGPropertyBase* value) | 23 InterpolableValue* IntegerOptionalIntegerSVGInterpolation::toInterpolableValue(S
VGPropertyBase* value) |
24 { | 24 { |
25 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> integerOptionalInteger = toSVG
IntegerOptionalInteger(value); | 25 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> integerOptionalInteger = toSVG
IntegerOptionalInteger(value); |
26 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2); | 26 InterpolableList* result = InterpolableList::create(2); |
27 result->set(0, InterpolableNumber::create(integerOptionalInteger->firstInteg
er()->value())); | 27 result->set(0, InterpolableNumber::create(integerOptionalInteger->firstInteg
er()->value())); |
28 result->set(1, InterpolableNumber::create(integerOptionalInteger->secondInte
ger()->value())); | 28 result->set(1, InterpolableNumber::create(integerOptionalInteger->secondInte
ger()->value())); |
29 return result.release(); | 29 return result; |
30 } | 30 } |
31 | 31 |
32 PassRefPtrWillBeRawPtr<SVGIntegerOptionalInteger> IntegerOptionalIntegerSVGInter
polation::fromInterpolableValue(const InterpolableValue& value, int min) | 32 PassRefPtrWillBeRawPtr<SVGIntegerOptionalInteger> IntegerOptionalIntegerSVGInter
polation::fromInterpolableValue(const InterpolableValue& value, int min) |
33 { | 33 { |
34 const InterpolableList& list = toInterpolableList(value); | 34 const InterpolableList& list = toInterpolableList(value); |
35 return SVGIntegerOptionalInteger::create( | 35 return SVGIntegerOptionalInteger::create(toPositiveInteger(list.get(0), min)
, toPositiveInteger(list.get(1), min)); |
36 toPositiveInteger(list.get(0), min), | |
37 toPositiveInteger(list.get(1), min)); | |
38 } | 36 } |
39 | 37 |
40 } | 38 } |
OLD | NEW |