OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CSSSizeListInterpolationType_h |
| 6 #define CSSSizeListInterpolationType_h |
| 7 |
| 8 #include "core/animation/CSSLengthInterpolationType.h" |
| 9 #include "core/animation/CSSLengthListInterpolationType.h" |
| 10 #include "core/animation/ListInterpolationFunctions.h" |
| 11 #include "core/css/CSSValueList.h" |
| 12 #include "core/css/CSSValuePair.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 class CSSSizeListInterpolationType : public CSSLengthListInterpolationType { |
| 17 public: |
| 18 CSSSizeListInterpolationType(CSSPropertyID property) |
| 19 : CSSLengthListInterpolationType(property) |
| 20 { } |
| 21 |
| 22 private: |
| 23 InterpolationValue maybeConvertValue(const CSSValue& value, const StyleResol
verState&, ConversionCheckers&) const final |
| 24 { |
| 25 RefPtrWillBeRawPtr<CSSValueList> tempList; |
| 26 if (!value.isBaseValueList()) { |
| 27 tempList = CSSValueList::createCommaSeparated(); |
| 28 tempList->append(const_cast<CSSValue*>(&value)); // Take ref. |
| 29 } |
| 30 const CSSValueList& list = value.isBaseValueList() ? toCSSValueList(valu
e) : *tempList; |
| 31 |
| 32 // Only size lists without keywords may interpolate smoothly: |
| 33 // https://drafts.csswg.org/css-backgrounds-3/#the-background-size |
| 34 return ListInterpolationFunctions::createList(list.length() * 2, [&list]
(size_t index) -> InterpolationValue { |
| 35 const CSSValue& item = *list.item(index / 2); |
| 36 if (!item.isValuePair()) |
| 37 return nullptr; |
| 38 const CSSValuePair& pair = toCSSValuePair(item); |
| 39 return CSSLengthInterpolationType::maybeConvertCSSValue(index % 2 ==
0 ? pair.first() : pair.second()); |
| 40 }); |
| 41 } |
| 42 }; |
| 43 |
| 44 } // namespace blink |
| 45 |
| 46 #endif // CSSSizeListInterpolationType_h |
OLD | NEW |