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

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

Issue 1885353004: Add ComputedStyle constructor and getter to InterpolationEnvironment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_transformInterpolationType
Patch Set: Rebased Created 4 years, 4 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 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 "core/animation/CSSLengthInterpolationType.h" 7 #include "core/animation/CSSLengthInterpolationType.h"
8 #include "core/animation/ImageSlicePropertyFunctions.h" 8 #include "core/animation/ImageSlicePropertyFunctions.h"
9 #include "core/css/CSSBorderImageSliceValue.h" 9 #include "core/css/CSSBorderImageSliceValue.h"
10 #include "core/css/resolver/StyleResolverState.h" 10 #include "core/css/resolver/StyleResolverState.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 const CSSPrimitiveValue& side = *sides[i]; 189 const CSSPrimitiveValue& side = *sides[i];
190 ASSERT_UNUSED(side, side.isNumber() || side.isPercentage()); 190 ASSERT_UNUSED(side, side.isNumber() || side.isPercentage());
191 list->set(i, InterpolableNumber::create(sides[i]->getDoubleValue())); 191 list->set(i, InterpolableNumber::create(sides[i]->getDoubleValue()));
192 } 192 }
193 193
194 return InterpolationValue(std::move(list), CSSImageSliceNonInterpolableValue ::create(SliceTypes(slice))); 194 return InterpolationValue(std::move(list), CSSImageSliceNonInterpolableValue ::create(SliceTypes(slice)));
195 } 195 }
196 196
197 InterpolationValue CSSImageSliceInterpolationType::maybeConvertUnderlyingValue(c onst InterpolationEnvironment& environment) const 197 InterpolationValue CSSImageSliceInterpolationType::maybeConvertUnderlyingValue(c onst InterpolationEnvironment& environment) const
198 { 198 {
199 const ComputedStyle& style = *environment.state().style(); 199 const ComputedStyle& style = environment.style();
200 return convertImageSlice(ImageSlicePropertyFunctions::getImageSlice(cssPrope rty(), style), style.effectiveZoom()); 200 return convertImageSlice(ImageSlicePropertyFunctions::getImageSlice(cssPrope rty(), style), style.effectiveZoom());
201 } 201 }
202 202
203 PairwiseInterpolationValue CSSImageSliceInterpolationType::maybeMergeSingles(Int erpolationValue&& start, InterpolationValue&& end) const 203 PairwiseInterpolationValue CSSImageSliceInterpolationType::maybeMergeSingles(Int erpolationValue&& start, InterpolationValue&& end) const
204 { 204 {
205 const SliceTypes& startSliceTypes = toCSSImageSliceNonInterpolableValue(*sta rt.nonInterpolableValue).types(); 205 const SliceTypes& startSliceTypes = toCSSImageSliceNonInterpolableValue(*sta rt.nonInterpolableValue).types();
206 const SliceTypes& endSliceTypes = toCSSImageSliceNonInterpolableValue(*end.n onInterpolableValue).types(); 206 const SliceTypes& endSliceTypes = toCSSImageSliceNonInterpolableValue(*end.n onInterpolableValue).types();
207 207
208 if (startSliceTypes != endSliceTypes) 208 if (startSliceTypes != endSliceTypes)
209 return nullptr; 209 return nullptr;
210 210
211 return PairwiseInterpolationValue(std::move(start.interpolableValue), std::m ove(end.interpolableValue), start.nonInterpolableValue.release()); 211 return PairwiseInterpolationValue(std::move(start.interpolableValue), std::m ove(end.interpolableValue), start.nonInterpolableValue.release());
212 } 212 }
213 213
214 void CSSImageSliceInterpolationType::composite(UnderlyingValueOwner& underlyingV alueOwner, double underlyingFraction, const InterpolationValue& value, double in terpolationFraction) const 214 void CSSImageSliceInterpolationType::composite(UnderlyingValueOwner& underlyingV alueOwner, double underlyingFraction, const InterpolationValue& value, double in terpolationFraction) const
215 { 215 {
216 const SliceTypes& underlyingTypes = toCSSImageSliceNonInterpolableValue(*und erlyingValueOwner.value().nonInterpolableValue).types(); 216 const SliceTypes& underlyingTypes = toCSSImageSliceNonInterpolableValue(*und erlyingValueOwner.value().nonInterpolableValue).types();
217 const SliceTypes& types = toCSSImageSliceNonInterpolableValue(*value.nonInte rpolableValue).types(); 217 const SliceTypes& types = toCSSImageSliceNonInterpolableValue(*value.nonInte rpolableValue).types();
218 218
219 if (underlyingTypes == types) 219 if (underlyingTypes == types)
220 underlyingValueOwner.mutableValue().interpolableValue->scaleAndAdd(under lyingFraction, *value.interpolableValue); 220 underlyingValueOwner.mutableValue().interpolableValue->scaleAndAdd(under lyingFraction, *value.interpolableValue);
221 else 221 else
222 underlyingValueOwner.set(*this, value); 222 underlyingValueOwner.set(*this, value);
223 } 223 }
224 224
225 void CSSImageSliceInterpolationType::apply(const InterpolableValue& interpolable Value, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironmen t& environment) const 225 void CSSImageSliceInterpolationType::apply(const InterpolableValue& interpolable Value, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironmen t& environment) const
226 { 226 {
227 ComputedStyle& style = *environment.state().style(); 227 ComputedStyle& style = environment.style();
228 const InterpolableList& list = toInterpolableList(interpolableValue); 228 const InterpolableList& list = toInterpolableList(interpolableValue);
229 const SliceTypes& types = toCSSImageSliceNonInterpolableValue(nonInterpolabl eValue)->types(); 229 const SliceTypes& types = toCSSImageSliceNonInterpolableValue(nonInterpolabl eValue)->types();
230 const auto& convertSide = [&types, &list, &style](size_t index) 230 const auto& convertSide = [&types, &list, &style](size_t index)
231 { 231 {
232 float value = clampTo<float>(toInterpolableNumber(list.get(index))->valu e(), 0); 232 float value = clampTo<float>(toInterpolableNumber(list.get(index))->valu e(), 0);
233 return types.isNumber[index] ? Length(value * style.effectiveZoom(), Fix ed) : Length(value, Percent); 233 return types.isNumber[index] ? Length(value * style.effectiveZoom(), Fix ed) : Length(value, Percent);
234 }; 234 };
235 LengthBox box( 235 LengthBox box(
236 convertSide(SideTop), 236 convertSide(SideTop),
237 convertSide(SideRight), 237 convertSide(SideRight),
238 convertSide(SideBottom), 238 convertSide(SideBottom),
239 convertSide(SideLeft)); 239 convertSide(SideLeft));
240 ImageSlicePropertyFunctions::setImageSlice(cssProperty(), style, ImageSlice( box, types.fill)); 240 ImageSlicePropertyFunctions::setImageSlice(cssProperty(), style, ImageSlice( box, types.fill));
241 } 241 }
242 242
243 } // namespace blink 243 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698