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

Unified Diff: third_party/WebKit/Source/core/animation/SVGIntegerOptionalIntegerInterpolationType.cpp

Issue 1417483015: SVG Web Animations: Add SVGIntegerOptionalIntegerInterpolationType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More test work... Some failing Created 5 years, 1 month 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
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

Powered by Google App Engine
This is Rietveld 408576698