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 return start.isShadowValue() && end.isShadowValue() | 19 return start.isShadowValue() && end.isShadowValue() |
20 && toCSSShadowValue(start).style == toCSSShadowValue(end).style | 20 && toCSSShadowValue(start).style == toCSSShadowValue(end).style |
21 && toCSSShadowValue(start).color && toCSSShadowValue(end).color; | 21 && toCSSShadowValue(start).color && toCSSShadowValue(end).color; |
22 } | 22 } |
23 | 23 |
24 PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::lengthToInte
rpolableValue(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> value) | 24 InterpolableValue* ShadowStyleInterpolation::lengthToInterpolableValue(PassRefPt
rWillBeRawPtr<CSSPrimitiveValue> value) |
25 { | 25 { |
26 if (value) | 26 if (value) |
27 return LengthStyleInterpolation::toInterpolableValue(*value); | 27 return LengthStyleInterpolation::toInterpolableValue(*value); |
28 return LengthStyleInterpolation::toInterpolableValue(*CSSPrimitiveValue::cre
ate(0, CSSPrimitiveValue::CSS_PX)); | 28 return LengthStyleInterpolation::toInterpolableValue(*CSSPrimitiveValue::cre
ate(0, CSSPrimitiveValue::CSS_PX)); |
29 } | 29 } |
30 | 30 |
31 PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::toInterpolab
leValue(const CSSValue& value, NonInterpolableType& nonInterpolableData) | 31 InterpolableValue* ShadowStyleInterpolation::toInterpolableValue(const CSSValue&
value, NonInterpolableType& nonInterpolableData) |
32 { | 32 { |
33 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(5); | 33 InterpolableList* result = InterpolableList::create(5); |
34 const CSSShadowValue* shadowValue = toCSSShadowValue(&value); | 34 const CSSShadowValue* shadowValue = toCSSShadowValue(&value); |
35 ASSERT(shadowValue); | 35 ASSERT(shadowValue); |
36 | 36 |
37 result->set(0, lengthToInterpolableValue(shadowValue->x)); | 37 result->set(0, lengthToInterpolableValue(shadowValue->x)); |
38 result->set(1, lengthToInterpolableValue(shadowValue->y)); | 38 result->set(1, lengthToInterpolableValue(shadowValue->y)); |
39 result->set(2, lengthToInterpolableValue(shadowValue->blur)); | 39 result->set(2, lengthToInterpolableValue(shadowValue->blur)); |
40 result->set(3, lengthToInterpolableValue(shadowValue->spread)); | 40 result->set(3, lengthToInterpolableValue(shadowValue->spread)); |
41 | 41 |
42 if (shadowValue->color && ColorStyleInterpolation::canCreateFrom(*shadowValu
e->color)) | 42 if (shadowValue->color && ColorStyleInterpolation::canCreateFrom(*shadowValu
e->color)) |
43 result->set(4, ColorStyleInterpolation::colorToInterpolableValue(*shadow
Value->color)); | 43 result->set(4, ColorStyleInterpolation::colorToInterpolableValue(*shadow
Value->color)); |
44 | 44 |
45 if (shadowValue->style) | 45 if (shadowValue->style) |
46 nonInterpolableData = (shadowValue->style->getValueID() == CSSValueInset
); | 46 nonInterpolableData = (shadowValue->style->getValueID() == CSSValueInset
); |
47 else | 47 else |
48 nonInterpolableData = false; | 48 nonInterpolableData = false; |
49 | 49 |
50 return result.release(); | 50 return result; |
51 } | 51 } |
52 | 52 |
53 PassRefPtrWillBeRawPtr<CSSValue> ShadowStyleInterpolation::fromInterpolableValue
(const InterpolableValue& value, NonInterpolableType nonInterpolableData, Interp
olationRange range) | 53 PassRefPtrWillBeRawPtr<CSSValue> ShadowStyleInterpolation::fromInterpolableValue
(const InterpolableValue& value, NonInterpolableType nonInterpolableData, Interp
olationRange range) |
54 { | 54 { |
55 const InterpolableList* shadow = toInterpolableList(&value); | 55 const InterpolableList* shadow = toInterpolableList(&value); |
56 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = LengthStyleInterpolation::fromInte
rpolableValue(*shadow->get(0), RangeAll); | 56 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = LengthStyleInterpolation::fromInte
rpolableValue(*shadow->get(0), RangeAll); |
57 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = LengthStyleInterpolation::fromInte
rpolableValue(*shadow->get(1), RangeAll); | 57 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = LengthStyleInterpolation::fromInte
rpolableValue(*shadow->get(1), RangeAll); |
58 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = LengthStyleInterpolation::fromI
nterpolableValue(*shadow->get(2), RangeNonNegative); | 58 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = LengthStyleInterpolation::fromI
nterpolableValue(*shadow->get(2), RangeNonNegative); |
59 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = LengthStyleInterpolation::fro
mInterpolableValue(*shadow->get(3), RangeAll); | 59 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = LengthStyleInterpolation::fro
mInterpolableValue(*shadow->get(3), RangeAll); |
60 | 60 |
(...skipping 12 matching lines...) Expand all Loading... |
73 for (size_t i = 0; i < toCSSValueList(start).length(); i++) { | 73 for (size_t i = 0; i < toCSSValueList(start).length(); i++) { |
74 if (startList->item(i)->isShadowValue() && endList->item(i)->isShado
wValue() | 74 if (startList->item(i)->isShadowValue() && endList->item(i)->isShado
wValue() |
75 && toCSSShadowValue(startList->item(i))->style != toCSSShadowVal
ue(endList->item(i))->style) | 75 && toCSSShadowValue(startList->item(i))->style != toCSSShadowVal
ue(endList->item(i))->style) |
76 return true; | 76 return true; |
77 } | 77 } |
78 } | 78 } |
79 return false; | 79 return false; |
80 } | 80 } |
81 | 81 |
82 } // namespace blink | 82 } // namespace blink |
OLD | NEW |