Chromium Code Reviews| Index: Source/core/animation/LengthStyleInterpolation.cpp |
| diff --git a/Source/core/animation/LengthStyleInterpolation.cpp b/Source/core/animation/LengthStyleInterpolation.cpp |
| index 0626c2b0e9adaf0f3de707e8960c297b7cd1a0f0..a8398d316bbbb8c1ffdcd42b9f5172a19a07bd8a 100644 |
| --- a/Source/core/animation/LengthStyleInterpolation.cpp |
| +++ b/Source/core/animation/LengthStyleInterpolation.cpp |
| @@ -10,13 +10,62 @@ |
| namespace blink { |
| -bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value) |
| +namespace { |
| + |
| +bool pixelsForKeyword(CSSPropertyID property, CSSValueID valueID, double& result) |
| +{ |
| + switch (property) { |
| + case CSSPropertyBorderBottomWidth: |
| + case CSSPropertyBorderLeftWidth: |
| + case CSSPropertyBorderRightWidth: |
| + case CSSPropertyBorderTopWidth: |
| + case CSSPropertyWebkitColumnRuleWidth: |
| + case CSSPropertyOutlineWidth: |
| + if (valueID == CSSValueThin) { |
| + result = 1; |
| + return true; |
| + } |
| + if (valueID == CSSValueMedium) { |
| + result = 3; |
| + return true; |
| + } |
| + if (valueID == CSSValueThick) { |
| + result = 5; |
| + return true; |
| + } |
| + return false; |
| + case CSSPropertyLetterSpacing: |
| + if (valueID == CSSValueNormal) { |
| + result = 0; |
| + return true; |
| + } |
| + return false; |
| + case CSSPropertyPerspective: |
| + if (valueID == CSSValueNone) { |
| + result = 0; |
|
alancutter (OOO until 2018)
2015/03/09 00:34:15
Actually we shouldn't be animating perspective: no
Eric Willigers
2015/03/09 02:04:55
Done.
|
| + return true; |
| + } |
| + return false; |
| + default: |
| + return false; |
| + } |
| +} |
| + |
| +} // namespace |
| + |
| +bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value, CSSPropertyID property) |
| { |
| if (value.isPrimitiveValue()) { |
| const CSSPrimitiveValue& primitiveValue = blink::toCSSPrimitiveValue(value); |
| if (primitiveValue.cssCalcValue()) |
| return true; |
| + if (primitiveValue.isValueID()) { |
| + CSSValueID valueID = primitiveValue.getValueID(); |
| + double pixels; |
| + return pixelsForKeyword(property, valueID, pixels); |
| + } |
| + |
| CSSPrimitiveValue::LengthUnitType type; |
| // Only returns true if the type is a primitive length unit. |
| return CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.primitiveType(), type); |
| @@ -24,9 +73,9 @@ bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value) |
| return value.isCalcValue(); |
| } |
| -PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolableValue(const CSSValue& value) |
| +PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolableValue(const CSSValue& value, CSSPropertyID id) |
| { |
| - ASSERT(canCreateFrom(value)); |
| + ASSERT(canCreateFrom(value, id)); |
| OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList::create(2); |
| OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount); |
| OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount); |
| @@ -39,7 +88,15 @@ PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolab |
| arrayOfValues.append(0); |
| arrayOfTypes.ensureSize(CSSPrimitiveValue::LengthUnitTypeCount); |
| - primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes); |
| + if (primitive.isValueID()) { |
| + CSSValueID valueID = primitive.getValueID(); |
| + double pixels; |
| + pixelsForKeyword(id, valueID, pixels); |
| + arrayOfTypes.set(CSSPrimitiveValue::UnitTypePixels); |
| + arrayOfValues[CSSPrimitiveValue::UnitTypePixels] = pixels; |
| + } else { |
| + primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes); |
| + } |
| for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { |
| listOfValues->set(i, InterpolableNumber::create(arrayOfValues.at(i))); |