Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Unified Diff: Source/core/animation/ShadowStyleInterpolation.cpp

Issue 851633002: Animation: Add template for ListStyleInterpolation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add else to shadowToInterpolableValue Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/animation/ShadowStyleInterpolation.cpp
diff --git a/Source/core/animation/ShadowStyleInterpolation.cpp b/Source/core/animation/ShadowStyleInterpolation.cpp
index 1b7ab6fb7fb34085e34c0f2090f2f812e4e677c4..4da6d98d95139cdb0fdcf154f49a86cebcb75769 100644
--- a/Source/core/animation/ShadowStyleInterpolation.cpp
+++ b/Source/core/animation/ShadowStyleInterpolation.cpp
@@ -13,60 +13,66 @@
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
+ && toCSSShadowValue(start).color && toCSSShadowValue(start).color;
}
-PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::shadowToInterpolableValue(const CSSValue& value)
+
+PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::lengthToInterpolableValue(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> value)
+{
+ if (value)
+ return LengthStyleInterpolation::toInterpolableValue(*value);
+ return LengthStyleInterpolation::toInterpolableValue(*CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX));
+}
+
+PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::toInterpolableValue(const CSSValue& value, NonInterpolableType& nonInterpolableData)
{
- OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(6);
+ 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));
+
+ if (shadowValue->color && ColorStyleInterpolation::canCreateFrom(*shadowValue->color))
+ result->set(4, ColorStyleInterpolation::colorToInterpolableValue(*shadowValue->color));
+
+ if (shadowValue->style)
+ nonInterpolableData = (shadowValue->style->getValueID() == CSSValueInset);
+ else
+ nonInterpolableData = false;
return result.release();
}
-PassRefPtrWillBeRawPtr<CSSValue> ShadowStyleInterpolation::interpolableValueToShadow(InterpolableValue* value, bool styleFlag)
+PassRefPtrWillBeRawPtr<CSSValue> ShadowStyleInterpolation::fromInterpolableValue(const InterpolableValue& value, NonInterpolableType nonInterpolableData, InterpolationRange range)
{
- 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)));
+ const InterpolableList* shadow = toInterpolableList(&value);
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> x = LengthStyleInterpolation::fromInterpolableValue(*shadow->get(0), RangeAll);
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> y = LengthStyleInterpolation::fromInterpolableValue(*shadow->get(1), RangeAll);
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = LengthStyleInterpolation::fromInterpolableValue(*shadow->get(2), RangeNonNegative);
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = LengthStyleInterpolation::fromInterpolableValue(*shadow->get(3), RangeAll);
- RefPtrWillBeRawPtr<CSSPrimitiveValue> style = styleFlag ? CSSPrimitiveValue::createIdentifier(CSSValueInset) : CSSPrimitiveValue::createIdentifier(CSSValueNone);
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> color = ColorStyleInterpolation::interpolableValueToColor(*shadow->get(4));
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> style = nonInterpolableData ? CSSPrimitiveValue::createIdentifier(CSSValueInset) : CSSPrimitiveValue::createIdentifier(CSSValueNone);
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)
+bool ShadowStyleInterpolation::usesDefaultStyleInterpolation(const CSSValue& start, const CSSValue& end)
{
- 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 (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 nullptr;
-}
-
-
-void ShadowStyleInterpolation::apply(StyleResolverState& state) const
-{
- StyleBuilder::applyProperty(m_id, state, interpolableValueToShadow(m_cachedValue.get(), m_styleFlag).get());
+ return false;
}
-void ShadowStyleInterpolation::trace(Visitor* visitor)
-{
- StyleInterpolation::trace(visitor);
-}
-
-}
+} // namespace blink
« no previous file with comments | « Source/core/animation/ShadowStyleInterpolation.h ('k') | Source/core/animation/ShadowStyleInterpolationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698