Chromium Code Reviews| Index: Source/core/animation/ShadowStyleInterpolation.cpp |
| diff --git a/Source/core/animation/ShadowStyleInterpolation.cpp b/Source/core/animation/ShadowStyleInterpolation.cpp |
| index 1b7ab6fb7fb34085e34c0f2090f2f812e4e677c4..8b6e50e06663c181ffa7d8102c90593e208fc865 100644 |
| --- a/Source/core/animation/ShadowStyleInterpolation.cpp |
| +++ b/Source/core/animation/ShadowStyleInterpolation.cpp |
| @@ -13,60 +13,72 @@ |
| 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)) |
|
dstockwell
2015/02/02 06:10:11
When can LengthStyleInterpolation::canCreateFrom r
evemj (not active)
2015/02/03 00:25:55
Done.
(Never oops)
|
| + return LengthStyleInterpolation::toInterpolableValue(*value); |
| + return InterpolableBool::create(false); |
|
dstockwell
2015/02/02 06:10:12
Using an InterpolableBool seems a bit of a hack. M
shans
2015/02/02 23:49:11
We should use an InterpolableValue that represents
evemj (not active)
2015/02/03 00:25:55
Done.
Additionally we are now not handling the ca
|
| +} |
| + |
| +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)); |
|
dstockwell
2015/02/02 06:10:11
Is there any reason to set this to a bool over swi
|
| - RefPtrWillBeRawPtr<CSSPrimitiveValue> style = styleFlag ? CSSPrimitiveValue::createIdentifier(CSSValueInset) : CSSPrimitiveValue::createIdentifier(CSSValueNone); |
| + if (shadowValue->style) |
| + nonInterpolableData = (shadowValue->style->getValueID() == CSSValueInset); |
| - 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; |
|
dstockwell
2015/02/02 06:10:12
outer parens not needed
evemj (not active)
2015/02/03 00:25:56
Done.
|
| + 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; |
| + } |
| + } |
|
dstockwell
2015/02/02 06:10:11
these braces aren't indented correctly
evemj (not active)
2015/02/03 00:25:55
Done.
|
| + return false; |
| } |
| -} |
| +} // namespace blink |