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

Side by Side Diff: third_party/WebKit/Source/core/animation/LengthListPropertyFunctions.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 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, 13 const FillLayer* getFillLayerForPosition(CSSPropertyID property,
14 const ComputedStyle& style) { 14 const ComputedStyle& style) {
15 switch (property) { 15 switch (property) {
16 case CSSPropertyBackgroundPositionX: 16 case CSSPropertyBackgroundPositionX:
17 case CSSPropertyBackgroundPositionY: 17 case CSSPropertyBackgroundPositionY:
18 return &style.backgroundLayers(); 18 return &style.backgroundLayers();
19 case CSSPropertyWebkitMaskPositionX: 19 case CSSPropertyWebkitMaskPositionX:
20 case CSSPropertyWebkitMaskPositionY: 20 case CSSPropertyWebkitMaskPositionY:
21 return &style.maskLayers(); 21 return &style.maskLayers();
22 default: 22 default:
23 NOTREACHED(); 23 NOTREACHED();
24 return nullptr; 24 return nullptr;
25 } 25 }
26 } 26 }
27 27
28 FillLayer* accessFillLayer(CSSPropertyID property, ComputedStyle& style) { 28 FillLayer* accessFillLayerForPosition(CSSPropertyID property,
29 ComputedStyle& style) {
29 switch (property) { 30 switch (property) {
30 case CSSPropertyBackgroundPositionX: 31 case CSSPropertyBackgroundPositionX:
31 case CSSPropertyBackgroundPositionY: 32 case CSSPropertyBackgroundPositionY:
32 return &style.accessBackgroundLayers(); 33 return &style.accessBackgroundLayers();
33 case CSSPropertyWebkitMaskPositionX: 34 case CSSPropertyWebkitMaskPositionX:
34 case CSSPropertyWebkitMaskPositionY: 35 case CSSPropertyWebkitMaskPositionY:
35 return &style.accessMaskLayers(); 36 return &style.accessMaskLayers();
36 default: 37 default:
37 NOTREACHED(); 38 NOTREACHED();
38 return nullptr; 39 return nullptr;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return appendToVector(style.borderTopLeftRadius(), result); 153 return appendToVector(style.borderTopLeftRadius(), result);
153 case CSSPropertyBorderTopRightRadius: 154 case CSSPropertyBorderTopRightRadius:
154 return appendToVector(style.borderTopRightRadius(), result); 155 return appendToVector(style.borderTopRightRadius(), result);
155 case CSSPropertyTransformOrigin: 156 case CSSPropertyTransformOrigin:
156 return appendToVector(style.transformOrigin(), result); 157 return appendToVector(style.transformOrigin(), result);
157 158
158 case CSSPropertyBackgroundPositionX: 159 case CSSPropertyBackgroundPositionX:
159 case CSSPropertyBackgroundPositionY: 160 case CSSPropertyBackgroundPositionY:
160 case CSSPropertyWebkitMaskPositionX: 161 case CSSPropertyWebkitMaskPositionX:
161 case CSSPropertyWebkitMaskPositionY: { 162 case CSSPropertyWebkitMaskPositionY: {
162 const FillLayer* fillLayer = getFillLayer(property, style); 163 const FillLayer* fillLayer = getFillLayerForPosition(property, style);
163 FillLayerMethods fillLayerMethods(property); 164 FillLayerMethods fillLayerMethods(property);
164 while (fillLayer && (fillLayer->*fillLayerMethods.isSet)()) { 165 while (fillLayer && (fillLayer->*fillLayerMethods.isSet)()) {
165 result.push_back((fillLayer->*fillLayerMethods.getLength)()); 166 result.push_back((fillLayer->*fillLayerMethods.getLength)());
166 switch ((fillLayer->*fillLayerMethods.getEdge)()) { 167 switch ((fillLayer->*fillLayerMethods.getEdge)()) {
167 case RightEdge: 168 case RightEdge:
168 case BottomEdge: 169 case BottomEdge:
169 result.back() = result.back().subtractFromOneHundredPercent(); 170 result.back() = result.back().subtractFromOneHundredPercent();
170 break; 171 break;
171 default: 172 default:
172 break; 173 break;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 return; 235 return;
235 236
236 case CSSPropertyTransformOrigin: 237 case CSSPropertyTransformOrigin:
237 style.setTransformOrigin(transformOriginFromVector(lengthList)); 238 style.setTransformOrigin(transformOriginFromVector(lengthList));
238 return; 239 return;
239 240
240 case CSSPropertyBackgroundPositionX: 241 case CSSPropertyBackgroundPositionX:
241 case CSSPropertyBackgroundPositionY: 242 case CSSPropertyBackgroundPositionY:
242 case CSSPropertyWebkitMaskPositionX: 243 case CSSPropertyWebkitMaskPositionX:
243 case CSSPropertyWebkitMaskPositionY: { 244 case CSSPropertyWebkitMaskPositionY: {
244 FillLayer* fillLayer = accessFillLayer(property, style); 245 FillLayer* fillLayer = accessFillLayerForPosition(property, style);
245 FillLayer* prev = nullptr; 246 FillLayer* prev = nullptr;
246 FillLayerMethods fillLayerMethods(property); 247 FillLayerMethods fillLayerMethods(property);
247 for (size_t i = 0; i < lengthList.size(); i++) { 248 for (size_t i = 0; i < lengthList.size(); i++) {
248 if (!fillLayer) 249 if (!fillLayer)
249 fillLayer = prev->ensureNext(); 250 fillLayer = prev->ensureNext();
250 (fillLayer->*fillLayerMethods.setLength)(lengthList[i]); 251 (fillLayer->*fillLayerMethods.setLength)(lengthList[i]);
251 prev = fillLayer; 252 prev = fillLayer;
252 fillLayer = fillLayer->next(); 253 fillLayer = fillLayer->next();
253 } 254 }
254 while (fillLayer) { 255 while (fillLayer) {
255 (fillLayer->*fillLayerMethods.clear)(); 256 (fillLayer->*fillLayerMethods.clear)();
256 fillLayer = fillLayer->next(); 257 fillLayer = fillLayer->next();
257 } 258 }
258 return; 259 return;
259 } 260 }
260 261
261 default: 262 default:
262 NOTREACHED(); 263 NOTREACHED();
263 break; 264 break;
264 } 265 }
265 } 266 }
266 267
267 } // namespace blink 268 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698