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/CSSImageSliceInterpolationType.h" | 5 #include "core/animation/CSSImageSliceInterpolationType.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "core/animation/CSSLengthInterpolationType.h" | 8 #include "core/animation/CSSLengthInterpolationType.h" |
9 #include "core/animation/ImageSlicePropertyFunctions.h" | 9 #include "core/animation/ImageSlicePropertyFunctions.h" |
10 #include "core/animation/SideIndex.h" | 10 #include "core/animation/SideIndex.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 const SliceTypes types_; | 72 const SliceTypes types_; |
73 }; | 73 }; |
74 | 74 |
75 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSImageSliceNonInterpolableValue); | 75 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSImageSliceNonInterpolableValue); |
76 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSImageSliceNonInterpolableValue); | 76 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSImageSliceNonInterpolableValue); |
77 | 77 |
78 namespace { | 78 namespace { |
79 | 79 |
80 class UnderlyingSliceTypesChecker | 80 class UnderlyingSliceTypesChecker |
81 : public InterpolationType::ConversionChecker { | 81 : public CSSInterpolationType::CSSConversionChecker { |
82 public: | 82 public: |
83 static std::unique_ptr<UnderlyingSliceTypesChecker> Create( | 83 static std::unique_ptr<UnderlyingSliceTypesChecker> Create( |
84 const SliceTypes& underlying_types) { | 84 const SliceTypes& underlying_types) { |
85 return WTF::WrapUnique(new UnderlyingSliceTypesChecker(underlying_types)); | 85 return WTF::WrapUnique(new UnderlyingSliceTypesChecker(underlying_types)); |
86 } | 86 } |
87 | 87 |
88 static SliceTypes GetUnderlyingSliceTypes( | 88 static SliceTypes GetUnderlyingSliceTypes( |
89 const InterpolationValue& underlying) { | 89 const InterpolationValue& underlying) { |
90 return ToCSSImageSliceNonInterpolableValue( | 90 return ToCSSImageSliceNonInterpolableValue( |
91 *underlying.non_interpolable_value) | 91 *underlying.non_interpolable_value) |
92 .Types(); | 92 .Types(); |
93 } | 93 } |
94 | 94 |
95 private: | 95 private: |
96 UnderlyingSliceTypesChecker(const SliceTypes& underlying_types) | 96 UnderlyingSliceTypesChecker(const SliceTypes& underlying_types) |
97 : underlying_types_(underlying_types) {} | 97 : underlying_types_(underlying_types) {} |
98 | 98 |
99 bool IsValid(const InterpolationEnvironment&, | 99 bool IsValid(const StyleResolverState&, |
100 const InterpolationValue& underlying) const final { | 100 const InterpolationValue& underlying) const final { |
101 return underlying_types_ == GetUnderlyingSliceTypes(underlying); | 101 return underlying_types_ == GetUnderlyingSliceTypes(underlying); |
102 } | 102 } |
103 | 103 |
104 const SliceTypes underlying_types_; | 104 const SliceTypes underlying_types_; |
105 }; | 105 }; |
106 | 106 |
107 class InheritedSliceTypesChecker : public InterpolationType::ConversionChecker { | 107 class InheritedSliceTypesChecker |
| 108 : public CSSInterpolationType::CSSConversionChecker { |
108 public: | 109 public: |
109 static std::unique_ptr<InheritedSliceTypesChecker> Create( | 110 static std::unique_ptr<InheritedSliceTypesChecker> Create( |
110 CSSPropertyID property, | 111 CSSPropertyID property, |
111 const SliceTypes& inherited_types) { | 112 const SliceTypes& inherited_types) { |
112 return WTF::WrapUnique( | 113 return WTF::WrapUnique( |
113 new InheritedSliceTypesChecker(property, inherited_types)); | 114 new InheritedSliceTypesChecker(property, inherited_types)); |
114 } | 115 } |
115 | 116 |
116 private: | 117 private: |
117 InheritedSliceTypesChecker(CSSPropertyID property, | 118 InheritedSliceTypesChecker(CSSPropertyID property, |
118 const SliceTypes& inherited_types) | 119 const SliceTypes& inherited_types) |
119 : property_(property), inherited_types_(inherited_types) {} | 120 : property_(property), inherited_types_(inherited_types) {} |
120 | 121 |
121 bool IsValid(const InterpolationEnvironment& environment, | 122 bool IsValid(const StyleResolverState& state, |
122 const InterpolationValue& underlying) const final { | 123 const InterpolationValue& underlying) const final { |
123 return inherited_types_ == | 124 return inherited_types_ == |
124 SliceTypes(ImageSlicePropertyFunctions::GetImageSlice( | 125 SliceTypes(ImageSlicePropertyFunctions::GetImageSlice( |
125 property_, *environment.GetState().ParentStyle())); | 126 property_, *state.ParentStyle())); |
126 } | 127 } |
127 | 128 |
128 const CSSPropertyID property_; | 129 const CSSPropertyID property_; |
129 const SliceTypes inherited_types_; | 130 const SliceTypes inherited_types_; |
130 }; | 131 }; |
131 | 132 |
132 InterpolationValue ConvertImageSlice(const ImageSlice& slice, double zoom) { | 133 InterpolationValue ConvertImageSlice(const ImageSlice& slice, double zoom) { |
133 std::unique_ptr<InterpolableList> list = | 134 std::unique_ptr<InterpolableList> list = |
134 InterpolableList::Create(kSideIndexCount); | 135 InterpolableList::Create(kSideIndexCount); |
135 const Length* sides[kSideIndexCount] = {}; | 136 const Length* sides[kSideIndexCount] = {}; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 ? Length(value * style.EffectiveZoom(), kFixed) | 273 ? Length(value * style.EffectiveZoom(), kFixed) |
273 : Length(value, kPercent); | 274 : Length(value, kPercent); |
274 }; | 275 }; |
275 LengthBox box(convert_side(kSideTop), convert_side(kSideRight), | 276 LengthBox box(convert_side(kSideTop), convert_side(kSideRight), |
276 convert_side(kSideBottom), convert_side(kSideLeft)); | 277 convert_side(kSideBottom), convert_side(kSideLeft)); |
277 ImageSlicePropertyFunctions::SetImageSlice(CssProperty(), style, | 278 ImageSlicePropertyFunctions::SetImageSlice(CssProperty(), style, |
278 ImageSlice(box, types.fill)); | 279 ImageSlice(box, types.fill)); |
279 } | 280 } |
280 | 281 |
281 } // namespace blink | 282 } // namespace blink |
OLD | NEW |