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 #include "config.h" | |
6 #include "core/animation/IntegerOptionalIntegerSVGInterpolation.h" | |
7 | |
8 #include "core/SVGNames.h" | |
9 | |
10 namespace blink { | |
11 | |
12 namespace { | |
13 | |
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. | |
16 PassRefPtrWillBeRawPtr<SVGInteger> toPositiveInteger(const InterpolableValue* nu
mber, int min) | |
17 { | |
18 return SVGInteger::create(clampTo<int>(roundf(toInterpolableNumber(number)->
value()), min)); | |
19 } | |
20 | |
21 } // namespace | |
22 | |
23 PassOwnPtr<InterpolableValue> IntegerOptionalIntegerSVGInterpolation::toInterpol
ableValue(SVGPropertyBase* value) | |
24 { | |
25 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> integerOptionalInteger = toSVG
IntegerOptionalInteger(value); | |
26 OwnPtr<InterpolableList> result = InterpolableList::create(2); | |
27 result->set(0, InterpolableNumber::create(integerOptionalInteger->firstInteg
er()->value())); | |
28 result->set(1, InterpolableNumber::create(integerOptionalInteger->secondInte
ger()->value())); | |
29 return result.release(); | |
30 } | |
31 | |
32 PassRefPtrWillBeRawPtr<SVGIntegerOptionalInteger> IntegerOptionalIntegerSVGInter
polation::fromInterpolableValue(const InterpolableValue& value, int min) | |
33 { | |
34 const InterpolableList& list = toInterpolableList(value); | |
35 return SVGIntegerOptionalInteger::create( | |
36 toPositiveInteger(list.get(0), min), | |
37 toPositiveInteger(list.get(1), min)); | |
38 } | |
39 | |
40 } | |
OLD | NEW |