Chromium Code Reviews| Index: third_party/WebKit/Source/core/animation/SVGRectInterpolationType.cpp |
| diff --git a/third_party/WebKit/Source/core/animation/SVGRectInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGRectInterpolationType.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2cbcc240708305b1a8f530cce960f5deb28f0bf7 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/animation/SVGRectInterpolationType.cpp |
| @@ -0,0 +1,46 @@ |
| +// 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/SVGRectInterpolationType.h" |
| + |
| +#include "core/animation/InterpolationEnvironment.h" |
| +#include "core/animation/StringKeyframe.h" |
| +#include "core/svg/SVGRect.h" |
| +#include "wtf/StdLibExtras.h" |
| + |
| +namespace blink { |
| + |
| +PassOwnPtr<InterpolationValue> SVGRectInterpolationType::maybeConvertNeutral() const |
| +{ |
| + return InterpolationValue::create(*this, InterpolableNumber::create(0)); |
|
alancutter (OOO until 2018)
2015/11/03 04:41:44
This is not compatible with the output of maybeCon
nainar
2015/11/03 06:37:47
Done.
|
| +} |
| + |
| +PassOwnPtr<InterpolationValue> SVGRectInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const |
| +{ |
| + const SVGRect& rect = toSVGRect(svgValue); |
| + float element[] = { rect.x(), rect.y(), rect.width(), rect.height() }; |
| + OwnPtr<InterpolableList> result = InterpolableList::create(WTF_ARRAY_LENGTH(element)); |
| + for (size_t i = 0; i < WTF_ARRAY_LENGTH(element); i++) { |
| + result->set(i, InterpolableNumber::create(element[i])); |
| + } |
| + return InterpolationValue::create(*this, result.release()); |
| +} |
| + |
| +PassOwnPtr<InterpolationValue> SVGRectInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const |
| +{ |
| + return maybeConvertSVGValue(environment.svgBaseValue()); |
| +} |
| + |
| +RefPtrWillBeRawPtr<SVGPropertyBase> SVGRectInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue*) const |
| +{ |
| + const InterpolableList& list = toInterpolableList(interpolableValue); |
| + RefPtrWillBeRawPtr<SVGRect> result = SVGRect::create(); |
| + result->setX(toInterpolableNumber(list.get(0))->value()); |
| + result->setY(toInterpolableNumber(list.get(1))->value()); |
| + result->setWidth(toInterpolableNumber(list.get(2))->value()); |
| + result->setHeight(toInterpolableNumber(list.get(3))->value()); |
| + return result; |
| +} |
| + |
| +} // namespace blink |