| Index: Source/core/animation/ShadowStyleInterpolation.cpp
|
| diff --git a/Source/core/animation/ShadowStyleInterpolation.cpp b/Source/core/animation/ShadowStyleInterpolation.cpp
|
| index 1b7ab6fb7fb34085e34c0f2090f2f812e4e677c4..9217faee79f9bbad511766647a5eabb839420538 100644
|
| --- a/Source/core/animation/ShadowStyleInterpolation.cpp
|
| +++ b/Source/core/animation/ShadowStyleInterpolation.cpp
|
| @@ -13,60 +13,74 @@
|
|
|
| namespace blink {
|
|
|
| -bool ShadowStyleInterpolation::canCreateFrom(const CSSValue& value)
|
| +bool ShadowStyleInterpolation::canCreateFrom(const CSSValue& start, const CSSValue& end)
|
| {
|
| - return value.isShadowValue();
|
| + return start.isShadowValue() && end.isShadowValue()
|
| + && toCSSShadowValue(start).style == toCSSShadowValue(end).style;
|
| }
|
| -PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::shadowToInterpolableValue(const CSSValue& value)
|
| +
|
| +PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::lengthToInterpolableValue(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> value)
|
| {
|
| - OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(6);
|
| + if (value && LengthStyleInterpolation::canCreateFrom(*value))
|
| + return LengthStyleInterpolation::toInterpolableValue(*value);
|
| + return InterpolableBool::create(false);
|
| +}
|
| +
|
| +PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::toInterpolableValue(const CSSValue& value, NonInterpolableType& nonInterpolableData)
|
| +{
|
| + OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(5);
|
| const CSSShadowValue* shadowValue = toCSSShadowValue(&value);
|
| ASSERT(shadowValue);
|
|
|
| - result->set(0, LengthStyleInterpolation::lengthToInterpolableValue(*shadowValue->x));
|
| - result->set(1, LengthStyleInterpolation::lengthToInterpolableValue(*shadowValue->y));
|
| - result->set(2, LengthStyleInterpolation::lengthToInterpolableValue(*shadowValue->blur));
|
| - result->set(3, LengthStyleInterpolation::lengthToInterpolableValue(*shadowValue->spread));
|
| - result->set(4, ColorStyleInterpolation::colorToInterpolableValue(*shadowValue->color));
|
| + result->set(0, lengthToInterpolableValue(shadowValue->x));
|
| + result->set(1, lengthToInterpolableValue(shadowValue->y));
|
| + result->set(2, lengthToInterpolableValue(shadowValue->blur));
|
| + result->set(3, lengthToInterpolableValue(shadowValue->spread));
|
|
|
| - return result.release();
|
| -}
|
| -
|
| -PassRefPtrWillBeRawPtr<CSSValue> ShadowStyleInterpolation::interpolableValueToShadow(InterpolableValue* value, bool styleFlag)
|
| -{
|
| - InterpolableList* shadow = toInterpolableList(value);
|
| - RefPtrWillBeRawPtr<CSSPrimitiveValue> x = LengthStyleInterpolation::interpolableValueToLength(shadow->get(0), RangeNonNegative);
|
| - RefPtrWillBeRawPtr<CSSPrimitiveValue> y = LengthStyleInterpolation::interpolableValueToLength(shadow->get(1), RangeNonNegative);
|
| - RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = LengthStyleInterpolation::interpolableValueToLength(shadow->get(2), RangeNonNegative);
|
| - RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = LengthStyleInterpolation::interpolableValueToLength(shadow->get(3), RangeNonNegative);
|
| - RefPtrWillBeRawPtr<CSSPrimitiveValue> color = ColorStyleInterpolation::interpolableValueToColor(*(shadow->get(4)));
|
| + if (shadowValue->color && ColorStyleInterpolation::canCreateFrom(*shadowValue->color))
|
| + result->set(4, ColorStyleInterpolation::colorToInterpolableValue(*shadowValue->color));
|
| + else
|
| + result->set(4, InterpolableBool::create(false));
|
|
|
| - RefPtrWillBeRawPtr<CSSPrimitiveValue> style = styleFlag ? CSSPrimitiveValue::createIdentifier(CSSValueInset) : CSSPrimitiveValue::createIdentifier(CSSValueNone);
|
| + if (shadowValue->style)
|
| + nonInterpolableData = (shadowValue->style->getValueID() == CSSValueInset);
|
| + else
|
| + nonInterpolableData = false;
|
|
|
| - RefPtrWillBeRawPtr<CSSShadowValue> result = CSSShadowValue::create(x, y, blur, spread, style, color);
|
| return result.release();
|
| }
|
|
|
| -PassRefPtrWillBeRawPtr<ShadowStyleInterpolation> ShadowStyleInterpolation::maybeCreateFromShadow(const CSSValue& start, const CSSValue& end, CSSPropertyID id)
|
| +PassRefPtrWillBeRawPtr<CSSPrimitiveValue> ShadowStyleInterpolation::interpolableValueToLength(const InterpolableValue* value, InterpolationRange range)
|
| {
|
| - if (canCreateFrom(start) && canCreateFrom(end)) {
|
| - if (toCSSShadowValue(start).style == toCSSShadowValue(end).style) {
|
| - bool styleFlag = (toCSSShadowValue(start).style->getValueID() == CSSValueInset) ? true : false;
|
| - return ShadowStyleInterpolation::create(start, end, id, styleFlag);
|
| - }
|
| - }
|
| + if (!value->isBool())
|
| + return LengthStyleInterpolation::fromInterpolableValue(*value, range);
|
| return nullptr;
|
| }
|
|
|
| -
|
| -void ShadowStyleInterpolation::apply(StyleResolverState& state) const
|
| +PassRefPtrWillBeRawPtr<CSSValue> ShadowStyleInterpolation::fromInterpolableValue(const InterpolableValue& value, NonInterpolableType nonInterpolableData, InterpolationRange range)
|
| {
|
| - StyleBuilder::applyProperty(m_id, state, interpolableValueToShadow(m_cachedValue.get(), m_styleFlag).get());
|
| + const InterpolableList* shadow = toInterpolableList(&value);
|
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> x = interpolableValueToLength(shadow->get(0));
|
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> y = interpolableValueToLength(shadow->get(1));
|
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = interpolableValueToLength(shadow->get(2), RangeNonNegative);
|
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = interpolableValueToLength(shadow->get(3));
|
| +
|
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> color = (!shadow->get(4)->isBool()) ? ColorStyleInterpolation::interpolableValueToColor(*shadow->get(4)) : nullptr;
|
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> style = nonInterpolableData ? CSSPrimitiveValue::createIdentifier(CSSValueInset) : CSSPrimitiveValue::createIdentifier(CSSValueNone);
|
| +
|
| + RefPtrWillBeRawPtr<CSSShadowValue> result = CSSShadowValue::create(x, y, blur, spread, style, color);
|
| + return result.release();
|
| }
|
|
|
| -void ShadowStyleInterpolation::trace(Visitor* visitor)
|
| +bool ShadowStyleInterpolation::usesDefaultStyleInterpolation(const CSSValue& start, const CSSValue& end)
|
| {
|
| - StyleInterpolation::trace(visitor);
|
| + if (start.isValueList() && end.isValueList() && toCSSValueList(start).length() == toCSSValueList(end).length()) {
|
| + for (size_t i = 0; i < toCSSValueList(start).length(); i++) {
|
| + if (!canCreateFrom(*toCSSValueList(start).item(i), *toCSSValueList(end).item(i)))
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| }
|
|
|
| -}
|
| +} // namespace blink
|
|
|