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

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

Issue 1587533002: Add composition support for SVG Web Animation of x, y, dx, dy attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review changes Created 4 years, 11 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: 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..b99b93178bcaa0e0f60ef75eb8eab2c4f441ee6d
--- /dev/null
+++ b/third_party/WebKit/Source/core/animation/SVGLengthListInterpolationType.cpp
@@ -0,0 +1,83 @@
+// Copyright 2016 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 "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));
+
+ if (underlyingLength == 0)
+ return nullptr;
+
+ OwnPtr<InterpolableList> result = InterpolableList::create(underlyingLength);
+ for (size_t i = 0; i < underlyingLength; i++)
+ result->set(i, SVGLengthInterpolationType::neutralInterpolableValue());
+ 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 = SVGLengthInterpolationType::convertSVGLength(*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)
+ InterpolationType::composite(underlyingValue, underlyingFraction, value);
+ else
+ underlyingValue.set(&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(SVGLengthInterpolationType::resolveInterpolableSVGLength(*list.get(i), lengthContext, m_unitMode, m_negativeValuesForbidden));
+ }
+
+ element.setWebAnimatedAttribute(attribute(), result.release());
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698