Index: Source/core/animation/NumberSVGInterpolation.cpp |
diff --git a/Source/core/animation/NumberSVGInterpolation.cpp b/Source/core/animation/NumberSVGInterpolation.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..36a504cbecaf61f6faa40f908b3a615e2acd3878 |
--- /dev/null |
+++ b/Source/core/animation/NumberSVGInterpolation.cpp |
@@ -0,0 +1,24 @@ |
+// 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/NumberSVGInterpolation.h" |
+ |
+namespace blink { |
+ |
+PassRefPtrWillBeRawPtr<NumberSVGInterpolation> NumberSVGInterpolation::create(SVGPropertyBase* start, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute) |
+{ |
+ SVGNumberNegativeValuesMode negativeValuesMode = &attribute->attributeName() == &SVGNames::pathLengthAttr ? ForbidNegativeNumbers : AllowNegativeNumbers; |
alancutter (OOO until 2018)
2015/04/20 07:39:40
It would be more consistent to have this property
Eric Willigers
2015/04/21 00:51:16
Done. Also done for IntegerOptionalInteger.
|
+ return adoptRefWillBeNoop(new NumberSVGInterpolation(toInterpolableValue(start), toInterpolableValue(end), attribute, negativeValuesMode)); |
+} |
+ |
+PassRefPtrWillBeRawPtr<SVGNumber> NumberSVGInterpolation::fromInterpolableValue(const InterpolableValue& value, SVGNumberNegativeValuesMode negativeValuesMode) |
+{ |
+ double doubleValue = toInterpolableNumber(value).value(); |
+ if (negativeValuesMode == ForbidNegativeNumbers && doubleValue < 0) |
+ doubleValue = 0; |
+ return SVGNumber::create(doubleValue); |
+} |
+ |
+} |