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

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

Issue 2280553002: Allow interpolation of background-size values with keywords in CSS Animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove DCHECK Created 4 years, 3 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/SizeListPropertyFunctions.cpp
diff --git a/third_party/WebKit/Source/core/animation/SizeListPropertyFunctions.cpp b/third_party/WebKit/Source/core/animation/SizeListPropertyFunctions.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0fe40119e5d65211bff4307f15f0d8615f292494
--- /dev/null
+++ b/third_party/WebKit/Source/core/animation/SizeListPropertyFunctions.cpp
@@ -0,0 +1,67 @@
+// 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/SizeListPropertyFunctions.h"
+
+#include "core/style/ComputedStyle.h"
+
+namespace blink {
+
+static const FillLayer* getFillLayer(CSSPropertyID property, const ComputedStyle& style)
+{
+ switch (property) {
+ case CSSPropertyBackgroundSize:
+ return &style.backgroundLayers();
+ case CSSPropertyWebkitMaskSize:
+ return &style.maskLayers();
+ default:
+ NOTREACHED();
+ return nullptr;
+ }
+}
+
+static FillLayer* accessFillLayer(CSSPropertyID property, ComputedStyle& style)
+{
+ switch (property) {
+ case CSSPropertyBackgroundSize:
+ return &style.accessBackgroundLayers();
+ case CSSPropertyWebkitMaskSize:
+ return &style.accessMaskLayers();
+ default:
+ NOTREACHED();
+ return nullptr;
+ }
+}
+
+SizeList SizeListPropertyFunctions::getInitialSizeList(CSSPropertyID property)
+{
+ return getSizeList(property, ComputedStyle::initialStyle());
+}
+
+SizeList SizeListPropertyFunctions::getSizeList(CSSPropertyID property, const ComputedStyle& style)
+{
+ SizeList result;
+ for (const FillLayer* fillLayer = getFillLayer(property, style); fillLayer && fillLayer->isSizeSet(); fillLayer = fillLayer->next())
+ result.append(fillLayer->size());
+ return result;
+}
+
+void SizeListPropertyFunctions::setSizeList(CSSPropertyID property, ComputedStyle& style, const SizeList& sizeList)
+{
+ FillLayer* fillLayer = accessFillLayer(property, style);
+ FillLayer* prev = nullptr;
+ for (const FillSize& size : sizeList) {
+ if (!fillLayer)
+ fillLayer = prev->ensureNext();
+ fillLayer->setSize(size);
+ prev = fillLayer;
+ fillLayer = fillLayer->next();
+ }
+ while (fillLayer) {
+ fillLayer->clearSize();
+ fillLayer = fillLayer->next();
+ }
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698