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/CSSLengthListInterpolationType.h" | 5 #include "core/animation/CSSLengthListInterpolationType.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "core/animation/LengthInterpolationFunctions.h" | 8 #include "core/animation/LengthInterpolationFunctions.h" |
9 #include "core/animation/LengthListPropertyFunctions.h" | 9 #include "core/animation/LengthListPropertyFunctions.h" |
10 #include "core/animation/ListInterpolationFunctions.h" | 10 #include "core/animation/ListInterpolationFunctions.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 InterpolationValue CSSLengthListInterpolationType::MaybeConvertInitial( | 54 InterpolationValue CSSLengthListInterpolationType::MaybeConvertInitial( |
55 const StyleResolverState&, | 55 const StyleResolverState&, |
56 ConversionCheckers& conversion_checkers) const { | 56 ConversionCheckers& conversion_checkers) const { |
57 Vector<Length> initial_length_list; | 57 Vector<Length> initial_length_list; |
58 if (!LengthListPropertyFunctions::GetInitialLengthList(CssProperty(), | 58 if (!LengthListPropertyFunctions::GetInitialLengthList(CssProperty(), |
59 initial_length_list)) | 59 initial_length_list)) |
60 return nullptr; | 60 return nullptr; |
61 return MaybeConvertLengthList(initial_length_list, 1); | 61 return MaybeConvertLengthList(initial_length_list, 1); |
62 } | 62 } |
63 | 63 |
64 class InheritedLengthListChecker : public InterpolationType::ConversionChecker { | 64 class InheritedLengthListChecker |
| 65 : public CSSInterpolationType::CSSConversionChecker { |
65 public: | 66 public: |
66 ~InheritedLengthListChecker() final {} | 67 ~InheritedLengthListChecker() final {} |
67 | 68 |
68 static std::unique_ptr<InheritedLengthListChecker> Create( | 69 static std::unique_ptr<InheritedLengthListChecker> Create( |
69 CSSPropertyID property, | 70 CSSPropertyID property, |
70 const Vector<Length>& inherited_length_list) { | 71 const Vector<Length>& inherited_length_list) { |
71 return WTF::WrapUnique( | 72 return WTF::WrapUnique( |
72 new InheritedLengthListChecker(property, inherited_length_list)); | 73 new InheritedLengthListChecker(property, inherited_length_list)); |
73 } | 74 } |
74 | 75 |
75 private: | 76 private: |
76 InheritedLengthListChecker(CSSPropertyID property, | 77 InheritedLengthListChecker(CSSPropertyID property, |
77 const Vector<Length>& inherited_length_list) | 78 const Vector<Length>& inherited_length_list) |
78 : property_(property), inherited_length_list_(inherited_length_list) {} | 79 : property_(property), inherited_length_list_(inherited_length_list) {} |
79 | 80 |
80 bool IsValid(const InterpolationEnvironment& environment, | 81 bool IsValid(const StyleResolverState& state, |
81 const InterpolationValue& underlying) const final { | 82 const InterpolationValue& underlying) const final { |
82 Vector<Length> inherited_length_list; | 83 Vector<Length> inherited_length_list; |
83 LengthListPropertyFunctions::GetLengthList( | 84 LengthListPropertyFunctions::GetLengthList(property_, *state.ParentStyle(), |
84 property_, *environment.GetState().ParentStyle(), | 85 inherited_length_list); |
85 inherited_length_list); | |
86 return inherited_length_list_ == inherited_length_list; | 86 return inherited_length_list_ == inherited_length_list; |
87 } | 87 } |
88 | 88 |
89 CSSPropertyID property_; | 89 CSSPropertyID property_; |
90 Vector<Length> inherited_length_list_; | 90 Vector<Length> inherited_length_list_; |
91 }; | 91 }; |
92 | 92 |
93 InterpolationValue CSSLengthListInterpolationType::MaybeConvertInherit( | 93 InterpolationValue CSSLengthListInterpolationType::MaybeConvertInherit( |
94 const StyleResolverState& state, | 94 const StyleResolverState& state, |
95 ConversionCheckers& conversion_checkers) const { | 95 ConversionCheckers& conversion_checkers) const { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 for (size_t i = 0; i < length; i++) { | 165 for (size_t i = 0; i < length; i++) { |
166 result[i] = LengthInterpolationFunctions::CreateLength( | 166 result[i] = LengthInterpolationFunctions::CreateLength( |
167 *interpolable_list.Get(i), non_interpolable_list.Get(i), | 167 *interpolable_list.Get(i), non_interpolable_list.Get(i), |
168 state.CssToLengthConversionData(), value_range_); | 168 state.CssToLengthConversionData(), value_range_); |
169 } | 169 } |
170 LengthListPropertyFunctions::SetLengthList(CssProperty(), *state.Style(), | 170 LengthListPropertyFunctions::SetLengthList(CssProperty(), *state.Style(), |
171 std::move(result)); | 171 std::move(result)); |
172 } | 172 } |
173 | 173 |
174 } // namespace blink | 174 } // namespace blink |
OLD | NEW |