OLD | NEW |
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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |