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

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

Issue 1120003002: [Oilpan] Migrate most classes under core/animations to Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 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 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 InterpolableValue* LengthStyleInterpolation::toInterpolableValue(const CSSValue& value, CSSPropertyID id)
73 { 73 {
74 ASSERT(canCreateFrom(value, id)); 74 ASSERT(canCreateFrom(value, id));
75 OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList ::create(2); 75 InterpolableList* listOfValuesAndTypes = InterpolableList::create(2);
76 OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create (CSSPrimitiveValue::LengthUnitTypeCount); 76 InterpolableList* listOfValues = InterpolableList::create(CSSPrimitiveValue: :LengthUnitTypeCount);
77 OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create( CSSPrimitiveValue::LengthUnitTypeCount); 77 InterpolableList* listOfTypes = InterpolableList::create(CSSPrimitiveValue:: 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()) {
88 CSSValueID valueID = primitive.getValueID(); 88 CSSValueID valueID = primitive.getValueID();
89 double pixels; 89 double pixels;
90 pixelsForKeyword(id, valueID, pixels); 90 pixelsForKeyword(id, valueID, pixels);
91 arrayOfTypes.set(CSSPrimitiveValue::UnitTypePixels); 91 arrayOfTypes.set(CSSPrimitiveValue::UnitTypePixels);
92 arrayOfValues[CSSPrimitiveValue::UnitTypePixels] = pixels; 92 arrayOfValues[CSSPrimitiveValue::UnitTypePixels] = pixels;
93 } else { 93 } else {
94 primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes); 94 primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes);
95 } 95 }
96 96
97 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { 97 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
98 listOfValues->set(i, InterpolableNumber::create(arrayOfValues.at(i))); 98 listOfValues->set(i, InterpolableNumber::create(arrayOfValues.at(i)));
99 listOfTypes->set(i, InterpolableNumber::create(arrayOfTypes.get(i))); 99 listOfTypes->set(i, InterpolableNumber::create(arrayOfTypes.get(i)));
100 } 100 }
101 101
102 listOfValuesAndTypes->set(0, listOfValues.release()); 102 listOfValuesAndTypes->set(0, listOfValues);
103 listOfValuesAndTypes->set(1, listOfTypes.release()); 103 listOfValuesAndTypes->set(1, listOfTypes);
104 104
105 return listOfValuesAndTypes.release(); 105 return listOfValuesAndTypes;
106 } 106 }
107 107
108 bool LengthStyleInterpolation::isPixelsOrPercentOnly(const InterpolableValue& va lue) 108 bool LengthStyleInterpolation::isPixelsOrPercentOnly(const InterpolableValue& va lue)
109 { 109 {
110 const InterpolableList& types = *toInterpolableList(toInterpolableList(value ).get(1)); 110 const InterpolableList& types = *toInterpolableList(toInterpolableList(value ).get(1));
111 bool result = false; 111 bool result = false;
112 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { 112 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
113 bool typeIsPresent = toInterpolableNumber(types.get(i))->value(); 113 bool typeIsPresent = toInterpolableNumber(types.get(i))->value();
114 if (i == CSSPrimitiveValue::UnitTypePixels) 114 if (i == CSSPrimitiveValue::UnitTypePixels)
115 result |= typeIsPresent; 115 result |= typeIsPresent;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 AnimatableValue* before = CSSAnimatableValueFactory::create(property, *s tate.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 AnimatableValue* after = CSSAnimatableValueFactory::create(property, *st ate.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