Index: Source/core/animation/LengthStyleInterpolation.cpp |
diff --git a/Source/core/animation/LengthStyleInterpolation.cpp b/Source/core/animation/LengthStyleInterpolation.cpp |
index 0626c2b0e9adaf0f3de707e8960c297b7cd1a0f0..d904b783620c1d6832d88ef920ab95e35d0cdfe9 100644 |
--- a/Source/core/animation/LengthStyleInterpolation.cpp |
+++ b/Source/core/animation/LengthStyleInterpolation.cpp |
@@ -10,13 +10,56 @@ |
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; |
+ 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 +67,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 +82,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))); |