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

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

Issue 1680803003: Add additive animation support for CSS property background-position (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove redundant braces Created 4 years, 10 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
Index: third_party/WebKit/Source/core/animation/CSSPositionAxisListInterpolationType.cpp
diff --git a/third_party/WebKit/Source/core/animation/CSSPositionAxisListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSPositionAxisListInterpolationType.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..93d79823aaaa3af4b6158a7f75e8120fd7e84fad
--- /dev/null
+++ b/third_party/WebKit/Source/core/animation/CSSPositionAxisListInterpolationType.cpp
@@ -0,0 +1,42 @@
+// Copyright 2016 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 "core/animation/CSSPositionAxisListInterpolationType.h"
+
+#include "core/animation/CSSLengthInterpolationType.h"
+#include "core/animation/ListInterpolationFunctions.h"
+#include "core/css/CSSPrimitiveValue.h"
+#include "core/css/CSSValueList.h"
+#include "core/css/CSSValuePair.h"
+
+namespace blink {
+
+static InterpolationValue convertPositionAxisCSSValue(const CSSValue& value)
+{
+ if (!value.isValuePair())
+ return CSSLengthInterpolationType::maybeConvertCSSValue(value);
+
+ const CSSValuePair& pair = toCSSValuePair(value);
+ InterpolationValue result = CSSLengthInterpolationType::maybeConvertCSSValue(pair.second());
+ CSSValueID side = toCSSPrimitiveValue(pair.first()).getValueID();
+ if (side == CSSValueRight || side == CSSValueBottom)
+ CSSLengthInterpolationType::subtractFromOneHundredPercent(result);
+ return result;
+}
+
+InterpolationValue CSSPositionAxisListInterpolationType::maybeConvertValue(const CSSValue& value, const StyleResolverState&, ConversionCheckers&) const
+{
+ if (!value.isBaseValueList()) {
+ return ListInterpolationFunctions::createList(1, [&value](size_t) {
+ return convertPositionAxisCSSValue(value);
+ });
+ }
+
+ const CSSValueList& list = toCSSValueList(value);
+ return ListInterpolationFunctions::createList(list.length(), [&list](size_t index) {
+ return convertPositionAxisCSSValue(*list.item(index));
+ });
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698