Index: third_party/WebKit/Source/core/animation/SVGIntegerOptionalIntegerInterpolationType.cpp |
diff --git a/third_party/WebKit/Source/core/animation/SVGIntegerOptionalIntegerInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGIntegerOptionalIntegerInterpolationType.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5292ce2280eca71eaa3753fbd0a00ab7e69dcb70 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/animation/SVGIntegerOptionalIntegerInterpolationType.cpp |
@@ -0,0 +1,53 @@ |
+// 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/SVGIntegerOptionalIntegerInterpolationType.h" |
+ |
+#include "core/animation/InterpolationEnvironment.h" |
+#include "core/animation/StringKeyframe.h" |
+#include "core/svg/SVGIntegerOptionalInteger.h" |
+#include "core/svg/properties/SVGAnimatedProperty.h" |
+ |
+namespace blink { |
+ |
+namespace { |
+ |
+PassRefPtrWillBeRawPtr<SVGInteger> toPositiveInteger(const InterpolableValue* number) |
+{ |
+ return SVGInteger::create(clampTo<int>(roundf(toInterpolableNumber(number)->value()), 1)); |
+} |
+ |
+} // namespace |
+ |
+PassOwnPtr<InterpolationValue> SVGIntegerOptionalIntegerInterpolationType::maybeConvertNeutral() const |
+{ |
+ return InterpolationValue::create(*this, InterpolableNumber::create(0)); |
+} |
+ |
+PassOwnPtr<InterpolationValue> SVGIntegerOptionalIntegerInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const |
+{ |
+ if (svgValue.type() != AnimatedIntegerOptionalInteger) |
+ return nullptr; |
+ const SVGIntegerOptionalInteger& integerOptionalInteger = toSVGIntegerOptionalInteger(svgValue); |
+ OwnPtr<InterpolableList> result = InterpolableList::create(2); |
+ result->set(0, InterpolableNumber::create(integerOptionalInteger.firstInteger()->value())); |
+ result->set(1, InterpolableNumber::create(integerOptionalInteger.secondInteger()->value())); |
+ return InterpolationValue::create(*this, result.release()); |
+} |
+ |
+PassOwnPtr<InterpolationValue> SVGIntegerOptionalIntegerInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const |
+{ |
+ return maybeConvertSVGValue(environment.svgBaseValue()); |
+} |
+ |
+RefPtrWillBeRawPtr<SVGPropertyBase> SVGIntegerOptionalIntegerInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue*) const |
+{ |
+ const InterpolableList& list = toInterpolableList(interpolableValue); |
+ return SVGIntegerOptionalInteger::create( |
+ toPositiveInteger(list.get(0)), |
+ toPositiveInteger(list.get(1))); |
+} |
+ |
+} // namespace blink |