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" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 PassRefPtrWillBeRawPtr<CSSValueList> extendFilterList(const CSSValueList& shortF
ilterList, const CSSValueList& otherFilterList) | 16 PassRefPtr<CSSValueList> extendFilterList(const CSSValueList& shortFilterList, c
onst CSSValueList& otherFilterList) |
17 { | 17 { |
18 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); | 18 RefPtr<CSSValueList> result = CSSValueList::createSpaceSeparated(); |
19 CSSValueList::const_iterator shortIter = shortFilterList.begin(); | 19 CSSValueList::const_iterator shortIter = shortFilterList.begin(); |
20 CSSValueList::const_iterator otherIter = otherFilterList.begin(); | 20 CSSValueList::const_iterator otherIter = otherFilterList.begin(); |
21 while (shortIter != shortFilterList.end()) { | 21 while (shortIter != shortFilterList.end()) { |
22 result->append(*shortIter); | 22 result->append(*shortIter); |
23 ++shortIter; | 23 ++shortIter; |
24 ++otherIter; | 24 ++otherIter; |
25 } | 25 } |
26 while (otherIter != otherFilterList.end()) { | 26 while (otherIter != otherFilterList.end()) { |
27 CSSFunctionValue* function = toCSSFunctionValue(otherIter->get()); | 27 CSSFunctionValue* function = toCSSFunctionValue(otherIter->get()); |
28 RefPtrWillBeRawPtr<CSSValueList> defaultFunction = CSSFunctionValue::cre
ate(function->functionType()); | 28 RefPtr<CSSValueList> defaultFunction = CSSFunctionValue::create(function
->functionType()); |
29 switch (function->functionType()) { | 29 switch (function->functionType()) { |
30 case CSSValueUrl: | 30 case CSSValueUrl: |
31 // Discrete interpolation occurs - see canCreateFrom. | 31 // Discrete interpolation occurs - see canCreateFrom. |
32 break; | 32 break; |
33 case CSSValueGrayscale: | 33 case CSSValueGrayscale: |
34 case CSSValueInvert: | 34 case CSSValueInvert: |
35 case CSSValueSepia: | 35 case CSSValueSepia: |
36 defaultFunction->append(CSSPrimitiveValue::create(0, CSSPrimitiveVal
ue::UnitType::Number)); | 36 defaultFunction->append(CSSPrimitiveValue::create(0, CSSPrimitiveVal
ue::UnitType::Number)); |
37 break; | 37 break; |
38 case CSSValueBrightness: | 38 case CSSValueBrightness: |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 break; | 123 break; |
124 case CSSValueDropShadow: | 124 case CSSValueDropShadow: |
125 case CSSValueUrl: | 125 case CSSValueUrl: |
126 default: | 126 default: |
127 ASSERT_NOT_REACHED(); | 127 ASSERT_NOT_REACHED(); |
128 } | 128 } |
129 } | 129 } |
130 return result.release(); | 130 return result.release(); |
131 } | 131 } |
132 | 132 |
133 PassRefPtrWillBeRawPtr<CSSFunctionValue> FilterStyleInterpolation::fromInterpola
bleValue(const InterpolableValue& value, CSSValueID functionType, InterpolationR
ange) | 133 PassRefPtr<CSSFunctionValue> FilterStyleInterpolation::fromInterpolableValue(con
st InterpolableValue& value, CSSValueID functionType, InterpolationRange) |
134 { | 134 { |
135 const InterpolableList& list = toInterpolableList(value); | 135 const InterpolableList& list = toInterpolableList(value); |
136 size_t length = list.length(); | 136 size_t length = list.length(); |
137 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(funct
ionType); | 137 RefPtr<CSSFunctionValue> result = CSSFunctionValue::create(functionType); |
138 for (size_t i = 0; i < length; ++i) { | 138 for (size_t i = 0; i < length; ++i) { |
139 switch (functionType) { | 139 switch (functionType) { |
140 case CSSValueGrayscale: | 140 case CSSValueGrayscale: |
141 case CSSValueInvert: | 141 case CSSValueInvert: |
142 case CSSValueOpacity: | 142 case CSSValueOpacity: |
143 case CSSValueSepia: | 143 case CSSValueSepia: |
144 result->append(CSSPrimitiveValue::create(clampTo<double>(toInterpola
bleNumber(list.get(i))->value(), 0, 1), CSSPrimitiveValue::UnitType::Number)); | 144 result->append(CSSPrimitiveValue::create(clampTo<double>(toInterpola
bleNumber(list.get(i))->value(), 0, 1), CSSPrimitiveValue::UnitType::Number)); |
145 break; | 145 break; |
146 case CSSValueBrightness: | 146 case CSSValueBrightness: |
147 case CSSValueContrast: | 147 case CSSValueContrast: |
(...skipping 10 matching lines...) Expand all 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 |