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

Unified Diff: third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp

Issue 1535523002: Web Animations: Add SVGLengthListInterpolationType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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: third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp
diff --git a/third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp
index 98da652e884906c89192cc9dd7512703b5131882..bc46f1c38fcf1ee8cb902e2a29a1f8a01d1c8763 100644
--- a/third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp
+++ b/third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp
@@ -76,21 +76,17 @@ LengthInterpolatedUnit convertToInterpolatedUnit(CSSPrimitiveValue::UnitType uni
} // namespace
-PassOwnPtr<InterpolationValue> SVGLengthInterpolationType::maybeConvertNeutral(const UnderlyingValue&, ConversionCheckers&) const
+InterpolationComponent neutralInterpolableSVGLength()
{
OwnPtr<InterpolableList> listOfValues = InterpolableList::create(numLengthInterpolatedUnits);
for (size_t i = 0; i < numLengthInterpolatedUnits; ++i)
listOfValues->set(i, InterpolableNumber::create(0));
- return InterpolationValue::create(*this, listOfValues.release());
+ return InterpolationComponent(listOfValues.release());
}
-PassOwnPtr<InterpolationValue> SVGLengthInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const
+InterpolationComponent interpolableSVGLength(const SVGLength& length)
{
- if (svgValue.type() != AnimatedLength)
- return nullptr;
-
- const SVGLength& length = toSVGLength(svgValue);
double value = length.valueInSpecifiedUnits();
LengthInterpolatedUnit unitType = convertToInterpolatedUnit(length.typeWithCalcResolved(), value);
@@ -101,17 +97,10 @@ PassOwnPtr<InterpolationValue> SVGLengthInterpolationType::maybeConvertSVGValue(
for (size_t i = 0; i < numLengthInterpolatedUnits; ++i)
listOfValues->set(i, InterpolableNumber::create(values[i]));
- return InterpolationValue::create(*this, listOfValues.release());
-}
-
-PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGLengthInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue*) const
-{
- ASSERT_NOT_REACHED();
- // This function is no longer called, because apply has been overridden.
- return nullptr;
+ return InterpolationComponent(listOfValues.release());
}
-PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGLengthInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue*, const SVGLengthContext& lengthContext) const
+PassRefPtrWillBeRawPtr<SVGLength> applyInterpolableSVGLength(const InterpolableValue& interpolableValue, const SVGLengthContext& lengthContext, const SVGLengthMode& unitMode, bool negativeValuesForbidden)
{
const InterpolableList& listOfValues = toInterpolableList(interpolableValue);
@@ -139,23 +128,46 @@ PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGLengthInterpolationType::appliedSVGVa
for (size_t i = 0; i < numLengthInterpolatedUnits; i++) {
double entry = toInterpolableNumber(listOfValues.get(i))->value();
if (entry)
- value += lengthContext.convertValueToUserUnits(entry, m_unitMode, unitTypes[i]);
+ value += lengthContext.convertValueToUserUnits(entry, unitMode, unitTypes[i]);
}
}
- if (m_negativeValuesForbidden && value < 0)
+ if (negativeValuesForbidden && value < 0)
value = 0;
- RefPtrWillBeRawPtr<SVGLength> result = SVGLength::create(m_unitMode); // defaults to the length 0
+ RefPtrWillBeRawPtr<SVGLength> result = SVGLength::create(unitMode); // defaults to the length 0
result->newValueSpecifiedUnits(unitType, value);
return result.release();
}
+PassOwnPtr<InterpolationValue> SVGLengthInterpolationType::maybeConvertNeutral(const UnderlyingValue&, ConversionCheckers&) const
+{
+ InterpolationComponent component = neutralInterpolableSVGLength();
+ return InterpolationValue::create(*this, component);
+}
+
+PassOwnPtr<InterpolationValue> SVGLengthInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const
+{
+ if (svgValue.type() != AnimatedLength)
+ return nullptr;
+
+ const SVGLength& length = toSVGLength(svgValue);
+ InterpolationComponent component = interpolableSVGLength(length);
+ return InterpolationValue::create(*this, component);
+}
+
+PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGLengthInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue*) const
+{
+ ASSERT_NOT_REACHED();
+ // This function is no longer called, because apply has been overridden.
+ return nullptr;
+}
+
void SVGLengthInterpolationType::apply(const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& environment) const
{
SVGElement& element = environment.svgElement();
SVGLengthContext lengthContext(&element);
- element.setWebAnimatedAttribute(attribute(), appliedSVGValue(interpolableValue, nonInterpolableValue, lengthContext));
+ element.setWebAnimatedAttribute(attribute(), applyInterpolableSVGLength(interpolableValue, lengthContext, m_unitMode, m_negativeValuesForbidden));
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698