OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/animation/CSSBorderImageLengthBoxInterpolationType.h" | 5 #include "core/animation/CSSBorderImageLengthBoxInterpolationType.h" |
6 | 6 |
7 #include "core/animation/BorderImageLengthBoxPropertyFunctions.h" | 7 #include "core/animation/BorderImageLengthBoxPropertyFunctions.h" |
8 #include "core/animation/LengthInterpolationFunctions.h" | 8 #include "core/animation/LengthInterpolationFunctions.h" |
9 #include "core/css/CSSQuadValue.h" | 9 #include "core/css/CSSQuadValue.h" |
10 #include "core/css/resolver/StyleResolverState.h" | 10 #include "core/css/resolver/StyleResolverState.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 struct SideNumbers { | 26 struct SideNumbers { |
27 explicit SideNumbers(const BorderImageLengthBox& box) | 27 explicit SideNumbers(const BorderImageLengthBox& box) |
28 { | 28 { |
29 isNumber[SideTop] = box.top().isNumber(); | 29 isNumber[SideTop] = box.top().isNumber(); |
30 isNumber[SideRight] = box.right().isNumber(); | 30 isNumber[SideRight] = box.right().isNumber(); |
31 isNumber[SideBottom] = box.bottom().isNumber(); | 31 isNumber[SideBottom] = box.bottom().isNumber(); |
32 isNumber[SideLeft] = box.left().isNumber(); | 32 isNumber[SideLeft] = box.left().isNumber(); |
33 } | 33 } |
34 explicit SideNumbers(const CSSQuadValue& quad) | 34 explicit SideNumbers(const CSSQuadValue& quad) |
35 { | 35 { |
36 isNumber[SideTop] = quad.top()->isNumber(); | 36 isNumber[SideTop] = quad.top()->isPrimitiveValue() && toCSSPrimitiveValu
e(quad.top())->isNumber(); |
37 isNumber[SideRight] = quad.right()->isNumber(); | 37 isNumber[SideRight] = quad.right()->isPrimitiveValue() && toCSSPrimitive
Value(quad.right())->isNumber(); |
38 isNumber[SideBottom] = quad.bottom()->isNumber(); | 38 isNumber[SideBottom] = quad.bottom()->isPrimitiveValue() && toCSSPrimiti
veValue(quad.bottom())->isNumber(); |
39 isNumber[SideLeft] = quad.left()->isNumber(); | 39 isNumber[SideLeft] = quad.left()->isPrimitiveValue() && toCSSPrimitiveVa
lue(quad.left())->isNumber(); |
40 } | 40 } |
41 | 41 |
42 bool operator==(const SideNumbers& other) const | 42 bool operator==(const SideNumbers& other) const |
43 { | 43 { |
44 for (size_t i = 0; i < SideIndexCount; i++) { | 44 for (size_t i = 0; i < SideIndexCount; i++) { |
45 if (isNumber[i] != other.isNumber[i]) | 45 if (isNumber[i] != other.isNumber[i]) |
46 return false; | 46 return false; |
47 } | 47 } |
48 return true; | 48 return true; |
49 } | 49 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 188 } |
189 | 189 |
190 InterpolationValue CSSBorderImageLengthBoxInterpolationType::maybeConvertValue(c
onst CSSValue& value, const StyleResolverState&, ConversionCheckers&) const | 190 InterpolationValue CSSBorderImageLengthBoxInterpolationType::maybeConvertValue(c
onst CSSValue& value, const StyleResolverState&, ConversionCheckers&) const |
191 { | 191 { |
192 if (!value.isQuadValue()) | 192 if (!value.isQuadValue()) |
193 return nullptr; | 193 return nullptr; |
194 | 194 |
195 const CSSQuadValue& quad = toCSSQuadValue(value); | 195 const CSSQuadValue& quad = toCSSQuadValue(value); |
196 std::unique_ptr<InterpolableList> list = InterpolableList::create(SideIndexC
ount); | 196 std::unique_ptr<InterpolableList> list = InterpolableList::create(SideIndexC
ount); |
197 Vector<RefPtr<NonInterpolableValue>> nonInterpolableValues(SideIndexCount); | 197 Vector<RefPtr<NonInterpolableValue>> nonInterpolableValues(SideIndexCount); |
198 const CSSPrimitiveValue* sides[SideIndexCount] = {}; | 198 const CSSValue* sides[SideIndexCount] = {}; |
199 sides[SideTop] = quad.top(); | 199 sides[SideTop] = quad.top(); |
200 sides[SideRight] = quad.right(); | 200 sides[SideRight] = quad.right(); |
201 sides[SideBottom] = quad.bottom(); | 201 sides[SideBottom] = quad.bottom(); |
202 sides[SideLeft] = quad.left(); | 202 sides[SideLeft] = quad.left(); |
203 | 203 |
204 for (size_t i = 0; i < SideIndexCount; i++) { | 204 for (size_t i = 0; i < SideIndexCount; i++) { |
205 const CSSPrimitiveValue& side = *sides[i]; | 205 const CSSValue& side = *sides[i]; |
206 if (side.isNumber()) { | 206 if (side.isPrimitiveValue() && toCSSPrimitiveValue(side).isNumber()) { |
207 list->set(i, InterpolableNumber::create(side.getDoubleValue())); | 207 list->set(i, InterpolableNumber::create(toCSSPrimitiveValue(side).ge
tDoubleValue())); |
208 } else { | 208 } else { |
209 InterpolationValue convertedSide = LengthInterpolationFunctions::may
beConvertCSSValue(side); | 209 InterpolationValue convertedSide = LengthInterpolationFunctions::may
beConvertCSSValue(side); |
210 if (!convertedSide) | 210 if (!convertedSide) |
211 return nullptr; | 211 return nullptr; |
212 list->set(i, std::move(convertedSide.interpolableValue)); | 212 list->set(i, std::move(convertedSide.interpolableValue)); |
213 nonInterpolableValues[i] = convertedSide.nonInterpolableValue.releas
e(); | 213 nonInterpolableValues[i] = convertedSide.nonInterpolableValue.releas
e(); |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
217 return InterpolationValue(std::move(list), CSSBorderImageLengthBoxNonInterpo
lableValue::create(SideNumbers(quad), std::move(nonInterpolableValues))); | 217 return InterpolationValue(std::move(list), CSSBorderImageLengthBoxNonInterpo
lableValue::create(SideNumbers(quad), std::move(nonInterpolableValues))); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 }; | 271 }; |
272 BorderImageLengthBox box( | 272 BorderImageLengthBox box( |
273 convertSide(SideTop), | 273 convertSide(SideTop), |
274 convertSide(SideRight), | 274 convertSide(SideRight), |
275 convertSide(SideBottom), | 275 convertSide(SideBottom), |
276 convertSide(SideLeft)); | 276 convertSide(SideLeft)); |
277 BorderImageLengthBoxPropertyFunctions::setBorderImageLengthBox(cssProperty()
, *environment.state().style(), box); | 277 BorderImageLengthBoxPropertyFunctions::setBorderImageLengthBox(cssProperty()
, *environment.state().style(), box); |
278 } | 278 } |
279 | 279 |
280 } // namespace blink | 280 } // namespace blink |
OLD | NEW |