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

Unified Diff: Source/core/animation/interpolation/LengthStyleInterpolation.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: Rebase 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/LengthStyleInterpolation.cpp
diff --git a/Source/core/animation/interpolation/LengthStyleInterpolation.cpp b/Source/core/animation/interpolation/LengthStyleInterpolation.cpp
index cf3e129ab1a8a82455bdd5f58c536315b5f88515..63ee264bf7428288fc2ba2e1b5928ceb5bc8b75a 100644
--- a/Source/core/animation/interpolation/LengthStyleInterpolation.cpp
+++ b/Source/core/animation/interpolation/LengthStyleInterpolation.cpp
@@ -66,7 +66,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;
@@ -83,18 +83,22 @@ 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)
+ value = 0;
+ return CSSPrimitiveValue::create(value, toUnitType(i));
}
}
+ ASSERT_NOT_REACHED();
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