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

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

Issue 851633002: Animation: Add template for ListStyleInterpolation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add else to shadowToInterpolableValue Created 5 years, 10 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/css/CSSCalculationValue.h" 8 #include "core/css/CSSCalculationValue.h"
9 #include "core/css/resolver/StyleBuilder.h" 9 #include "core/css/resolver/StyleBuilder.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value) 13 bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value)
14 { 14 {
15 if (value.isPrimitiveValue()) { 15 if (value.isPrimitiveValue()) {
16 const CSSPrimitiveValue& primitiveValue = blink::toCSSPrimitiveValue(val ue); 16 const CSSPrimitiveValue& primitiveValue = blink::toCSSPrimitiveValue(val ue);
17 if (primitiveValue.cssCalcValue()) 17 if (primitiveValue.cssCalcValue())
18 return true; 18 return true;
19 19
20 CSSPrimitiveValue::LengthUnitType type; 20 CSSPrimitiveValue::LengthUnitType type;
21 // Only returns true if the type is a primitive length unit. 21 // Only returns true if the type is a primitive length unit.
22 return CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.primit iveType(), type); 22 return CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.primit iveType(), type);
23 } 23 }
24 return value.isCalcValue(); 24 return value.isCalcValue();
25 } 25 }
26 26
27 PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::lengthToInte rpolableValue(const CSSValue& value) 27 PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolab leValue(const CSSValue& value)
28 { 28 {
29 ASSERT(canCreateFrom(value)); 29 ASSERT(canCreateFrom(value));
30 OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList ::create(2); 30 OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList ::create(2);
31 OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create (CSSPrimitiveValue::LengthUnitTypeCount); 31 OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create (CSSPrimitiveValue::LengthUnitTypeCount);
32 OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create( CSSPrimitiveValue::LengthUnitTypeCount); 32 OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create( CSSPrimitiveValue::LengthUnitTypeCount);
33 33
34 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); 34 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value);
35 35
36 CSSLengthArray arrayOfValues; 36 CSSLengthArray arrayOfValues;
37 CSSPrimitiveValue::CSSLengthTypeArray arrayOfTypes; 37 CSSPrimitiveValue::CSSLengthTypeArray arrayOfTypes;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 next = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::cre ate(value, toUnitType(position))); 74 next = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::cre ate(value, toUnitType(position)));
75 return constructCalcExpression(next, list, position + 1); 75 return constructCalcExpression(next, list, position + 1);
76 } 76 }
77 position++; 77 position++;
78 } 78 }
79 return previous; 79 return previous;
80 } 80 }
81 81
82 } 82 }
83 83
84 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> LengthStyleInterpolation::interpolable ValueToLength(const InterpolableValue* value, InterpolationRange range) 84 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> LengthStyleInterpolation::fromInterpol ableValue(const InterpolableValue& value, InterpolationRange range)
85 { 85 {
86 const InterpolableList* listOfValuesAndTypes = toInterpolableList(value); 86 const InterpolableList* listOfValuesAndTypes = toInterpolableList(&value);
87 const InterpolableList* listOfValues = toInterpolableList(listOfValuesAndTyp es->get(0)); 87 const InterpolableList* listOfValues = toInterpolableList(listOfValuesAndTyp es->get(0));
88 const InterpolableList* listOfTypes = toInterpolableList(listOfValuesAndType s->get(1)); 88 const InterpolableList* listOfTypes = toInterpolableList(listOfValuesAndType s->get(1));
89 unsigned unitTypeCount = 0; 89 unsigned unitTypeCount = 0;
90 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { 90 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
91 const InterpolableNumber* subType = toInterpolableNumber(listOfTypes->ge t(i)); 91 const InterpolableNumber* subType = toInterpolableNumber(listOfTypes->ge t(i));
92 if (subType->value()) { 92 if (subType->value()) {
93 unitTypeCount++; 93 unitTypeCount++;
94 } 94 }
95 } 95 }
96 96
(...skipping 13 matching lines...) Expand all
110 } 110 }
111 ASSERT_NOT_REACHED(); 111 ASSERT_NOT_REACHED();
112 default: 112 default:
113 ValueRange valueRange = (range == RangeNonNegative) ? ValueRangeNonNegat ive : ValueRangeAll; 113 ValueRange valueRange = (range == RangeNonNegative) ? ValueRangeNonNegat ive : ValueRangeAll;
114 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre ssion(nullptr, listOfValuesAndTypes, 0), valueRange)); 114 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre ssion(nullptr, listOfValuesAndTypes, 0), valueRange));
115 } 115 }
116 } 116 }
117 117
118 void LengthStyleInterpolation::apply(StyleResolverState& state) const 118 void LengthStyleInterpolation::apply(StyleResolverState& state) const
119 { 119 {
120 StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedV alue.get(), m_range).get()); 120 StyleBuilder::applyProperty(m_id, state, fromInterpolableValue(*m_cachedValu e.get(), m_range).get());
121 } 121 }
122 122
123 void LengthStyleInterpolation::trace(Visitor* visitor) 123 void LengthStyleInterpolation::trace(Visitor* visitor)
124 { 124 {
125 StyleInterpolation::trace(visitor); 125 StyleInterpolation::trace(visitor);
126 } 126 }
127 127
128 } 128 }
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