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

Side by Side Diff: third_party/WebKit/Source/core/animation/SizeListPropertyFunctions.cpp

Issue 2794013002: Fewer reused duplicate symbol names in animation. (Closed)
Patch Set: Addressed review comments. Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/animation/SizeListPropertyFunctions.h" 5 #include "core/animation/SizeListPropertyFunctions.h"
6 6
7 #include "core/style/ComputedStyle.h" 7 #include "core/style/ComputedStyle.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 static const FillLayer* getFillLayer(CSSPropertyID property, 11 static const FillLayer* getFillLayerForSize(CSSPropertyID property,
12 const ComputedStyle& style) { 12 const ComputedStyle& style) {
13 switch (property) { 13 switch (property) {
14 case CSSPropertyBackgroundSize: 14 case CSSPropertyBackgroundSize:
15 return &style.backgroundLayers(); 15 return &style.backgroundLayers();
16 case CSSPropertyWebkitMaskSize: 16 case CSSPropertyWebkitMaskSize:
17 return &style.maskLayers(); 17 return &style.maskLayers();
18 default: 18 default:
19 NOTREACHED(); 19 NOTREACHED();
20 return nullptr; 20 return nullptr;
21 } 21 }
22 } 22 }
23 23
24 static FillLayer* accessFillLayer(CSSPropertyID property, 24 static FillLayer* accessFillLayerForSize(CSSPropertyID property,
25 ComputedStyle& style) { 25 ComputedStyle& style) {
26 switch (property) { 26 switch (property) {
27 case CSSPropertyBackgroundSize: 27 case CSSPropertyBackgroundSize:
28 return &style.accessBackgroundLayers(); 28 return &style.accessBackgroundLayers();
29 case CSSPropertyWebkitMaskSize: 29 case CSSPropertyWebkitMaskSize:
30 return &style.accessMaskLayers(); 30 return &style.accessMaskLayers();
31 default: 31 default:
32 NOTREACHED(); 32 NOTREACHED();
33 return nullptr; 33 return nullptr;
34 } 34 }
35 } 35 }
36 36
37 SizeList SizeListPropertyFunctions::getInitialSizeList(CSSPropertyID property) { 37 SizeList SizeListPropertyFunctions::getInitialSizeList(CSSPropertyID property) {
38 return getSizeList(property, ComputedStyle::initialStyle()); 38 return getSizeList(property, ComputedStyle::initialStyle());
39 } 39 }
40 40
41 SizeList SizeListPropertyFunctions::getSizeList(CSSPropertyID property, 41 SizeList SizeListPropertyFunctions::getSizeList(CSSPropertyID property,
42 const ComputedStyle& style) { 42 const ComputedStyle& style) {
43 SizeList result; 43 SizeList result;
44 for (const FillLayer* fillLayer = getFillLayer(property, style); 44 for (const FillLayer* fillLayer = getFillLayerForSize(property, style);
45 fillLayer && fillLayer->isSizeSet(); fillLayer = fillLayer->next()) 45 fillLayer && fillLayer->isSizeSet(); fillLayer = fillLayer->next())
46 result.push_back(fillLayer->size()); 46 result.push_back(fillLayer->size());
47 return result; 47 return result;
48 } 48 }
49 49
50 void SizeListPropertyFunctions::setSizeList(CSSPropertyID property, 50 void SizeListPropertyFunctions::setSizeList(CSSPropertyID property,
51 ComputedStyle& style, 51 ComputedStyle& style,
52 const SizeList& sizeList) { 52 const SizeList& sizeList) {
53 FillLayer* fillLayer = accessFillLayer(property, style); 53 FillLayer* fillLayer = accessFillLayerForSize(property, style);
54 FillLayer* prev = nullptr; 54 FillLayer* prev = nullptr;
55 for (const FillSize& size : sizeList) { 55 for (const FillSize& size : sizeList) {
56 if (!fillLayer) 56 if (!fillLayer)
57 fillLayer = prev->ensureNext(); 57 fillLayer = prev->ensureNext();
58 fillLayer->setSize(size); 58 fillLayer->setSize(size);
59 prev = fillLayer; 59 prev = fillLayer;
60 fillLayer = fillLayer->next(); 60 fillLayer = fillLayer->next();
61 } 61 }
62 while (fillLayer) { 62 while (fillLayer) {
63 fillLayer->clearSize(); 63 fillLayer->clearSize();
64 fillLayer = fillLayer->next(); 64 fillLayer = fillLayer->next();
65 } 65 }
66 } 66 }
67 67
68 } // namespace blink 68 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698