| 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/SizeInterpolationFunctions.h" | 5 #include "core/animation/SizeInterpolationFunctions.h" |
| 6 | 6 |
| 7 #include "core/animation/LengthInterpolationFunctions.h" | 7 #include "core/animation/LengthInterpolationFunctions.h" |
| 8 #include "core/animation/UnderlyingValueOwner.h" | 8 #include "core/animation/UnderlyingValueOwner.h" |
| 9 #include "core/css/CSSIdentifierValue.h" |
| 9 #include "core/css/CSSToLengthConversionData.h" | 10 #include "core/css/CSSToLengthConversionData.h" |
| 10 #include "core/css/CSSValuePair.h" | 11 #include "core/css/CSSValuePair.h" |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 class CSSSizeNonInterpolableValue : public NonInterpolableValue { | 15 class CSSSizeNonInterpolableValue : public NonInterpolableValue { |
| 15 public: | 16 public: |
| 16 static PassRefPtr<CSSSizeNonInterpolableValue> create(CSSValueID keyword) | 17 static PassRefPtr<CSSSizeNonInterpolableValue> create(CSSValueID keyword) |
| 17 { | 18 { |
| 18 return adoptRef(new CSSSizeNonInterpolableValue(keyword)); | 19 return adoptRef(new CSSSizeNonInterpolableValue(keyword)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 NOTREACHED(); | 84 NOTREACHED(); |
| 84 return nullptr; | 85 return nullptr; |
| 85 } | 86 } |
| 86 } | 87 } |
| 87 | 88 |
| 88 InterpolationValue SizeInterpolationFunctions::maybeConvertCSSSizeSide(const CSS
Value& value, bool convertWidth) | 89 InterpolationValue SizeInterpolationFunctions::maybeConvertCSSSizeSide(const CSS
Value& value, bool convertWidth) |
| 89 { | 90 { |
| 90 if (value.isValuePair()) { | 91 if (value.isValuePair()) { |
| 91 const CSSValuePair& pair = toCSSValuePair(value); | 92 const CSSValuePair& pair = toCSSValuePair(value); |
| 92 const CSSValue& side = convertWidth ? pair.first() : pair.second(); | 93 const CSSValue& side = convertWidth ? pair.first() : pair.second(); |
| 93 if (side.isPrimitiveValue() && toCSSPrimitiveValue(side).getValueID() ==
CSSValueAuto) | 94 if (side.isIdentifierValue() && toCSSIdentifierValue(side).getValueID()
== CSSValueAuto) |
| 94 return convertKeyword(CSSValueAuto); | 95 return convertKeyword(CSSValueAuto); |
| 95 return wrapConvertedLength(LengthInterpolationFunctions::maybeConvertCSS
Value(side)); | 96 return wrapConvertedLength(LengthInterpolationFunctions::maybeConvertCSS
Value(side)); |
| 96 } | 97 } |
| 97 | 98 |
| 98 if (!value.isPrimitiveValue()) | 99 if (!value.isIdentifierValue() && !value.isPrimitiveValue()) |
| 99 return nullptr; | 100 return nullptr; |
| 100 CSSValueID keyword = toCSSPrimitiveValue(value).getValueID(); | 101 if (value.isIdentifierValue()) |
| 101 if (keyword) | 102 return convertKeyword(toCSSIdentifierValue(value).getValueID()); |
| 102 return convertKeyword(keyword); | |
| 103 | 103 |
| 104 // A single length is equivalent to "<length> auto". | 104 // A single length is equivalent to "<length> auto". |
| 105 if (convertWidth) | 105 if (convertWidth) |
| 106 return wrapConvertedLength(LengthInterpolationFunctions::maybeConvertCSS
Value(value)); | 106 return wrapConvertedLength(LengthInterpolationFunctions::maybeConvertCSS
Value(value)); |
| 107 return convertKeyword(CSSValueAuto); | 107 return convertKeyword(CSSValueAuto); |
| 108 } | 108 } |
| 109 | 109 |
| 110 PairwiseInterpolationValue SizeInterpolationFunctions::maybeMergeSingles(Interpo
lationValue&& start, InterpolationValue&& end) | 110 PairwiseInterpolationValue SizeInterpolationFunctions::maybeMergeSingles(Interpo
lationValue&& start, InterpolationValue&& end) |
| 111 { | 111 { |
| 112 if (!nonInterpolableValuesAreCompatible(start.nonInterpolableValue.get(), en
d.nonInterpolableValue.get())) | 112 if (!nonInterpolableValuesAreCompatible(start.nonInterpolableValue.get(), en
d.nonInterpolableValue.get())) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 NOTREACHED(); | 177 NOTREACHED(); |
| 178 break; | 178 break; |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 return FillSize(SizeLength, LengthSize( | 181 return FillSize(SizeLength, LengthSize( |
| 182 createLength(interpolableValueA, sideA, conversionData), | 182 createLength(interpolableValueA, sideA, conversionData), |
| 183 createLength(interpolableValueB, sideB, conversionData))); | 183 createLength(interpolableValueB, sideB, conversionData))); |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace blink | 186 } // namespace blink |
| OLD | NEW |