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/FilterStyleInterpolation.h" | 6 #include "core/animation/FilterStyleInterpolation.h" |
7 | 7 |
8 #include "core/animation/LengthStyleInterpolation.h" | 8 #include "core/animation/LengthStyleInterpolation.h" |
9 #include "core/animation/ListStyleInterpolation.h" | 9 #include "core/animation/ListStyleInterpolation.h" |
10 #include "core/css/CSSPrimitiveValue.h" | 10 #include "core/css/CSSPrimitiveValue.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 default: | 53 default: |
54 ASSERT_NOT_REACHED(); | 54 ASSERT_NOT_REACHED(); |
55 return CSSValueList::createSpaceSeparated(); | 55 return CSSValueList::createSpaceSeparated(); |
56 } | 56 } |
57 result->append(defaultFunction); | 57 result->append(defaultFunction); |
58 ++otherIter; | 58 ++otherIter; |
59 } | 59 } |
60 return result.release(); | 60 return result.release(); |
61 } | 61 } |
62 | 62 |
63 PassRefPtrWillBeRawPtr<FilterStyleInterpolation::FilterListStyleInterpolation> m
aybeCreateFromList(const CSSValueList& startList, const CSSValueList& endList, C
SSPropertyID property) | 63 PassRefPtr<FilterStyleInterpolation::FilterListStyleInterpolation> maybeCreateFr
omList(const CSSValueList& startList, const CSSValueList& endList, CSSPropertyID
property) |
64 { | 64 { |
65 if (startList.length() < endList.length()) | 65 if (startList.length() < endList.length()) |
66 return ListStyleInterpolation<FilterStyleInterpolation>::maybeCreateFrom
List(*extendFilterList(startList, endList), endList, property); | 66 return ListStyleInterpolation<FilterStyleInterpolation>::maybeCreateFrom
List(*extendFilterList(startList, endList), endList, property); |
67 return ListStyleInterpolation<FilterStyleInterpolation>::maybeCreateFromList
(startList, *extendFilterList(endList, startList), property); | 67 return ListStyleInterpolation<FilterStyleInterpolation>::maybeCreateFromList
(startList, *extendFilterList(endList, startList), property); |
68 } | 68 } |
69 | 69 |
70 } // namespace | 70 } // namespace |
71 | 71 |
72 PassRefPtrWillBeRawPtr<FilterStyleInterpolation::FilterListStyleInterpolation> F
ilterStyleInterpolation::maybeCreateList(const CSSValue& start, const CSSValue&
end, CSSPropertyID property) | 72 PassRefPtr<FilterStyleInterpolation::FilterListStyleInterpolation> FilterStyleIn
terpolation::maybeCreateList(const CSSValue& start, const CSSValue& end, CSSProp
ertyID property) |
73 { | 73 { |
74 if (start.isCSSWideKeyword() || end.isCSSWideKeyword()) | 74 if (start.isCSSWideKeyword() || end.isCSSWideKeyword()) |
75 return nullptr; | 75 return nullptr; |
76 | 76 |
77 ASSERT(start.isValueList() || toCSSPrimitiveValue(start).getValueID() == CSS
ValueNone); | 77 ASSERT(start.isValueList() || toCSSPrimitiveValue(start).getValueID() == CSS
ValueNone); |
78 ASSERT(end.isValueList() || toCSSPrimitiveValue(end).getValueID() == CSSValu
eNone); | 78 ASSERT(end.isValueList() || toCSSPrimitiveValue(end).getValueID() == CSSValu
eNone); |
79 | 79 |
80 if (!start.isValueList() && !end.isValueList()) | 80 if (!start.isValueList() && !end.isValueList()) |
81 return nullptr; | 81 return nullptr; |
82 | 82 |
83 return maybeCreateFromList( | 83 return maybeCreateFromList( |
84 start.isValueList() ? toCSSValueList(start) : *CSSValueList::createSpace
Separated(), | 84 start.isValueList() ? toCSSValueList(start) : *CSSValueList::createSpace
Separated(), |
85 end.isValueList() ? toCSSValueList(end) : *CSSValueList::createSpaceSepa
rated(), | 85 end.isValueList() ? toCSSValueList(end) : *CSSValueList::createSpaceSepa
rated(), |
86 property); | 86 property); |
87 } | 87 } |
88 | 88 |
89 bool FilterStyleInterpolation::canCreateFrom(const CSSValue& start, const CSSVal
ue& end) | 89 bool FilterStyleInterpolation::canCreateFrom(const CSSValue& start, const CSSVal
ue& end) |
90 { | 90 { |
91 // Discrete interpolation occurs when url or distinct function types occur. | 91 // Discrete interpolation occurs when url or distinct function types occur. |
92 // http://dev.w3.org/fxtf/filters/#animation-of-filters | 92 // http://dev.w3.org/fxtf/filters/#animation-of-filters |
93 // FIXME: Drop shadow interpolation has not been implemented. | 93 // FIXME: Drop shadow interpolation has not been implemented. |
94 CSSValueID startFunctionType = toCSSFunctionValue(start).functionType(); | 94 CSSValueID startFunctionType = toCSSFunctionValue(start).functionType(); |
95 return startFunctionType == toCSSFunctionValue(end).functionType() | 95 return startFunctionType == toCSSFunctionValue(end).functionType() |
96 && startFunctionType != CSSValueUrl | 96 && startFunctionType != CSSValueUrl |
97 && startFunctionType != CSSValueDropShadow; | 97 && startFunctionType != CSSValueDropShadow; |
98 } | 98 } |
99 | 99 |
100 PassOwnPtrWillBeRawPtr<InterpolableValue> FilterStyleInterpolation::toInterpolab
leValue(const CSSValue& value, CSSValueID& functionType) | 100 PassOwnPtr<InterpolableValue> FilterStyleInterpolation::toInterpolableValue(cons
t CSSValue& value, CSSValueID& functionType) |
101 { | 101 { |
102 const CSSFunctionValue& filterValue = toCSSFunctionValue(value); | 102 const CSSFunctionValue& filterValue = toCSSFunctionValue(value); |
103 functionType = filterValue.functionType(); | 103 functionType = filterValue.functionType(); |
104 size_t length = filterValue.length(); | 104 size_t length = filterValue.length(); |
105 | 105 |
106 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(lengt
h); | 106 OwnPtr<InterpolableList> result = InterpolableList::create(length); |
107 for (size_t i = 0; i < length; ++i) { | 107 for (size_t i = 0; i < length; ++i) { |
108 switch (functionType) { | 108 switch (functionType) { |
109 case CSSValueHueRotate: | 109 case CSSValueHueRotate: |
110 result->set(i, InterpolableNumber::create(toCSSPrimitiveValue(filter
Value.item(i))->computeDegrees())); | 110 result->set(i, InterpolableNumber::create(toCSSPrimitiveValue(filter
Value.item(i))->computeDegrees())); |
111 break; | 111 break; |
112 case CSSValueBlur: | 112 case CSSValueBlur: |
113 result->set(i, LengthStyleInterpolation::toInterpolableValue(*filter
Value.item(i), CSSPropertyWebkitFilter)); | 113 result->set(i, LengthStyleInterpolation::toInterpolableValue(*filter
Value.item(i), CSSPropertyWebkitFilter)); |
114 break; | 114 break; |
115 case CSSValueGrayscale: | 115 case CSSValueGrayscale: |
116 case CSSValueInvert: | 116 case CSSValueInvert: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 case CSSValueUrl: | 158 case CSSValueUrl: |
159 default: | 159 default: |
160 ASSERT_NOT_REACHED(); | 160 ASSERT_NOT_REACHED(); |
161 break; | 161 break; |
162 } | 162 } |
163 } | 163 } |
164 return result.release(); | 164 return result.release(); |
165 } | 165 } |
166 | 166 |
167 } // namespace blink | 167 } // namespace blink |
OLD | NEW |