OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/LengthPairStyleInterpolation.h" | 6 #include "core/animation/LengthPairStyleInterpolation.h" |
7 | 7 |
8 #include "core/animation/LengthStyleInterpolation.h" | 8 #include "core/animation/LengthStyleInterpolation.h" |
9 #include "core/css/Pair.h" | 9 #include "core/css/Pair.h" |
10 #include "core/css/resolver/StyleBuilder.h" | 10 #include "core/css/resolver/StyleBuilder.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 bool LengthPairStyleInterpolation::canCreateFrom(const CSSValue& value) | 14 bool LengthPairStyleInterpolation::canCreateFrom(const CSSValue& value) |
15 { | 15 { |
16 return value.isPrimitiveValue() && toCSSPrimitiveValue(value).getPairValue()
; | 16 return value.isPrimitiveValue() && toCSSPrimitiveValue(value).getPairValue()
; |
17 } | 17 } |
18 | 18 |
19 PassOwnPtrWillBeRawPtr<InterpolableValue> LengthPairStyleInterpolation::lengthPa
irToInterpolableValue(const CSSValue& value) | 19 InterpolableValue* LengthPairStyleInterpolation::lengthPairToInterpolableValue(c
onst CSSValue& value) |
20 { | 20 { |
21 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2); | 21 InterpolableList* result = InterpolableList::create(2); |
22 Pair* pair = toCSSPrimitiveValue(value).getPairValue(); | 22 Pair* pair = toCSSPrimitiveValue(value).getPairValue(); |
23 ASSERT(pair); | 23 ASSERT(pair); |
24 | 24 |
25 result->set(0, LengthStyleInterpolation::toInterpolableValue(*pair->first())
); | 25 result->set(0, LengthStyleInterpolation::toInterpolableValue(*pair->first())
); |
26 result->set(1, LengthStyleInterpolation::toInterpolableValue(*pair->second()
)); | 26 result->set(1, LengthStyleInterpolation::toInterpolableValue(*pair->second()
)); |
27 return result.release(); | 27 return result; |
28 } | 28 } |
29 | 29 |
30 PassRefPtrWillBeRawPtr<CSSValue> LengthPairStyleInterpolation::interpolableValue
ToLengthPair(InterpolableValue* value, InterpolationRange range) | 30 PassRefPtrWillBeRawPtr<CSSValue> LengthPairStyleInterpolation::interpolableValue
ToLengthPair(InterpolableValue* value, InterpolationRange range) |
31 { | 31 { |
32 InterpolableList* lengthPair = toInterpolableList(value); | 32 InterpolableList* lengthPair = toInterpolableList(value); |
33 RefPtrWillBeRawPtr<CSSPrimitiveValue> first = LengthStyleInterpolation::from
InterpolableValue(*lengthPair->get(0), range); | 33 RefPtrWillBeRawPtr<CSSPrimitiveValue> first = LengthStyleInterpolation::from
InterpolableValue(*lengthPair->get(0), range); |
34 RefPtrWillBeRawPtr<CSSPrimitiveValue> second = LengthStyleInterpolation::fro
mInterpolableValue(*lengthPair->get(1), range); | 34 RefPtrWillBeRawPtr<CSSPrimitiveValue> second = LengthStyleInterpolation::fro
mInterpolableValue(*lengthPair->get(1), range); |
35 RefPtrWillBeRawPtr<Pair> result = Pair::create(first, second, Pair::KeepIden
ticalValues); | 35 RefPtrWillBeRawPtr<Pair> result = Pair::create(first, second, Pair::KeepIden
ticalValues); |
36 | 36 |
37 return CSSPrimitiveValue::create(result.release()); | 37 return CSSPrimitiveValue::create(result.release()); |
38 } | 38 } |
39 | 39 |
40 void LengthPairStyleInterpolation::apply(StyleResolverState& state) const | 40 void LengthPairStyleInterpolation::apply(StyleResolverState& state) const |
41 { | 41 { |
42 StyleBuilder::applyProperty(m_id, state, interpolableValueToLengthPair(m_cac
hedValue.get(), m_range).get()); | 42 StyleBuilder::applyProperty(m_id, state, interpolableValueToLengthPair(m_cac
hedValue.get(), m_range).get()); |
43 } | 43 } |
44 | 44 |
45 } // namespace blink | 45 } // namespace blink |
OLD | NEW |