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

Unified Diff: Source/core/animation/NumberSVGInterpolation.cpp

Issue 1068973004: Web Animations: Support animation of SVG number attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 8 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
« no previous file with comments | « Source/core/animation/NumberSVGInterpolation.h ('k') | Source/core/animation/StringKeyframe.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
+
+}
« no previous file with comments | « Source/core/animation/NumberSVGInterpolation.h ('k') | Source/core/animation/StringKeyframe.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698