Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/animation/SizeListPropertyFunctions.h" | |
| 6 | |
| 7 #include "core/style/ComputedStyle.h" | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 static const FillLayer* getFillLayer(CSSPropertyID property, const ComputedStyle & style) | |
| 12 { | |
| 13 switch (property) { | |
| 14 case CSSPropertyBackgroundSize: | |
| 15 return &style.backgroundLayers(); | |
| 16 case CSSPropertyWebkitMaskSize: | |
| 17 return &style.maskLayers(); | |
| 18 default: | |
| 19 NOTREACHED(); | |
| 20 return nullptr; | |
| 21 } | |
| 22 } | |
| 23 | |
| 24 static FillLayer* accessFillLayer(CSSPropertyID property, ComputedStyle& style) | |
| 25 { | |
| 26 switch (property) { | |
| 27 case CSSPropertyBackgroundSize: | |
| 28 return &style.accessBackgroundLayers(); | |
| 29 case CSSPropertyWebkitMaskSize: | |
| 30 return &style.accessMaskLayers(); | |
| 31 default: | |
| 32 NOTREACHED(); | |
| 33 return nullptr; | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 SizeList SizeListPropertyFunctions::getInitialSizeList(CSSPropertyID property) | |
| 38 { | |
| 39 return getSizeList(property, ComputedStyle::initialStyle()); | |
| 40 } | |
| 41 | |
| 42 SizeList SizeListPropertyFunctions::getSizeList(CSSPropertyID property, const Co mputedStyle& style) | |
| 43 { | |
| 44 SizeList result; | |
| 45 for (const FillLayer* fillLayer = getFillLayer(property, style); fillLayer & & fillLayer->isSizeSet(); fillLayer = fillLayer->next()) | |
|
Eric Willigers
2016/08/31 01:47:06
We stop when we hit a fillLayer with size not set,
alancutter (OOO until 2018)
2016/09/05 07:44:27
Yes. Unset/nullptr indicates the end of the list.
| |
| 46 result.append(fillLayer->size()); | |
| 47 return result; | |
| 48 } | |
| 49 | |
| 50 void SizeListPropertyFunctions::setSizeList(CSSPropertyID property, ComputedStyl e& style, SizeList& sizeList) | |
| 51 { | |
| 52 FillLayer* fillLayer = accessFillLayer(property, style); | |
| 53 FillLayer* prev = nullptr; | |
| 54 for (const FillSize& size : sizeList) { | |
| 55 if (!fillLayer) | |
| 56 fillLayer = prev->ensureNext(); | |
| 57 fillLayer->setSize(size); | |
| 58 prev = fillLayer; | |
| 59 fillLayer = fillLayer->next(); | |
| 60 } | |
| 61 while (fillLayer) { | |
| 62 fillLayer->clearSize(); | |
| 63 fillLayer = fillLayer->next(); | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 } // namespace blink | |
| OLD | NEW |