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/ShadowStyleInterpolation.h" | 6 #include "core/animation/ShadowStyleInterpolation.h" |
7 | 7 |
8 #include "core/animation/ColorStyleInterpolation.h" | 8 #include "core/animation/ColorStyleInterpolation.h" |
9 #include "core/animation/LengthStyleInterpolation.h" | 9 #include "core/animation/LengthStyleInterpolation.h" |
10 #include "core/css/CSSPrimitiveValue.h" | 10 #include "core/css/CSSPrimitiveValue.h" |
11 #include "core/css/CSSValueList.h" | 11 #include "core/css/CSSValueList.h" |
12 #include "core/css/CSSValuePool.h" | 12 #include "core/css/CSSValuePool.h" |
13 #include "core/css/resolver/StyleBuilder.h" | 13 #include "core/css/resolver/StyleBuilder.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 bool ShadowStyleInterpolation::canCreateFrom(const CSSValue& start, const CSSVal
ue& end) | 17 bool ShadowStyleInterpolation::canCreateFrom(const CSSValue& start, const CSSVal
ue& end) |
18 { | 18 { |
19 if (!start.isShadowValue() || end.isShadowValue()) | 19 if (!start.isShadowValue() || end.isShadowValue()) |
20 return false; | 20 return false; |
21 const CSSShadowValue& startShadow = toCSSShadowValue(start); | 21 const CSSShadowValue& startShadow = toCSSShadowValue(start); |
22 const CSSShadowValue& endShadow = toCSSShadowValue(end); | 22 const CSSShadowValue& endShadow = toCSSShadowValue(end); |
23 if (startShadow.style != endShadow.style || !startShadow.color || !endShadow
.color) | 23 if (startShadow.style != endShadow.style || !startShadow.color || !endShadow
.color) |
24 return false; | 24 return false; |
25 return !ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(*startSha
dow.color, *endShadow.color); | 25 return !ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(*startSha
dow.color, *endShadow.color); |
26 } | 26 } |
27 | 27 |
28 PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::lengthToInte
rpolableValue(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> value) | 28 PassOwnPtr<InterpolableValue> ShadowStyleInterpolation::lengthToInterpolableValu
e(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> value) |
29 { | 29 { |
30 if (value) | 30 if (value) |
31 return LengthStyleInterpolation::toInterpolableValue(*value); | 31 return LengthStyleInterpolation::toInterpolableValue(*value); |
32 return LengthStyleInterpolation::toInterpolableValue(*CSSPrimitiveValue::cre
ate(0, CSSPrimitiveValue::UnitType::Pixels)); | 32 return LengthStyleInterpolation::toInterpolableValue(*CSSPrimitiveValue::cre
ate(0, CSSPrimitiveValue::UnitType::Pixels)); |
33 } | 33 } |
34 | 34 |
35 PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::toInterpolab
leValue(const CSSValue& value, NonInterpolableType& nonInterpolableData) | 35 PassOwnPtr<InterpolableValue> ShadowStyleInterpolation::toInterpolableValue(cons
t CSSValue& value, NonInterpolableType& nonInterpolableData) |
36 { | 36 { |
37 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(5); | 37 OwnPtr<InterpolableList> result = InterpolableList::create(5); |
38 const CSSShadowValue* shadowValue = toCSSShadowValue(&value); | 38 const CSSShadowValue* shadowValue = toCSSShadowValue(&value); |
39 ASSERT(shadowValue); | 39 ASSERT(shadowValue); |
40 | 40 |
41 result->set(0, lengthToInterpolableValue(shadowValue->x)); | 41 result->set(0, lengthToInterpolableValue(shadowValue->x)); |
42 result->set(1, lengthToInterpolableValue(shadowValue->y)); | 42 result->set(1, lengthToInterpolableValue(shadowValue->y)); |
43 result->set(2, lengthToInterpolableValue(shadowValue->blur)); | 43 result->set(2, lengthToInterpolableValue(shadowValue->blur)); |
44 result->set(3, lengthToInterpolableValue(shadowValue->spread)); | 44 result->set(3, lengthToInterpolableValue(shadowValue->spread)); |
45 | 45 |
46 if (shadowValue->color && ColorStyleInterpolation::canCreateFrom(*shadowValu
e->color)) | 46 if (shadowValue->color && ColorStyleInterpolation::canCreateFrom(*shadowValu
e->color)) |
47 result->set(4, ColorStyleInterpolation::colorToInterpolableValue(*shadow
Value->color)); | 47 result->set(4, ColorStyleInterpolation::colorToInterpolableValue(*shadow
Value->color)); |
(...skipping 29 matching lines...) Expand all Loading... |
77 for (size_t i = 0; i < toCSSValueList(start).length(); i++) { | 77 for (size_t i = 0; i < toCSSValueList(start).length(); i++) { |
78 if (startList->item(i)->isShadowValue() && endList->item(i)->isShado
wValue() | 78 if (startList->item(i)->isShadowValue() && endList->item(i)->isShado
wValue() |
79 && toCSSShadowValue(startList->item(i))->style != toCSSShadowVal
ue(endList->item(i))->style) | 79 && toCSSShadowValue(startList->item(i))->style != toCSSShadowVal
ue(endList->item(i))->style) |
80 return true; | 80 return true; |
81 } | 81 } |
82 } | 82 } |
83 return false; | 83 return false; |
84 } | 84 } |
85 | 85 |
86 } // namespace blink | 86 } // namespace blink |
OLD | NEW |