Chromium Code Reviews| Index: Source/core/animation/LengthStyleInterpolation.cpp |
| diff --git a/Source/core/animation/LengthStyleInterpolation.cpp b/Source/core/animation/LengthStyleInterpolation.cpp |
| index effaf43168f31f34598aba819483a4db8969647f..7379c1f049dc84a1dd6d77c195ffa276c3c5d245 100644 |
| --- a/Source/core/animation/LengthStyleInterpolation.cpp |
| +++ b/Source/core/animation/LengthStyleInterpolation.cpp |
| @@ -10,13 +10,24 @@ |
| namespace blink { |
| -bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value) |
| +bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value, CSSPropertyID id) |
|
alancutter (OOO until 2018)
2015/03/05 23:38:49
Nit: I think we should name our CSSPropertyID vari
Eric Willigers
2015/03/07 23:58:21
Done.
|
| { |
| if (value.isPrimitiveValue()) { |
| const CSSPrimitiveValue& primitiveValue = blink::toCSSPrimitiveValue(value); |
| if (primitiveValue.cssCalcValue()) |
| return true; |
| + if (primitiveValue.isValueID()) { |
|
alancutter (OOO until 2018)
2015/03/05 23:38:49
You should only enter this branch if the property
Eric Willigers
2015/03/07 23:58:21
Acknowledged.
|
| + CSSValueID valueID = primitiveValue.getValueID(); |
| + |
| + // border-*-width column-rule-width, outline-width support thin, medium, thick. |
| + return valueID == CSSValueThin |
| + || valueID == CSSValueMedium |
| + || valueID == CSSValueThick |
| + || (id == CSSPropertyLetterSpacing && valueID == CSSValueNormal) |
| + || (id == CSSPropertyPerspective && valueID == CSSValueNone); |
|
alancutter (OOO until 2018)
2015/03/05 23:38:50
The properties should be called out in code, a com
Eric Willigers
2015/03/07 23:58:22
Done.
|
| + } |
| + |
| CSSPrimitiveValue::LengthUnitType type; |
| // Only returns true if the type is a primitive length unit. |
| return CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.primitiveType(), type); |
| @@ -24,12 +35,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)); |
| - OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList::create(2); |
| - OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount); |
| - OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount); |
|
alancutter (OOO until 2018)
2015/03/05 23:38:50
Do these need to move? I think the original placem
Eric Willigers
2015/03/07 23:58:22
Acknowledged.
|
| + ASSERT(canCreateFrom(value, id)); |
| const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); |
| @@ -39,13 +47,31 @@ PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolab |
| arrayOfValues.append(0); |
| arrayOfTypes.ensureSize(CSSPrimitiveValue::LengthUnitTypeCount); |
| - primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes); |
| + if (primitive.isValueID()) { |
| + CSSValueID valueID = primitive.getValueID(); |
| + |
| + arrayOfTypes.set(0); |
| + if (valueID == CSSValueThin) |
| + arrayOfValues[0] = 1; |
|
alancutter (OOO until 2018)
2015/03/05 23:38:50
Don't index by 0, use CSSPrimitiveValue::UnitTypeP
Eric Willigers
2015/03/07 23:58:21
Done.
|
| + if (valueID == CSSValueMedium) |
| + arrayOfValues[0] = 3; |
| + if (valueID == CSSValueThick) |
| + arrayOfValues[0] = 5; |
| + |
| + // letter-spacing 'normal' corresponds to 0 |
| + // perspective 'none' corresponds to 0 |
| + } else { |
| + primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes); |
| + } |
| + OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount); |
| + OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount); |
| for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { |
| listOfValues->set(i, InterpolableNumber::create(arrayOfValues.at(i))); |
| listOfTypes->set(i, InterpolableNumber::create(arrayOfTypes.get(i))); |
| } |
| + OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList::create(2); |
| listOfValuesAndTypes->set(0, listOfValues.release()); |
| listOfValuesAndTypes->set(1, listOfTypes.release()); |