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

Side by Side Diff: Source/core/animation/LengthStyleInterpolation.cpp

Issue 1305383006: Oilpan: Unship CSSValues and AnimatableValues Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/animation/LengthStyleInterpolation.h" 6 #include "core/animation/LengthStyleInterpolation.h"
7 7
8 #include "core/animation/css/CSSAnimatableValueFactory.h" 8 #include "core/animation/css/CSSAnimatableValueFactory.h"
9 #include "core/css/CSSCalculationValue.h" 9 #include "core/css/CSSCalculationValue.h"
10 #include "core/css/resolver/StyleBuilder.h" 10 #include "core/css/resolver/StyleBuilder.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 if (primitiveValue.isValueID()) { 63 if (primitiveValue.isValueID()) {
64 CSSValueID valueID = primitiveValue.getValueID(); 64 CSSValueID valueID = primitiveValue.getValueID();
65 double pixels; 65 double pixels;
66 return pixelsForKeyword(property, valueID, pixels); 66 return pixelsForKeyword(property, valueID, pixels);
67 } 67 }
68 68
69 return primitiveValue.isLength() || primitiveValue.isPercentage() || primiti veValue.isCalculatedPercentageWithLength(); 69 return primitiveValue.isLength() || primitiveValue.isPercentage() || primiti veValue.isCalculatedPercentageWithLength();
70 } 70 }
71 71
72 PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolab leValue(const CSSValue& value, CSSPropertyID id) 72 PassOwnPtr<InterpolableValue> LengthStyleInterpolation::toInterpolableValue(cons t CSSValue& value, CSSPropertyID id)
73 { 73 {
74 ASSERT(canCreateFrom(value, id)); 74 ASSERT(canCreateFrom(value, id));
75 OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList ::create(2); 75 OwnPtr<InterpolableList> listOfValuesAndTypes = InterpolableList::create(2);
76 OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create (CSSPrimitiveValue::LengthUnitTypeCount); 76 OwnPtr<InterpolableList> listOfValues = InterpolableList::create(CSSPrimitiv eValue::LengthUnitTypeCount);
77 OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create( CSSPrimitiveValue::LengthUnitTypeCount); 77 OwnPtr<InterpolableList> listOfTypes = InterpolableList::create(CSSPrimitive Value::LengthUnitTypeCount);
78 78
79 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); 79 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value);
80 80
81 CSSLengthArray arrayOfValues; 81 CSSLengthArray arrayOfValues;
82 CSSPrimitiveValue::CSSLengthTypeArray arrayOfTypes; 82 CSSPrimitiveValue::CSSLengthTypeArray arrayOfTypes;
83 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) 83 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++)
84 arrayOfValues.append(0); 84 arrayOfValues.append(0);
85 85
86 arrayOfTypes.ensureSize(CSSPrimitiveValue::LengthUnitTypeCount); 86 arrayOfTypes.ensureSize(CSSPrimitiveValue::LengthUnitTypeCount);
87 if (primitive.isValueID()) { 87 if (primitive.isValueID()) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 219 }
220 } 220 }
221 221
222 namespace { 222 namespace {
223 223
224 static CSSPrimitiveValue::UnitType toUnitType(int lengthUnitType) 224 static CSSPrimitiveValue::UnitType toUnitType(int lengthUnitType)
225 { 225 {
226 return static_cast<CSSPrimitiveValue::UnitType>(CSSPrimitiveValue::lengthUni tTypeToUnitType(static_cast<CSSPrimitiveValue::LengthUnitType>(lengthUnitType))) ; 226 return static_cast<CSSPrimitiveValue::UnitType>(CSSPrimitiveValue::lengthUni tTypeToUnitType(static_cast<CSSPrimitiveValue::LengthUnitType>(lengthUnitType))) ;
227 } 227 }
228 228
229 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> constructCalcExpression(con st InterpolableList* list) 229 static PassRefPtr<CSSCalcExpressionNode> constructCalcExpression(const Interpola bleList* list)
230 { 230 {
231 const InterpolableList* listOfValues = toInterpolableList(list->get(0)); 231 const InterpolableList* listOfValues = toInterpolableList(list->get(0));
232 const InterpolableList* listOfTypes = toInterpolableList(list->get(1)); 232 const InterpolableList* listOfTypes = toInterpolableList(list->get(1));
233 RefPtrWillBeRawPtr<CSSCalcExpressionNode> expression = nullptr; 233 RefPtr<CSSCalcExpressionNode> expression = nullptr;
234 for (size_t position = 0; position < CSSPrimitiveValue::LengthUnitTypeCount; position++) { 234 for (size_t position = 0; position < CSSPrimitiveValue::LengthUnitTypeCount; position++) {
235 const InterpolableNumber *subValueType = toInterpolableNumber(listOfType s->get(position)); 235 const InterpolableNumber *subValueType = toInterpolableNumber(listOfType s->get(position));
236 if (!subValueType->value()) 236 if (!subValueType->value())
237 continue; 237 continue;
238 double value = toInterpolableNumber(listOfValues->get(position))->value( ); 238 double value = toInterpolableNumber(listOfValues->get(position))->value( );
239 RefPtrWillBeRawPtr<CSSCalcExpressionNode> currentTerm = CSSCalcValue::cr eateExpressionNode(CSSPrimitiveValue::create(value, toUnitType(position))); 239 RefPtr<CSSCalcExpressionNode> currentTerm = CSSCalcValue::createExpressi onNode(CSSPrimitiveValue::create(value, toUnitType(position)));
240 if (expression) 240 if (expression)
241 expression = CSSCalcValue::createExpressionNode(expression.release() , currentTerm.release(), CalcAdd); 241 expression = CSSCalcValue::createExpressionNode(expression.release() , currentTerm.release(), CalcAdd);
242 else 242 else
243 expression = currentTerm.release(); 243 expression = currentTerm.release();
244 } 244 }
245 return expression.release(); 245 return expression.release();
246 } 246 }
247 247
248 static double clampToRange(double x, ValueRange range) 248 static double clampToRange(double x, ValueRange range)
249 { 249 {
(...skipping 19 matching lines...) Expand all
269 if (hasPixels) 269 if (hasPixels)
270 return Length(CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixe lsAndPercent.pixels, range)), Fixed); 270 return Length(CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixe lsAndPercent.pixels, range)), Fixed);
271 if (hasPercent) 271 if (hasPercent)
272 return Length(clampToRange(pixelsAndPercent.percent, range), Percent); 272 return Length(clampToRange(pixelsAndPercent.percent, range), Percent);
273 ASSERT_NOT_REACHED(); 273 ASSERT_NOT_REACHED();
274 return Length(0, Fixed); 274 return Length(0, Fixed);
275 } 275 }
276 276
277 } 277 }
278 278
279 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> LengthStyleInterpolation::fromInterpol ableValue(const InterpolableValue& value, InterpolationRange range) 279 PassRefPtr<CSSPrimitiveValue> LengthStyleInterpolation::fromInterpolableValue(co nst InterpolableValue& value, InterpolationRange range)
280 { 280 {
281 const InterpolableList* listOfValuesAndTypes = toInterpolableList(&value); 281 const InterpolableList* listOfValuesAndTypes = toInterpolableList(&value);
282 const InterpolableList* listOfValues = toInterpolableList(listOfValuesAndTyp es->get(0)); 282 const InterpolableList* listOfValues = toInterpolableList(listOfValuesAndTyp es->get(0));
283 const InterpolableList* listOfTypes = toInterpolableList(listOfValuesAndType s->get(1)); 283 const InterpolableList* listOfTypes = toInterpolableList(listOfValuesAndType s->get(1));
284 unsigned unitTypeCount = 0; 284 unsigned unitTypeCount = 0;
285 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { 285 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
286 const InterpolableNumber* subType = toInterpolableNumber(listOfTypes->ge t(i)); 286 const InterpolableNumber* subType = toInterpolableNumber(listOfTypes->ge t(i));
287 if (subType->value()) { 287 if (subType->value()) {
288 unitTypeCount++; 288 unitTypeCount++;
289 } 289 }
(...skipping 18 matching lines...) Expand all
308 ValueRange valueRange = (range == RangeNonNegative) ? ValueRangeNonNegat ive : ValueRangeAll; 308 ValueRange valueRange = (range == RangeNonNegative) ? ValueRangeNonNegat ive : ValueRangeAll;
309 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre ssion(listOfValuesAndTypes), valueRange)); 309 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre ssion(listOfValuesAndTypes), valueRange));
310 } 310 }
311 } 311 }
312 312
313 void LengthStyleInterpolation::applyInterpolableValue(CSSPropertyID property, co nst InterpolableValue& value, InterpolationRange range, StyleResolverState& stat e, LengthSetter lengthSetter) 313 void LengthStyleInterpolation::applyInterpolableValue(CSSPropertyID property, co nst InterpolableValue& value, InterpolationRange range, StyleResolverState& stat e, LengthSetter lengthSetter)
314 { 314 {
315 if (lengthSetter && isPixelsOrPercentOnly(value)) { 315 if (lengthSetter && isPixelsOrPercentOnly(value)) {
316 (state.style()->*lengthSetter)(lengthFromInterpolableValue(value, range, state.style()->effectiveZoom())); 316 (state.style()->*lengthSetter)(lengthFromInterpolableValue(value, range, state.style()->effectiveZoom()));
317 #if ENABLE(ASSERT) 317 #if ENABLE(ASSERT)
318 RefPtrWillBeRawPtr<AnimatableValue> before = CSSAnimatableValueFactory:: create(property, *state.style()); 318 RefPtr<AnimatableValue> before = CSSAnimatableValueFactory::create(prope rty, *state.style());
319 StyleBuilder::applyProperty(property, state, fromInterpolableValue(value , range).get()); 319 StyleBuilder::applyProperty(property, state, fromInterpolableValue(value , range).get());
320 RefPtrWillBeRawPtr<AnimatableValue> after = CSSAnimatableValueFactory::c reate(property, *state.style()); 320 RefPtr<AnimatableValue> after = CSSAnimatableValueFactory::create(proper ty, *state.style());
321 ASSERT(before->equals(*after)); 321 ASSERT(before->equals(*after));
322 #endif 322 #endif
323 } else { 323 } else {
324 StyleBuilder::applyProperty(property, state, fromInterpolableValue(value , range).get()); 324 StyleBuilder::applyProperty(property, state, fromInterpolableValue(value , range).get());
325 } 325 }
326 } 326 }
327 327
328 void LengthStyleInterpolation::apply(StyleResolverState& state) const 328 void LengthStyleInterpolation::apply(StyleResolverState& state) const
329 { 329 {
330 applyInterpolableValue(m_id, *m_cachedValue, m_range, state, m_lengthSetter) ; 330 applyInterpolableValue(m_id, *m_cachedValue, m_range, state, m_lengthSetter) ;
331 } 331 }
332 332
333 DEFINE_TRACE(LengthStyleInterpolation) 333 DEFINE_TRACE(LengthStyleInterpolation)
334 { 334 {
335 StyleInterpolation::trace(visitor); 335 StyleInterpolation::trace(visitor);
336 } 336 }
337 337
338 } 338 }
OLDNEW
« no previous file with comments | « Source/core/animation/LengthStyleInterpolation.h ('k') | Source/core/animation/LengthStyleInterpolationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698