Chromium Code Reviews| 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 e5ccf7ebedecf0ae10df216c18cb028f8f664b94..773d3af093b7804c70cf89ff87ed29d19e10efab 100644 |
| --- a/third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp |
| +++ b/third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp |
| @@ -75,21 +75,17 @@ LengthInterpolatedUnit convertToInterpolatedUnit(CSSPrimitiveValue::UnitType uni |
| } // namespace |
| -PassOwnPtr<InterpolationValue> SVGLengthInterpolationType::maybeConvertNeutral(const UnderlyingValue&, ConversionCheckers&) const |
| +PassOwnPtr<InterpolableValue> SVGLengthInterpolationType::neutralInterpolableValue() |
| { |
| 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 listOfValues.release(); |
| } |
| -PassOwnPtr<InterpolationValue> SVGLengthInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const |
| +InterpolationComponent SVGLengthInterpolationType::convertSVGLength(const SVGLength& length) |
| { |
| - if (svgValue.type() != AnimatedLength) |
| - return nullptr; |
| - |
| - const SVGLength& length = toSVGLength(svgValue); |
| double value = length.valueInSpecifiedUnits(); |
| LengthInterpolatedUnit unitType = convertToInterpolatedUnit(length.typeWithCalcResolved(), value); |
| @@ -100,17 +96,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> SVGLengthInterpolationType::resolveInterpolableSVGLength(const InterpolableValue& interpolableValue, const SVGLengthContext& lengthContext, const SVGLengthMode& unitMode, bool negativeValuesForbidden) |
|
fs
2016/01/13 12:20:24
uNit: SVGLengthMode is an enum, so passing as a re
alancutter (OOO until 2018)
2016/01/14 00:44:01
Done.
|
| { |
| const InterpolableList& listOfValues = toInterpolableList(interpolableValue); |
| @@ -138,23 +127,45 @@ 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 |
| +{ |
| + return InterpolationValue::create(*this, neutralInterpolableValue()); |
| +} |
| + |
| +PassOwnPtr<InterpolationValue> SVGLengthInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const |
| +{ |
| + if (svgValue.type() != AnimatedLength) |
| + return nullptr; |
| + |
| + const SVGLength& length = toSVGLength(svgValue); |
| + InterpolationComponent component = convertSVGLength(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(), resolveInterpolableSVGLength(interpolableValue, lengthContext, m_unitMode, m_negativeValuesForbidden)); |
| } |
| } // namespace blink |