Chromium Code Reviews| Index: third_party/WebKit/Source/core/animation/SVGNumberListInterpolationType.cpp |
| diff --git a/third_party/WebKit/Source/core/animation/SVGNumberListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGNumberListInterpolationType.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ad0688b7cc52fac66ebb45b0c3d1c62173c3c12a |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/animation/SVGNumberListInterpolationType.cpp |
| @@ -0,0 +1,51 @@ |
| +// 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/SVGNumberListInterpolationType.h" |
| + |
| +#include "core/animation/InterpolationEnvironment.h" |
| +#include "core/svg/SVGNumberList.h" |
| +#include "core/svg/properties/SVGAnimatedProperty.h" |
| + |
| +namespace blink { |
| + |
| +PassOwnPtr<InterpolationValue> SVGNumberListInterpolationType::maybeConvertNeutral() const |
| +{ |
| + return InterpolationValue::create(*this, InterpolableList::create(0)); |
| +} |
| + |
| +PassOwnPtr<InterpolationValue> SVGNumberListInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const |
| +{ |
| + if (svgValue.type() != AnimatedNumberList) |
| + return nullptr; |
| + const SVGNumberList& svgList = static_cast<const SVGNumberList&>(svgValue); |
|
alancutter (OOO until 2018)
2015/11/03 03:23:58
Add DEFINE_SVG_PROPERTY_TYPE_CASTS() to SVGNumberL
|
| + OwnPtr<InterpolableList> result = InterpolableList::create(svgList.length()); |
| + for (size_t i = 0; i < svgList.length(); i++) |
| + result->set(i, InterpolableNumber::create(svgList.at(i)->value())); |
| + return InterpolationValue::create(*this, result.release()); |
| +} |
| + |
| +PassOwnPtr<InterpolationValue> SVGNumberListInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const |
| +{ |
| + return maybeConvertSVGValue(environment.svgBaseValue()); |
| +} |
| + |
| +RefPtrWillBeRawPtr<SVGPropertyBase> SVGNumberListInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue*) const |
| +{ |
| + RefPtrWillBeRawPtr<SVGNumberList> result = SVGNumberList::create(); |
| + const InterpolableList& list = toInterpolableList(interpolableValue); |
| + for (size_t i = 0; i < list.length(); ++i) |
| + result->append(SVGNumber::create(toInterpolableNumber(list.get(i))->value())); |
| + return result.release(); |
| +} |
| + |
| +PassOwnPtr<PairwisePrimitiveInterpolation> SVGNumberListInterpolationType::mergeSingleConversions(InterpolationValue& startValue, InterpolationValue& endValue) const |
| +{ |
| + if (toInterpolableList(startValue.interpolableValue()).length() != toInterpolableList(endValue.interpolableValue()).length()) |
| + return nullptr; |
| + return InterpolationType::mergeSingleConversions(startValue, endValue); |
| +} |
| + |
| +} // namespace blink |