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 #ifndef CSSSizeListInterpolationType_h | 5 #ifndef CSSSizeListInterpolationType_h |
6 #define CSSSizeListInterpolationType_h | 6 #define CSSSizeListInterpolationType_h |
7 | 7 |
8 #include "core/animation/CSSLengthInterpolationType.h" | 8 #include "core/animation/CSSInterpolationType.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 | 9 |
14 namespace blink { | 10 namespace blink { |
15 | 11 |
16 class CSSSizeListInterpolationType : public CSSLengthListInterpolationType { | 12 class CSSSizeListInterpolationType : public CSSInterpolationType { |
suzyh_UTC10 (ex-contributor)
2016/08/26 04:14:34
In the CL description I think it would be useful t
alancutter (OOO until 2018)
2016/08/26 13:31:48
Done.
| |
17 public: | 13 public: |
18 CSSSizeListInterpolationType(CSSPropertyID property) | 14 CSSSizeListInterpolationType(CSSPropertyID property) |
19 : CSSLengthListInterpolationType(property) | 15 : CSSInterpolationType(property) |
20 { } | 16 { } |
21 | 17 |
18 InterpolationValue maybeConvertUnderlyingValue(const InterpolationEnvironmen t&) const final; | |
19 void composite(UnderlyingValueOwner&, double underlyingFraction, const Inter polationValue&, double interpolationFraction) const final; | |
20 void apply(const InterpolableValue&, const NonInterpolableValue*, Interpolat ionEnvironment&) const final; | |
21 | |
22 private: | 22 private: |
23 InterpolationValue maybeConvertValue(const CSSValue& value, const StyleResol verState&, ConversionCheckers&) const final | 23 InterpolationValue maybeConvertNeutral(const InterpolationValue& underlying, ConversionCheckers&) const final; |
24 { | 24 InterpolationValue maybeConvertInitial(const StyleResolverState&, Conversion Checkers&) const final; |
25 CSSValueList* tempList = nullptr; | 25 InterpolationValue maybeConvertInherit(const StyleResolverState&, Conversion Checkers&) const final; |
26 if (!value.isBaseValueList()) { | 26 InterpolationValue maybeConvertValue(const CSSValue&, const StyleResolverSta te&, ConversionCheckers&) const final; |
27 tempList = CSSValueList::createCommaSeparated(); | |
28 tempList->append(value); | |
29 } | |
30 const CSSValueList& list = value.isBaseValueList() ? toCSSValueList(valu e) : *tempList; | |
31 | 27 |
32 // Only size lists without keywords may interpolate smoothly: | 28 PairwiseInterpolationValue maybeMergeSingles(InterpolationValue&& start, Int erpolationValue&& end) const final; |
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 }; | 29 }; |
43 | 30 |
44 } // namespace blink | 31 } // namespace blink |
45 | 32 |
46 #endif // CSSSizeListInterpolationType_h | 33 #endif // CSSSizeListInterpolationType_h |
OLD | NEW |