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

Side by Side Diff: third_party/WebKit/Source/core/animation/LengthListPropertyFunctions.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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/LengthListPropertyFunctions.h" 5 #include "core/animation/LengthListPropertyFunctions.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 namespace { 11 namespace {
12 12
13 const FillLayer* getFillLayer(CSSPropertyID property, const ComputedStyle& style ) 13 const FillLayer* getFillLayer(CSSPropertyID property, const ComputedStyle& style )
14 { 14 {
15 switch (property) { 15 switch (property) {
16 case CSSPropertyBackgroundPositionX: 16 case CSSPropertyBackgroundPositionX:
17 case CSSPropertyBackgroundPositionY: 17 case CSSPropertyBackgroundPositionY:
18 case CSSPropertyBackgroundSize:
19 return &style.backgroundLayers(); 18 return &style.backgroundLayers();
20 case CSSPropertyWebkitMaskPositionX: 19 case CSSPropertyWebkitMaskPositionX:
21 case CSSPropertyWebkitMaskPositionY: 20 case CSSPropertyWebkitMaskPositionY:
22 case CSSPropertyWebkitMaskSize:
23 return &style.maskLayers(); 21 return &style.maskLayers();
24 default: 22 default:
25 NOTREACHED(); 23 NOTREACHED();
26 return nullptr; 24 return nullptr;
27 } 25 }
28 } 26 }
29 27
30 FillLayer* accessFillLayer(CSSPropertyID property, ComputedStyle& style) 28 FillLayer* accessFillLayer(CSSPropertyID property, ComputedStyle& style)
31 { 29 {
32 switch (property) { 30 switch (property) {
33 case CSSPropertyBackgroundPositionX: 31 case CSSPropertyBackgroundPositionX:
34 case CSSPropertyBackgroundPositionY: 32 case CSSPropertyBackgroundPositionY:
35 case CSSPropertyBackgroundSize:
36 return &style.accessBackgroundLayers(); 33 return &style.accessBackgroundLayers();
37 case CSSPropertyWebkitMaskPositionX: 34 case CSSPropertyWebkitMaskPositionX:
38 case CSSPropertyWebkitMaskPositionY: 35 case CSSPropertyWebkitMaskPositionY:
39 case CSSPropertyWebkitMaskSize:
40 return &style.accessMaskLayers(); 36 return &style.accessMaskLayers();
41 default: 37 default:
42 NOTREACHED(); 38 NOTREACHED();
43 return nullptr; 39 return nullptr;
44 } 40 }
45 } 41 }
46 42
47 struct FillLayerMethods { 43 struct FillLayerMethods {
48 FillLayerMethods(CSSPropertyID property) 44 FillLayerMethods(CSSPropertyID property)
49 { 45 {
50 isSet = nullptr; 46 isSet = nullptr;
51 getLength = nullptr; 47 getLength = nullptr;
52 setLength = nullptr; 48 setLength = nullptr;
53 getFillSize = nullptr;
54 setFillSize = nullptr;
55 clear = nullptr; 49 clear = nullptr;
56 switch (property) { 50 switch (property) {
suzyh_UTC10 (ex-contributor) 2016/08/26 04:14:34 After this change, the four CSSPropertyIDs that ar
alancutter (OOO until 2018) 2016/08/26 13:31:48 We could inline the specific method calls (like se
57 case CSSPropertyBackgroundPositionX: 51 case CSSPropertyBackgroundPositionX:
58 case CSSPropertyWebkitMaskPositionX: 52 case CSSPropertyWebkitMaskPositionX:
59 isSet = &FillLayer::isXPositionSet; 53 isSet = &FillLayer::isXPositionSet;
60 getLength = &FillLayer::xPosition; 54 getLength = &FillLayer::xPosition;
61 setLength = &FillLayer::setXPosition; 55 setLength = &FillLayer::setXPosition;
62 clear = &FillLayer::clearXPosition; 56 clear = &FillLayer::clearXPosition;
63 break; 57 break;
64 case CSSPropertyBackgroundPositionY: 58 case CSSPropertyBackgroundPositionY:
65 case CSSPropertyWebkitMaskPositionY: 59 case CSSPropertyWebkitMaskPositionY:
66 isSet = &FillLayer::isYPositionSet; 60 isSet = &FillLayer::isYPositionSet;
67 getLength = &FillLayer::yPosition; 61 getLength = &FillLayer::yPosition;
68 setLength = &FillLayer::setYPosition; 62 setLength = &FillLayer::setYPosition;
69 clear = &FillLayer::clearYPosition; 63 clear = &FillLayer::clearYPosition;
70 break; 64 break;
71 case CSSPropertyBackgroundSize:
72 case CSSPropertyWebkitMaskSize:
73 isSet = &FillLayer::isSizeSet;
74 getFillSize = &FillLayer::size;
75 setFillSize = &FillLayer::setSize;
76 clear = &FillLayer::clearSize;
77 break;
78 default: 65 default:
79 NOTREACHED(); 66 NOTREACHED();
80 break; 67 break;
81 } 68 }
82 } 69 }
83 70
84 bool (FillLayer::*isSet)() const; 71 bool (FillLayer::*isSet)() const;
85 const Length& (FillLayer::*getLength)() const; 72 const Length& (FillLayer::*getLength)() const;
86 void (FillLayer::*setLength)(const Length&); 73 void (FillLayer::*setLength)(const Length&);
87 FillSize (FillLayer::*getFillSize)() const;
88 void (FillLayer::*setFillSize)(const FillSize&);
89 void (FillLayer::*clear)(); 74 void (FillLayer::*clear)();
90 }; 75 };
91 76
92 } // namespace 77 } // namespace
93 78
94 ValueRange LengthListPropertyFunctions::getValueRange(CSSPropertyID property) 79 ValueRange LengthListPropertyFunctions::getValueRange(CSSPropertyID property)
95 { 80 {
96 switch (property) { 81 switch (property) {
97 case CSSPropertyBackgroundPositionX: 82 case CSSPropertyBackgroundPositionX:
98 case CSSPropertyBackgroundPositionY: 83 case CSSPropertyBackgroundPositionY:
99 case CSSPropertyObjectPosition: 84 case CSSPropertyObjectPosition:
100 case CSSPropertyPerspectiveOrigin: 85 case CSSPropertyPerspectiveOrigin:
101 case CSSPropertyTransformOrigin: 86 case CSSPropertyTransformOrigin:
102 case CSSPropertyWebkitMaskPositionX: 87 case CSSPropertyWebkitMaskPositionX:
103 case CSSPropertyWebkitMaskPositionY: 88 case CSSPropertyWebkitMaskPositionY:
104 return ValueRangeAll; 89 return ValueRangeAll;
105 90
106 case CSSPropertyBackgroundSize:
107 case CSSPropertyBorderBottomLeftRadius: 91 case CSSPropertyBorderBottomLeftRadius:
108 case CSSPropertyBorderBottomRightRadius: 92 case CSSPropertyBorderBottomRightRadius:
109 case CSSPropertyBorderTopLeftRadius: 93 case CSSPropertyBorderTopLeftRadius:
110 case CSSPropertyBorderTopRightRadius: 94 case CSSPropertyBorderTopRightRadius:
111 case CSSPropertyStrokeDasharray: 95 case CSSPropertyStrokeDasharray:
112 case CSSPropertyWebkitMaskSize:
113 return ValueRangeNonNegative; 96 return ValueRangeNonNegative;
114 97
115 default: 98 default:
116 NOTREACHED(); 99 NOTREACHED();
117 return ValueRangeAll; 100 return ValueRangeAll;
118 } 101 }
119 } 102 }
120 103
121 bool LengthListPropertyFunctions::getInitialLengthList(CSSPropertyID property, V ector<Length>& result) 104 bool LengthListPropertyFunctions::getInitialLengthList(CSSPropertyID property, V ector<Length>& result)
122 { 105 {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 case CSSPropertyWebkitMaskPositionX: 159 case CSSPropertyWebkitMaskPositionX:
177 case CSSPropertyWebkitMaskPositionY: { 160 case CSSPropertyWebkitMaskPositionY: {
178 const FillLayer* fillLayer = getFillLayer(property, style); 161 const FillLayer* fillLayer = getFillLayer(property, style);
179 FillLayerMethods fillLayerMethods(property); 162 FillLayerMethods fillLayerMethods(property);
180 while (fillLayer && (fillLayer->*fillLayerMethods.isSet)()) { 163 while (fillLayer && (fillLayer->*fillLayerMethods.isSet)()) {
181 result.append((fillLayer->*fillLayerMethods.getLength)()); 164 result.append((fillLayer->*fillLayerMethods.getLength)());
182 fillLayer = fillLayer->next(); 165 fillLayer = fillLayer->next();
183 } 166 }
184 return true; 167 return true;
185 } 168 }
186 case CSSPropertyBackgroundSize:
187 case CSSPropertyWebkitMaskSize: {
188 const FillLayer* fillLayer = getFillLayer(property, style);
189 FillLayerMethods fillLayerMethods(property);
190 while (fillLayer && (fillLayer->*fillLayerMethods.isSet)()) {
191 FillSize fillSize = (fillLayer->*fillLayerMethods.getFillSize)();
192 if (fillSize.type != SizeLength) {
193 result.clear();
194 return false;
195 }
196 result.append(fillSize.size.width());
197 result.append(fillSize.size.height());
198 fillLayer = fillLayer->next();
199 }
200 return true;
201 }
202 169
203 default: 170 default:
204 NOTREACHED(); 171 NOTREACHED();
205 return false; 172 return false;
206 } 173 }
207 } 174 }
208 175
209 static LengthPoint pointFromVector(const Vector<Length>& list) 176 static LengthPoint pointFromVector(const Vector<Length>& list)
210 { 177 {
211 DCHECK_EQ(list.size(), 2U); 178 DCHECK_EQ(list.size(), 2U);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 prev = fillLayer; 236 prev = fillLayer;
270 fillLayer = fillLayer->next(); 237 fillLayer = fillLayer->next();
271 } 238 }
272 while (fillLayer) { 239 while (fillLayer) {
273 (fillLayer->*fillLayerMethods.clear)(); 240 (fillLayer->*fillLayerMethods.clear)();
274 fillLayer = fillLayer->next(); 241 fillLayer = fillLayer->next();
275 } 242 }
276 return; 243 return;
277 } 244 }
278 245
279 case CSSPropertyBackgroundSize:
280 case CSSPropertyWebkitMaskSize: {
281 DCHECK_EQ(lengthList.size() % 2, 0U);
282 FillLayer* fillLayer = accessFillLayer(property, style);
283 FillLayer* prev = nullptr;
284 FillLayerMethods fillLayerMethods(property);
285 for (size_t i = 0; i < lengthList.size() / 2; i++) {
286 if (!fillLayer)
287 fillLayer = prev->ensureNext();
288 FillSize fillSize(SizeLength, LengthSize(lengthList[2 * i], lengthLi st[2 * i + 1]));
289 (fillLayer->*fillLayerMethods.setFillSize)(fillSize);
290 prev = fillLayer;
291 fillLayer = fillLayer->next();
292 }
293 while (fillLayer) {
294 (fillLayer->*fillLayerMethods.clear)();
295 fillLayer = fillLayer->next();
296 }
297 return;
298 }
299
300 default: 246 default:
301 NOTREACHED(); 247 NOTREACHED();
302 break; 248 break;
303 } 249 }
304 } 250 }
305 251
306 } // namespace blink 252 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698