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

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

Issue 273903002: Web Animations API: Length properties responsive to style changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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/Interpolation.cpp
diff --git a/Source/core/animation/Interpolation.cpp b/Source/core/animation/Interpolation.cpp
index 1738b817f533f9a98d670160a2a91f1ae70aaa9c..53fa9888b7d2177cdc99f55527bba43173ddc7d2 100644
--- a/Source/core/animation/Interpolation.cpp
+++ b/Source/core/animation/Interpolation.cpp
@@ -136,7 +136,7 @@ static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> constructCalcExpression(Pas
}
-PassRefPtrWillBeRawPtr<CSSValue> LengthStyleInterpolation::interpolableValueToLength(InterpolableValue* value)
+PassRefPtrWillBeRawPtr<CSSValue> LengthStyleInterpolation::interpolableValueToLength(InterpolableValue* value, ValueRange range)
{
InterpolableList* listValue = toInterpolableList(value);
unsigned unitCount = 0;
@@ -153,18 +153,21 @@ PassRefPtrWillBeRawPtr<CSSValue> LengthStyleInterpolation::interpolableValueToLe
case 1:
for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
const InterpolableNumber* subValue = toInterpolableNumber(listValue->get(i));
- if (subValue->value()) {
- return CSSPrimitiveValue::create(subValue->value(), toUnitType(i));
+ double value = subValue->value();
+ if (value) {
+ if (range == ValueRangeNonNegative && value < 0)
+ return CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX);
+ return CSSPrimitiveValue::create(value, toUnitType(i));
alancutter (OOO until 2018) 2014/05/12 09:17:36 As discussed we should retain the unit here even i
Eric Willigers 2014/05/12 09:42:37 Done.
}
}
alancutter (OOO until 2018) 2014/05/12 09:17:36 This is unrelated to your change but can we add an
Eric Willigers 2014/05/12 09:42:37 Done.
default:
- return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpression(nullptr, listValue, 0)));
+ return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpression(nullptr, listValue, 0), range));
}
}
void LengthStyleInterpolation::apply(StyleResolverState& state) const
{
- StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedValue.get()).get());
+ StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedValue.get(), m_range).get());
}
void LengthStyleInterpolation::trace(Visitor* visitor)

Powered by Google App Engine
This is Rietveld 408576698