| 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/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::lengthToInte
rpolableValue(const CSSValue& value) |
| 28 { | 28 { |
| 29 ASSERT(canCreateFrom(value)); |
| 29 OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList
::create(2); | 30 OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList
::create(2); |
| 30 OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create
(CSSPrimitiveValue::LengthUnitTypeCount); | 31 OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create
(CSSPrimitiveValue::LengthUnitTypeCount); |
| 31 OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create(
CSSPrimitiveValue::LengthUnitTypeCount); | 32 OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create(
CSSPrimitiveValue::LengthUnitTypeCount); |
| 32 | 33 |
| 33 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); | 34 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); |
| 34 | 35 |
| 35 CSSLengthArray arrayOfValues; | 36 CSSLengthArray arrayOfValues; |
| 36 CSSPrimitiveValue::CSSLengthTypeArray arrayOfTypes; | 37 CSSPrimitiveValue::CSSLengthTypeArray arrayOfTypes; |
| 37 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) | 38 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) |
| 38 arrayOfValues.append(0); | 39 arrayOfValues.append(0); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 { | 117 { |
| 117 StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedV
alue.get(), m_range).get()); | 118 StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedV
alue.get(), m_range).get()); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void LengthStyleInterpolation::trace(Visitor* visitor) | 121 void LengthStyleInterpolation::trace(Visitor* visitor) |
| 121 { | 122 { |
| 122 StyleInterpolation::trace(visitor); | 123 StyleInterpolation::trace(visitor); |
| 123 } | 124 } |
| 124 | 125 |
| 125 } | 126 } |
| OLD | NEW |