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

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

Issue 273903002: Web Animations API: Length properties responsive to style changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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/Interpolation.h" 6 #include "core/animation/Interpolation.h"
7 7
8 #include "core/css/CSSCalculationValue.h" 8 #include "core/css/CSSCalculationValue.h"
9 #include "core/css/resolver/AnimatedStyleBuilder.h" 9 #include "core/css/resolver/AnimatedStyleBuilder.h"
10 #include "core/css/resolver/StyleBuilder.h" 10 #include "core/css/resolver/StyleBuilder.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 next = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::cre ate(subValue->value(), toUnitType(position))); 129 next = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::cre ate(subValue->value(), toUnitType(position)));
130 return constructCalcExpression(next, list, position + 1); 130 return constructCalcExpression(next, list, position + 1);
131 } 131 }
132 position++; 132 position++;
133 } 133 }
134 return previous; 134 return previous;
135 } 135 }
136 136
137 } 137 }
138 138
139 PassRefPtrWillBeRawPtr<CSSValue> LengthStyleInterpolation::interpolableValueToLe ngth(InterpolableValue* value) 139 PassRefPtrWillBeRawPtr<CSSValue> LengthStyleInterpolation::interpolableValueToLe ngth(InterpolableValue* value, ValueRange range)
140 { 140 {
141 InterpolableList* listValue = toInterpolableList(value); 141 InterpolableList* listValue = toInterpolableList(value);
142 unsigned unitCount = 0; 142 unsigned unitCount = 0;
143 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { 143 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
144 const InterpolableNumber* subValue = toInterpolableNumber(listValue->get (i)); 144 const InterpolableNumber* subValue = toInterpolableNumber(listValue->get (i));
145 if (subValue->value()) { 145 if (subValue->value()) {
146 unitCount++; 146 unitCount++;
147 } 147 }
148 } 148 }
149 149
150 switch (unitCount) { 150 switch (unitCount) {
151 case 0: 151 case 0:
152 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX); 152 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX);
153 case 1: 153 case 1:
154 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { 154 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
155 const InterpolableNumber* subValue = toInterpolableNumber(listValue- >get(i)); 155 const InterpolableNumber* subValue = toInterpolableNumber(listValue- >get(i));
156 if (subValue->value()) { 156 double value = subValue->value();
157 return CSSPrimitiveValue::create(subValue->value(), toUnitType(i )); 157 if (value) {
158 if (range == ValueRangeNonNegative && value < 0)
159 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_P X);
160 return CSSPrimitiveValue::create(value, toUnitType(i));
alancutter (OOO until 2018) 2014/05/12 09:17:36 As discussed we should retain the unit here even i
Eric Willigers 2014/05/12 09:42:37 Done.
158 } 161 }
159 } 162 }
alancutter (OOO until 2018) 2014/05/12 09:17:36 This is unrelated to your change but can we add an
Eric Willigers 2014/05/12 09:42:37 Done.
160 default: 163 default:
161 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre ssion(nullptr, listValue, 0))); 164 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre ssion(nullptr, listValue, 0), range));
162 } 165 }
163 } 166 }
164 167
165 void LengthStyleInterpolation::apply(StyleResolverState& state) const 168 void LengthStyleInterpolation::apply(StyleResolverState& state) const
166 { 169 {
167 StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedV alue.get()).get()); 170 StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedV alue.get(), m_range).get());
168 } 171 }
169 172
170 void LengthStyleInterpolation::trace(Visitor* visitor) 173 void LengthStyleInterpolation::trace(Visitor* visitor)
171 { 174 {
172 StyleInterpolation::trace(visitor); 175 StyleInterpolation::trace(visitor);
173 } 176 }
174 177
175 void DefaultStyleInterpolation::apply(StyleResolverState& state) const 178 void DefaultStyleInterpolation::apply(StyleResolverState& state) const
176 { 179 {
177 StyleBuilder::applyProperty(m_id, state, toInterpolableBool(m_cachedValue.ge t())->value() ? m_endCSSValue.get() : m_startCSSValue.get()); 180 StyleBuilder::applyProperty(m_id, state, toInterpolableBool(m_cachedValue.ge t())->value() ? m_endCSSValue.get() : m_startCSSValue.get());
178 } 181 }
179 182
180 void DefaultStyleInterpolation::trace(Visitor* visitor) 183 void DefaultStyleInterpolation::trace(Visitor* visitor)
181 { 184 {
182 StyleInterpolation::trace(visitor); 185 StyleInterpolation::trace(visitor);
183 visitor->trace(m_startCSSValue); 186 visitor->trace(m_startCSSValue);
184 visitor->trace(m_endCSSValue); 187 visitor->trace(m_endCSSValue);
185 } 188 }
186 189
187 } 190 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698