Index: third_party/WebKit/Source/core/animation/SVGLengthListInterpolationType.cpp |
diff --git a/third_party/WebKit/Source/core/animation/SVGLengthListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGLengthListInterpolationType.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7b3e2d8a0a2f881cc655f12e533bf0121c29c6d2 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/animation/SVGLengthListInterpolationType.cpp |
@@ -0,0 +1,85 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/animation/SVGLengthListInterpolationType.h" |
+ |
+#include "core/animation/InterpolationEnvironment.h" |
+#include "core/animation/SVGLengthInterpolationType.h" |
+#include "core/animation/UnderlyingLengthChecker.h" |
+#include "core/svg/SVGLengthList.h" |
+ |
+namespace blink { |
+ |
+PassOwnPtr<InterpolationValue> SVGLengthListInterpolationType::maybeConvertNeutral(const UnderlyingValue& underlyingValue, ConversionCheckers& conversionCheckers) const |
+{ |
+ size_t underlyingLength = UnderlyingLengthChecker::getUnderlyingLength(underlyingValue); |
+ conversionCheckers.append(UnderlyingLengthChecker::create(*this, underlyingLength)); |
alancutter (OOO until 2018)
2015/12/18 00:35:50
We should have a neutral keyframe responsiveness t
|
+ |
+ if (underlyingLength == 0) |
+ return nullptr; |
+ |
+ OwnPtr<InterpolableList> result = InterpolableList::create(underlyingLength); |
+ for (size_t i = 0; i < underlyingLength; i++) { |
+ InterpolationComponent component = neutralInterpolableSVGLength(); |
+ result->set(i, component.interpolableValue.release()); |
+ } |
+ return InterpolationValue::create(*this, result.release()); |
+} |
+ |
+PassOwnPtr<InterpolationValue> SVGLengthListInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const |
+{ |
+ if (svgValue.type() != AnimatedLengthList) |
+ return nullptr; |
+ |
+ const SVGLengthList& lengthList = toSVGLengthList(svgValue); |
+ OwnPtr<InterpolableList> result = InterpolableList::create(lengthList.length()); |
+ for (size_t i = 0; i < lengthList.length(); i++) { |
+ InterpolationComponent component = interpolableSVGLength(*lengthList.at(i)); |
+ result->set(i, component.interpolableValue.release()); |
+ } |
+ return InterpolationValue::create(*this, result.release()); |
+} |
+ |
+PassOwnPtr<PairwisePrimitiveInterpolation> SVGLengthListInterpolationType::mergeSingleConversions(InterpolationValue& startValue, InterpolationValue& endValue) const |
+{ |
+ size_t startLength = toInterpolableList(startValue.interpolableValue()).length(); |
+ size_t endLength = toInterpolableList(endValue.interpolableValue()).length(); |
+ if (startLength != endLength) |
+ return nullptr; |
+ return InterpolationType::mergeSingleConversions(startValue, endValue); |
+} |
+ |
+void SVGLengthListInterpolationType::composite(UnderlyingValue& underlyingValue, double underlyingFraction, const InterpolationValue& value) const |
+{ |
+ size_t startLength = toInterpolableList(underlyingValue->interpolableValue()).length(); |
+ size_t endLength = toInterpolableList(value.interpolableValue()).length(); |
+ if (startLength != endLength) |
+ underlyingValue.set(&value); |
alancutter (OOO until 2018)
2015/12/18 00:35:50
Does SMIL simply replace like this?
We need tests
|
+ |
+ InterpolationType::composite(underlyingValue, underlyingFraction, value); |
+} |
+ |
+PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGLengthListInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue*) const |
+{ |
+ ASSERT_NOT_REACHED(); |
+ // This function is no longer called, because apply has been overridden. |
+ return nullptr; |
+} |
+ |
+void SVGLengthListInterpolationType::apply(const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& environment) const |
+{ |
+ SVGElement& element = environment.svgElement(); |
+ SVGLengthContext lengthContext(&element); |
+ |
+ RefPtrWillBeRawPtr<SVGLengthList> result = SVGLengthList::create(m_unitMode); |
+ const InterpolableList& list = toInterpolableList(interpolableValue); |
+ for (size_t i = 0; i < list.length(); i++) { |
+ result->append(applyInterpolableSVGLength(*list.get(i), lengthContext, m_unitMode, m_negativeValuesForbidden)); |
+ } |
+ |
+ element.setWebAnimatedAttribute(attribute(), result.release()); |
+} |
+ |
+} // namespace blink |