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

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

Issue 1592593002: Web Animations: Animate d presentation attribute using InterpolableValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove assert 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/PathInterpolationFunctions.cpp
diff --git a/third_party/WebKit/Source/core/animation/SVGPathInterpolationType.cpp b/third_party/WebKit/Source/core/animation/PathInterpolationFunctions.cpp
similarity index 80%
copy from third_party/WebKit/Source/core/animation/SVGPathInterpolationType.cpp
copy to third_party/WebKit/Source/core/animation/PathInterpolationFunctions.cpp
index 9525f660429f837bfe92be5c8aadeb67fe08a12f..92a837b9dc5b4ced197f333d5bdeb3f782d65c06 100644
--- a/third_party/WebKit/Source/core/animation/SVGPathInterpolationType.cpp
+++ b/third_party/WebKit/Source/core/animation/PathInterpolationFunctions.cpp
@@ -1,12 +1,13 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
+// 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/SVGPathInterpolationType.h"
+#include "core/animation/PathInterpolationFunctions.h"
#include "core/animation/InterpolatedSVGPathSource.h"
#include "core/animation/InterpolationEnvironment.h"
#include "core/animation/SVGPathSegInterpolationFunctions.h"
+#include "core/css/CSSPathValue.h"
#include "core/svg/SVGPath.h"
#include "core/svg/SVGPathByteStreamBuilder.h"
#include "core/svg/SVGPathByteStreamSource.h"
@@ -45,12 +46,9 @@ enum PathComponentIndex {
PathComponentIndexCount,
};
-PassOwnPtr<InterpolationValue> SVGPathInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const
+PassOwnPtr<InterpolationValue> PathInterpolationFunctions::convertValue(const InterpolationType& type, const SVGPathByteStream& byteStream)
{
- if (svgValue.type() != AnimatedPath)
- return nullptr;
-
- SVGPathByteStreamSource pathSource(toSVGPath(svgValue).byteStream());
+ SVGPathByteStreamSource pathSource(byteStream);
size_t length = 0;
PathCoordinates currentCoordinates;
Vector<OwnPtr<InterpolableValue>> interpolablePathSegs;
@@ -71,7 +69,7 @@ PassOwnPtr<InterpolationValue> SVGPathInterpolationType::maybeConvertSVGValue(co
result->set(PathArgsIndex, pathArgs.release());
result->set(PathNeutralIndex, InterpolableNumber::create(0));
- return InterpolationValue::create(*this, result.release(), SVGPathNonInterpolableValue::create(pathSegTypes));
+ return InterpolationValue::create(type, result.release(), SVGPathNonInterpolableValue::create(pathSegTypes));
}
class UnderlyingPathSegTypesChecker : public InterpolationType::ConversionChecker {
@@ -102,13 +100,13 @@ private:
Vector<SVGPathSegType> m_pathSegTypes;
};
-PassOwnPtr<InterpolationValue> SVGPathInterpolationType::maybeConvertNeutral(const UnderlyingValue& underlyingValue, ConversionCheckers& conversionCheckers) const
+PassOwnPtr<InterpolationValue> PathInterpolationFunctions::maybeConvertNeutral(const InterpolationType& type, const UnderlyingValue& underlyingValue, InterpolationType::ConversionCheckers& conversionCheckers)
{
- conversionCheckers.append(UnderlyingPathSegTypesChecker::create(*this, underlyingValue));
+ conversionCheckers.append(UnderlyingPathSegTypesChecker::create(type, underlyingValue));
OwnPtr<InterpolableList> result = InterpolableList::create(PathComponentIndexCount);
result->set(PathArgsIndex, toInterpolableList(underlyingValue->interpolableValue()).get(PathArgsIndex)->cloneAndZero());
result->set(PathNeutralIndex, InterpolableNumber::create(1));
- return InterpolationValue::create(*this, result.release(),
+ return InterpolationValue::create(type, result.release(),
const_cast<NonInterpolableValue*>(underlyingValue->nonInterpolableValue())); // Take ref.
}
@@ -125,20 +123,20 @@ static bool pathSegTypesMatch(const Vector<SVGPathSegType>& a, const Vector<SVGP
return true;
}
-PassOwnPtr<PairwisePrimitiveInterpolation> SVGPathInterpolationType::mergeSingleConversions(InterpolationValue& startValue, InterpolationValue& endValue) const
+PassOwnPtr<PairwisePrimitiveInterpolation> PathInterpolationFunctions::mergeSingleConversions(const InterpolationType& type, InterpolationValue& startValue, InterpolationValue& endValue)
{
const Vector<SVGPathSegType>& startTypes = toSVGPathNonInterpolableValue(startValue.nonInterpolableValue())->pathSegTypes();
const Vector<SVGPathSegType>& endTypes = toSVGPathNonInterpolableValue(endValue.nonInterpolableValue())->pathSegTypes();
if (!pathSegTypesMatch(startTypes, endTypes))
return nullptr;
- return PairwisePrimitiveInterpolation::create(*this,
+ return PairwisePrimitiveInterpolation::create(type,
startValue.mutableComponent().interpolableValue.release(),
endValue.mutableComponent().interpolableValue.release(),
const_cast<NonInterpolableValue*>(endValue.nonInterpolableValue())); // Take ref.
}
-void SVGPathInterpolationType::composite(UnderlyingValue& underlyingValue, double underlyingFraction, const InterpolationValue& value) const
+void PathInterpolationFunctions::composite(UnderlyingValue& underlyingValue, double underlyingFraction, const InterpolationValue& value)
{
const InterpolableList& list = toInterpolableList(value.interpolableValue());
double neutralComponent = toInterpolableNumber(list.get(PathNeutralIndex))->value();
@@ -155,7 +153,7 @@ void SVGPathInterpolationType::composite(UnderlyingValue& underlyingValue, doubl
underlyingValue.mutableComponent().nonInterpolableValue = const_cast<NonInterpolableValue*>(value.nonInterpolableValue()); // Take ref.
}
-PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGPathInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue) const
+PassRefPtr<SVGPathByteStream> PathInterpolationFunctions::appliedValue(const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue)
{
RefPtr<SVGPathByteStream> pathByteStream = SVGPathByteStream::create();
InterpolatedSVGPathSource source(
@@ -163,7 +161,7 @@ PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGPathInterpolationType::appliedSVGValu
toSVGPathNonInterpolableValue(nonInterpolableValue)->pathSegTypes());
SVGPathByteStreamBuilder builder(*pathByteStream);
SVGPathParser(&source, &builder).parsePathDataFromSource(UnalteredParsing, false);
- return SVGPath::create(CSSPathValue::create(pathByteStream.release()));
+ return pathByteStream.release();
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698