InterpolationComponent CSSLengthInterpolationType::maybeConvertCSSValue(const CSSValue& value) { if (!value.isPrimitiveValue()) return nullptr; const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); CSSLengthArray valueArray; for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) valueArray.append(0); bool hasPercentage = false; if (!primitiveValue.isLength() && !primitiveValue.isPercentage() && !primitiveValue.isCalculatedPercentageWithLength()) return nullptr; CSSLengthTypeArray hasType; hasType.ensureSize(CSSPrimitiveValue::LengthUnitTypeCount); primitiveValue.accumulateLengthArray(valueArray, hasType); hasPercentage = hasType.get(CSSPrimitiveValue::UnitTypePercentage); OwnPtr<InterpolableList> values = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount); for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) values->set(i, InterpolableNumber::create(valueArray.at(i))); return InterpolationComponent(values.release(), CSSLengthNonInterpolableValue::create(hasPercentage)); }
PassOwnPtr<InterpolableValue> LengthStyleInterpolation::lengthToInterpolableValue(CSSValue* value) { OwnPtr<InterpolableList> result = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount); CSSPrimitiveValue* primitive = toCSSPrimitiveValue(value); CSSLengthArray array; for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) array.append(0); primitive->accumulateLengthArray(array); for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) result->set(i, InterpolableNumber::create(array.at(i))); return result.release(); }