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 "core/animation/CSSImageListInterpolationType.h" | 5 #include "core/animation/CSSImageListInterpolationType.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "core/animation/CSSImageInterpolationType.h" | 8 #include "core/animation/CSSImageInterpolationType.h" |
9 #include "core/animation/ImageListPropertyFunctions.h" | 9 #include "core/animation/ImageListPropertyFunctions.h" |
10 #include "core/animation/ListInterpolationFunctions.h" | 10 #include "core/animation/ListInterpolationFunctions.h" |
11 #include "core/css/CSSIdentifierValue.h" | 11 #include "core/css/CSSIdentifierValue.h" |
12 #include "core/css/CSSValueList.h" | 12 #include "core/css/CSSValueList.h" |
13 #include "core/css/resolver/StyleResolverState.h" | 13 #include "core/css/resolver/StyleResolverState.h" |
14 #include "platform/wtf/PtrUtil.h" | 14 #include "platform/wtf/PtrUtil.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 class UnderlyingImageListChecker : public InterpolationType::ConversionChecker { | 18 class UnderlyingImageListChecker |
| 19 : public CSSInterpolationType::CSSConversionChecker { |
19 public: | 20 public: |
20 ~UnderlyingImageListChecker() final {} | 21 ~UnderlyingImageListChecker() final {} |
21 | 22 |
22 static std::unique_ptr<UnderlyingImageListChecker> Create( | 23 static std::unique_ptr<UnderlyingImageListChecker> Create( |
23 const InterpolationValue& underlying) { | 24 const InterpolationValue& underlying) { |
24 return WTF::WrapUnique(new UnderlyingImageListChecker(underlying)); | 25 return WTF::WrapUnique(new UnderlyingImageListChecker(underlying)); |
25 } | 26 } |
26 | 27 |
27 private: | 28 private: |
28 UnderlyingImageListChecker(const InterpolationValue& underlying) | 29 UnderlyingImageListChecker(const InterpolationValue& underlying) |
29 : underlying_(underlying.Clone()) {} | 30 : underlying_(underlying.Clone()) {} |
30 | 31 |
31 bool IsValid(const InterpolationEnvironment&, | 32 bool IsValid(const StyleResolverState&, |
32 const InterpolationValue& underlying) const final { | 33 const InterpolationValue& underlying) const final { |
33 return ListInterpolationFunctions::EqualValues( | 34 return ListInterpolationFunctions::EqualValues( |
34 underlying_, underlying, | 35 underlying_, underlying, |
35 CSSImageInterpolationType::EqualNonInterpolableValues); | 36 CSSImageInterpolationType::EqualNonInterpolableValues); |
36 } | 37 } |
37 | 38 |
38 const InterpolationValue underlying_; | 39 const InterpolationValue underlying_; |
39 }; | 40 }; |
40 | 41 |
41 InterpolationValue CSSImageListInterpolationType::MaybeConvertNeutral( | 42 InterpolationValue CSSImageListInterpolationType::MaybeConvertNeutral( |
(...skipping 17 matching lines...) Expand all Loading... |
59 if (image_list.size() == 0) | 60 if (image_list.size() == 0) |
60 return nullptr; | 61 return nullptr; |
61 | 62 |
62 return ListInterpolationFunctions::CreateList( | 63 return ListInterpolationFunctions::CreateList( |
63 image_list.size(), [&image_list](size_t index) { | 64 image_list.size(), [&image_list](size_t index) { |
64 return CSSImageInterpolationType::MaybeConvertStyleImage( | 65 return CSSImageInterpolationType::MaybeConvertStyleImage( |
65 image_list[index].Get(), false); | 66 image_list[index].Get(), false); |
66 }); | 67 }); |
67 } | 68 } |
68 | 69 |
69 class InheritedImageListChecker : public InterpolationType::ConversionChecker { | 70 class InheritedImageListChecker |
| 71 : public CSSInterpolationType::CSSConversionChecker { |
70 public: | 72 public: |
71 ~InheritedImageListChecker() final {} | 73 ~InheritedImageListChecker() final {} |
72 | 74 |
73 static std::unique_ptr<InheritedImageListChecker> Create( | 75 static std::unique_ptr<InheritedImageListChecker> Create( |
74 CSSPropertyID property, | 76 CSSPropertyID property, |
75 const StyleImageList& inherited_image_list) { | 77 const StyleImageList& inherited_image_list) { |
76 return WTF::WrapUnique( | 78 return WTF::WrapUnique( |
77 new InheritedImageListChecker(property, inherited_image_list)); | 79 new InheritedImageListChecker(property, inherited_image_list)); |
78 } | 80 } |
79 | 81 |
80 private: | 82 private: |
81 InheritedImageListChecker(CSSPropertyID property, | 83 InheritedImageListChecker(CSSPropertyID property, |
82 const StyleImageList& inherited_image_list) | 84 const StyleImageList& inherited_image_list) |
83 : property_(property), inherited_image_list_(inherited_image_list) {} | 85 : property_(property), inherited_image_list_(inherited_image_list) {} |
84 | 86 |
85 bool IsValid(const InterpolationEnvironment& environment, | 87 bool IsValid(const StyleResolverState& state, |
86 const InterpolationValue& underlying) const final { | 88 const InterpolationValue& underlying) const final { |
87 StyleImageList inherited_image_list; | 89 StyleImageList inherited_image_list; |
88 ImageListPropertyFunctions::GetImageList( | 90 ImageListPropertyFunctions::GetImageList(property_, *state.ParentStyle(), |
89 property_, *environment.GetState().ParentStyle(), inherited_image_list); | 91 inherited_image_list); |
90 return inherited_image_list_ == inherited_image_list; | 92 return inherited_image_list_ == inherited_image_list; |
91 } | 93 } |
92 | 94 |
93 CSSPropertyID property_; | 95 CSSPropertyID property_; |
94 StyleImageList inherited_image_list_; | 96 StyleImageList inherited_image_list_; |
95 }; | 97 }; |
96 | 98 |
97 InterpolationValue CSSImageListInterpolationType::MaybeConvertInherit( | 99 InterpolationValue CSSImageListInterpolationType::MaybeConvertInherit( |
98 const StyleResolverState& state, | 100 const StyleResolverState& state, |
99 ConversionCheckers& conversion_checkers) const { | 101 ConversionCheckers& conversion_checkers) const { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 for (size_t i = 0; i < length; i++) { | 185 for (size_t i = 0; i < length; i++) { |
184 image_list[i] = CSSImageInterpolationType::ResolveStyleImage( | 186 image_list[i] = CSSImageInterpolationType::ResolveStyleImage( |
185 CssProperty(), *interpolable_list.Get(i), non_interpolable_list.Get(i), | 187 CssProperty(), *interpolable_list.Get(i), non_interpolable_list.Get(i), |
186 state); | 188 state); |
187 } | 189 } |
188 ImageListPropertyFunctions::SetImageList(CssProperty(), *state.Style(), | 190 ImageListPropertyFunctions::SetImageList(CssProperty(), *state.Style(), |
189 image_list); | 191 image_list); |
190 } | 192 } |
191 | 193 |
192 } // namespace blink | 194 } // namespace blink |
OLD | NEW |