Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: third_party/WebKit/Source/core/animation/CSSImageInterpolationType.cpp

Issue 2812213002: Add CSSInterpolationType specific ConversionChecker (Closed)
Patch Set: rebased Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/CSSImageInterpolationType.h" 5 #include "core/animation/CSSImageInterpolationType.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/animation/ImagePropertyFunctions.h" 8 #include "core/animation/ImagePropertyFunctions.h"
9 #include "core/css/CSSCrossfadeValue.h" 9 #include "core/css/CSSCrossfadeValue.h"
10 #include "core/css/CSSPrimitiveValue.h" 10 #include "core/css/CSSPrimitiveValue.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return state.GetStyleImage(property, *image); 122 return state.GetStyleImage(property, *image);
123 } 123 }
124 124
125 bool CSSImageInterpolationType::EqualNonInterpolableValues( 125 bool CSSImageInterpolationType::EqualNonInterpolableValues(
126 const NonInterpolableValue* a, 126 const NonInterpolableValue* a,
127 const NonInterpolableValue* b) { 127 const NonInterpolableValue* b) {
128 return ToCSSImageNonInterpolableValue(*a).Equals( 128 return ToCSSImageNonInterpolableValue(*a).Equals(
129 ToCSSImageNonInterpolableValue(*b)); 129 ToCSSImageNonInterpolableValue(*b));
130 } 130 }
131 131
132 class UnderlyingImageChecker : public InterpolationType::ConversionChecker { 132 class UnderlyingImageChecker
133 : public CSSInterpolationType::CSSConversionChecker {
133 public: 134 public:
134 ~UnderlyingImageChecker() final {} 135 ~UnderlyingImageChecker() final {}
135 136
136 static std::unique_ptr<UnderlyingImageChecker> Create( 137 static std::unique_ptr<UnderlyingImageChecker> Create(
137 const InterpolationValue& underlying) { 138 const InterpolationValue& underlying) {
138 return WTF::WrapUnique(new UnderlyingImageChecker(underlying)); 139 return WTF::WrapUnique(new UnderlyingImageChecker(underlying));
139 } 140 }
140 141
141 private: 142 private:
142 UnderlyingImageChecker(const InterpolationValue& underlying) 143 UnderlyingImageChecker(const InterpolationValue& underlying)
143 : underlying_(underlying.Clone()) {} 144 : underlying_(underlying.Clone()) {}
144 145
145 bool IsValid(const InterpolationEnvironment&, 146 bool IsValid(const StyleResolverState&,
146 const InterpolationValue& underlying) const final { 147 const InterpolationValue& underlying) const final {
147 if (!underlying && !underlying_) 148 if (!underlying && !underlying_)
148 return true; 149 return true;
149 if (!underlying || !underlying_) 150 if (!underlying || !underlying_)
150 return false; 151 return false;
151 return underlying_.interpolable_value->Equals( 152 return underlying_.interpolable_value->Equals(
152 *underlying.interpolable_value) && 153 *underlying.interpolable_value) &&
153 CSSImageInterpolationType::EqualNonInterpolableValues( 154 CSSImageInterpolationType::EqualNonInterpolableValues(
154 underlying_.non_interpolable_value.Get(), 155 underlying_.non_interpolable_value.Get(),
155 underlying.non_interpolable_value.Get()); 156 underlying.non_interpolable_value.Get());
156 } 157 }
157 158
158 const InterpolationValue underlying_; 159 const InterpolationValue underlying_;
159 }; 160 };
160 161
161 InterpolationValue CSSImageInterpolationType::MaybeConvertNeutral( 162 InterpolationValue CSSImageInterpolationType::MaybeConvertNeutral(
162 const InterpolationValue& underlying, 163 const InterpolationValue& underlying,
163 ConversionCheckers& conversion_checkers) const { 164 ConversionCheckers& conversion_checkers) const {
164 conversion_checkers.push_back(UnderlyingImageChecker::Create(underlying)); 165 conversion_checkers.push_back(UnderlyingImageChecker::Create(underlying));
165 return InterpolationValue(underlying.Clone()); 166 return InterpolationValue(underlying.Clone());
166 } 167 }
167 168
168 InterpolationValue CSSImageInterpolationType::MaybeConvertInitial( 169 InterpolationValue CSSImageInterpolationType::MaybeConvertInitial(
169 const StyleResolverState&, 170 const StyleResolverState&,
170 ConversionCheckers& conversion_checkers) const { 171 ConversionCheckers& conversion_checkers) const {
171 return MaybeConvertStyleImage( 172 return MaybeConvertStyleImage(
172 ImagePropertyFunctions::GetInitialStyleImage(CssProperty()), true); 173 ImagePropertyFunctions::GetInitialStyleImage(CssProperty()), true);
173 } 174 }
174 175
175 class InheritedImageChecker : public InterpolationType::ConversionChecker { 176 class InheritedImageChecker
177 : public CSSInterpolationType::CSSConversionChecker {
176 public: 178 public:
177 ~InheritedImageChecker() final {} 179 ~InheritedImageChecker() final {}
178 180
179 static std::unique_ptr<InheritedImageChecker> Create( 181 static std::unique_ptr<InheritedImageChecker> Create(
180 CSSPropertyID property, 182 CSSPropertyID property,
181 StyleImage* inherited_image) { 183 StyleImage* inherited_image) {
182 return WTF::WrapUnique( 184 return WTF::WrapUnique(
183 new InheritedImageChecker(property, inherited_image)); 185 new InheritedImageChecker(property, inherited_image));
184 } 186 }
185 187
186 private: 188 private:
187 InheritedImageChecker(CSSPropertyID property, StyleImage* inherited_image) 189 InheritedImageChecker(CSSPropertyID property, StyleImage* inherited_image)
188 : property_(property), inherited_image_(inherited_image) {} 190 : property_(property), inherited_image_(inherited_image) {}
189 191
190 bool IsValid(const InterpolationEnvironment& environment, 192 bool IsValid(const StyleResolverState& state,
191 const InterpolationValue& underlying) const final { 193 const InterpolationValue& underlying) const final {
192 const StyleImage* inherited_image = ImagePropertyFunctions::GetStyleImage( 194 const StyleImage* inherited_image =
193 property_, *environment.GetState().ParentStyle()); 195 ImagePropertyFunctions::GetStyleImage(property_, *state.ParentStyle());
194 if (!inherited_image_ && !inherited_image) 196 if (!inherited_image_ && !inherited_image)
195 return true; 197 return true;
196 if (!inherited_image_ || !inherited_image) 198 if (!inherited_image_ || !inherited_image)
197 return false; 199 return false;
198 return *inherited_image_ == *inherited_image; 200 return *inherited_image_ == *inherited_image;
199 } 201 }
200 202
201 CSSPropertyID property_; 203 CSSPropertyID property_;
202 Persistent<StyleImage> inherited_image_; 204 Persistent<StyleImage> inherited_image_;
203 }; 205 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 const InterpolableValue& interpolable_value, 244 const InterpolableValue& interpolable_value,
243 const NonInterpolableValue* non_interpolable_value, 245 const NonInterpolableValue* non_interpolable_value,
244 StyleResolverState& state) const { 246 StyleResolverState& state) const {
245 ImagePropertyFunctions::SetStyleImage( 247 ImagePropertyFunctions::SetStyleImage(
246 CssProperty(), *state.Style(), 248 CssProperty(), *state.Style(),
247 ResolveStyleImage(CssProperty(), interpolable_value, 249 ResolveStyleImage(CssProperty(), interpolable_value,
248 non_interpolable_value, state)); 250 non_interpolable_value, state));
249 } 251 }
250 252
251 } // namespace blink 253 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698