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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSPropertyEqualityCustom.cpp

Issue 1910263003: Generate CSSPropertyEquality instead of using hand-updated file. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests2! Created 4 years, 6 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
(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/CSSPropertyEqualityCustom.h"
6
7 #include "core/CSSPropertyNames.h"
8 #include "core/css/CSSPropertyEquality.h"
9 #include "core/style/ComputedStyle.h"
10 #include "core/style/DataEquivalency.h"
11 #include "core/style/FillLayer.h"
12
13 namespace blink {
14
15 namespace {
16
17 template <CSSPropertyID property>
18 bool fillLayersEqual(const FillLayer& aLayers, const FillLayer& bLayers)
19 {
20 const FillLayer* aLayer = &aLayers;
21 const FillLayer* bLayer = &bLayers;
22 while (aLayer && bLayer) {
23 switch (property) {
Timothy Loh 2016/05/24 05:38:35 Maybe it's nicer to pass a getter as the template
24 case CSSPropertyBackgroundPositionX:
25 case CSSPropertyWebkitMaskPositionX:
26 if (aLayer->xPosition() != bLayer->xPosition())
27 return false;
28 break;
29 case CSSPropertyBackgroundPositionY:
30 case CSSPropertyWebkitMaskPositionY:
31 if (aLayer->yPosition() != bLayer->yPosition())
32 return false;
33 break;
34 case CSSPropertyBackgroundSize:
35 case CSSPropertyWebkitMaskSize:
36 if (!(aLayer->sizeLength() == bLayer->sizeLength()))
37 return false;
38 break;
39 case CSSPropertyBackgroundImage:
40 if (!dataEquivalent(aLayer->image(), bLayer->image()))
41 return false;
42 break;
Timothy Loh 2016/05/24 04:38:20 missing breaks on subsequent cases
43 case CSSPropertyWebkitMaskComposite:
44 if (aLayer->composite() != bLayer->composite())
45 return false;
46 case CSSPropertyBackgroundOrigin:
47 case CSSPropertyWebkitMaskOrigin:
48 if (aLayer->origin() != bLayer->origin())
49 return false;
50 case CSSPropertyBackgroundBlendMode:
51 if (aLayer->blendMode() != bLayer->blendMode())
52 return false;
53 case CSSPropertyBackgroundAttachment:
54 if (aLayer->attachment() != bLayer->attachment())
55 return false;
56 case CSSPropertyBackgroundRepeatX:
57 case CSSPropertyWebkitMaskRepeatX:
58 if (aLayer->repeatX() != bLayer->repeatX())
59 return false;
60 case CSSPropertyBackgroundRepeatY:
61 case CSSPropertyWebkitMaskRepeatY:
62 if (aLayer->repeatY() != bLayer->repeatY())
63 return false;
64 case CSSPropertyBackgroundClip:
65 case CSSPropertyWebkitMaskClip:
66 if (aLayer->clip() != bLayer->clip())
67 return false;
68 case CSSPropertyMaskSourceType:
69 if (aLayer->maskSourceType() != bLayer->maskSourceType())
70 return false;
71 default:
72 NOTREACHED();
73 return true;
74 }
75
76 aLayer = aLayer->next();
77 bLayer = bLayer->next();
78 }
79
80 // FIXME: Shouldn't this be return !aLayer && !bLayer; ?
81 return true;
82 }
83
84 } // namespace
85
86 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskBoxImageWidthEqual(const Co mputedStyle& a, const ComputedStyle& b)
87 {
88 return a.maskBoxImageWidth() == b.maskBoxImageWidth();
89 }
90
91 bool CSSPropertyEqualityCustom::CSSPropertySizeEqual(const ComputedStyle& a, con st ComputedStyle& b)
92 {
93 return a.pageSize() == b.pageSize() && a.getPageSizeType() == b.getPageSizeT ype();
94 }
95
96 bool CSSPropertyEqualityCustom::CSSPropertyTextDecorationColorEqual(const Comput edStyle& a, const ComputedStyle& b)
97 {
98 return a.textDecorationColor() == b.textDecorationColor()
99 && a.visitedLinkTextDecorationColor() == b.visitedLinkTextDecorationColo r();
100 }
101
102 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskCompositeEqual(const Comput edStyle& a, const ComputedStyle& b)
103 {
104 return fillLayersEqual<CSSPropertyWebkitMaskComposite>(a.maskLayers(), b.mas kLayers());
105 }
106
107 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskPositionYEqual(const Comput edStyle& a, const ComputedStyle& b)
108 {
109 return fillLayersEqual<CSSPropertyWebkitMaskPositionY>(a.maskLayers(), b.mas kLayers());
110 }
111
112 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskPositionXEqual(const Comput edStyle& a, const ComputedStyle& b)
113 {
114 return fillLayersEqual<CSSPropertyWebkitMaskPositionX>(a.maskLayers(), b.mas kLayers());
115 }
116
117 bool CSSPropertyEqualityCustom::CSSPropertyContentEqual(const ComputedStyle& a, const ComputedStyle& b)
118 {
119 return a.contentDataEquivalent(&b);
120 }
121
122 bool CSSPropertyEqualityCustom::CSSPropertyOutlineColorEqual(const ComputedStyle & a, const ComputedStyle& b)
123 {
124 return a.outlineColor() == b.outlineColor()
125 && a.visitedLinkOutlineColor() == b.visitedLinkOutlineColor();
126 }
127
128 bool CSSPropertyEqualityCustom::CSSPropertyWebkitTextEmphasisStyleEqual(const Co mputedStyle& a, const ComputedStyle& b)
129 {
130 return CSSPropertyEquality::propertiesEqual(CSSPropertyWebkitTextEmphasisCol or, a, b)
131 && CSSPropertyEquality::propertiesEqual(CSSPropertyWebkitTextEmphasisSty le, a, b);
132 }
133
134 bool CSSPropertyEqualityCustom::CSSPropertyWebkitTextStrokeColorEqual(const Comp utedStyle& a, const ComputedStyle& b)
135 {
136 return a.textStrokeColor() == b.textStrokeColor()
137 && a.visitedLinkTextStrokeColor() == b.visitedLinkTextStrokeColor();
138 }
139
140 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskBoxImageOutsetEqual(const C omputedStyle& a, const ComputedStyle& b)
141 {
142 return a.maskBoxImageOutset() == b.maskBoxImageOutset();
143 }
144
145 bool CSSPropertyEqualityCustom::CSSPropertyColumnCountEqual(const ComputedStyle& a, const ComputedStyle& b)
146 {
147 return a.columnCount() == b.columnCount();
148 }
149
150 bool CSSPropertyEqualityCustom::CSSPropertyGridTemplateRowsEqual(const ComputedS tyle& a, const ComputedStyle& b)
151 {
152 return a.gridTemplateRows() == b.gridTemplateRows();
153 }
154
155 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskOriginEqual(const ComputedS tyle& a, const ComputedStyle& b)
156 {
157 return fillLayersEqual<CSSPropertyWebkitMaskOrigin>(a.maskLayers(), b.maskLa yers());
158 }
159
160 bool CSSPropertyEqualityCustom::CSSPropertyFillEqual(const ComputedStyle& a, con st ComputedStyle& b)
161 {
162 const SVGComputedStyle& aSVG = a.svgStyle();
163 const SVGComputedStyle& bSVG = b.svgStyle();
164 return aSVG.fillPaintType() == bSVG.fillPaintType()
165 && (aSVG.fillPaintType() != SVG_PAINTTYPE_RGBCOLOR || aSVG.fillPaintColo r() == bSVG.fillPaintColor())
166 && aSVG.visitedLinkFillPaintType() == bSVG.visitedLinkFillPaintType()
167 && (aSVG.visitedLinkFillPaintType() != SVG_PAINTTYPE_RGBCOLOR || aSVG.vi sitedLinkFillPaintColor() == bSVG.visitedLinkFillPaintColor());
168 }
169
170 bool CSSPropertyEqualityCustom::CSSPropertyZoomEqual(const ComputedStyle& a, con st ComputedStyle& b)
171 {
172 return a.zoom() == b.zoom();
173 }
174
175 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskBoxImageRepeatEqual(const C omputedStyle& a, const ComputedStyle& b)
176 {
177 return a.maskBoxImage().horizontalRule() == b.maskBoxImage().horizontalRule( )
178 && a.maskBoxImage().verticalRule() == b.maskBoxImage().verticalRule();
179 }
180
181 bool CSSPropertyEqualityCustom::CSSPropertyBackgroundAttachmentEqual(const Compu tedStyle& a, const ComputedStyle& b)
182 {
183 return fillLayersEqual<CSSPropertyBackgroundAttachment>(a.backgroundLayers() , b.backgroundLayers());
184 }
185
186 bool CSSPropertyEqualityCustom::CSSPropertyBackgroundImageEqual(const ComputedSt yle& a, const ComputedStyle& b)
187 {
188 return fillLayersEqual<CSSPropertyBackgroundImage>(a.backgroundLayers(), b.b ackgroundLayers());
189 }
190
191 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskClipEqual(const ComputedSty le& a, const ComputedStyle& b)
192 {
193 return fillLayersEqual<CSSPropertyWebkitMaskClip>(a.maskLayers(), b.maskLaye rs());
194 }
195
196 bool CSSPropertyEqualityCustom::CSSPropertyCounterResetEqual(const ComputedStyle & a, const ComputedStyle& b)
197 {
198 const CounterDirectiveMap* aMap = a.counterDirectives();
199 const CounterDirectiveMap* bMap = b.counterDirectives();
200
201 if (!aMap || !bMap)
202 return true;
203
204 if (!aMap) {
205 aMap = bMap;
206 bMap = nullptr;
207 }
208
209 for (const auto& aItem : *aMap) {
210 if (!aItem.value.isReset())
211 continue;
212
213 if (!bMap)
214 return false;
215
216 if (!bMap->contains(aItem.key))
217 return false;
218
219 const auto& bItem = bMap->get(aItem.key);
220 if (aItem.value.resetValue() != bItem.resetValue())
221 return false;
222 }
223
224 return true;
225 }
226
227 bool CSSPropertyEqualityCustom::CSSPropertyBorderImageSliceEqual(const ComputedS tyle& a, const ComputedStyle& b)
228 {
229 return a.borderImageSlices() == b.borderImageSlices();
230 }
231
232 bool CSSPropertyEqualityCustom::CSSPropertyTextIndentEqual(const ComputedStyle& a, const ComputedStyle& b)
233 {
234 return a.textIndent() == b.textIndent();
235 }
236
237 bool CSSPropertyEqualityCustom::CSSPropertyBorderImageOutsetEqual(const Computed Style& a, const ComputedStyle& b)
238 {
239 return a.borderImageOutset() == b.borderImageOutset();
240 }
241
242 bool CSSPropertyEqualityCustom::CSSPropertyBorderImageRepeatEqual(const Computed Style& a, const ComputedStyle& b)
243 {
244 return a.borderImage().horizontalRule() == b.borderImage().horizontalRule()
245 && a.borderImage().verticalRule() == b.borderImage().verticalRule();
246 }
247
248 bool CSSPropertyEqualityCustom::CSSPropertyColumnRuleColorEqual(const ComputedSt yle& a, const ComputedStyle& b)
249 {
250 return a.columnRuleColor() == b.columnRuleColor()
251 && a.visitedLinkColumnRuleColor() == b.visitedLinkColumnRuleColor();
252 }
253
254 bool CSSPropertyEqualityCustom::CSSPropertyGridTemplateColumnsEqual(const Comput edStyle& a, const ComputedStyle& b)
255 {
256 return a.gridTemplateColumns() == b.gridTemplateColumns();
257 }
258
259 bool CSSPropertyEqualityCustom::CSSPropertyColumnGapEqual(const ComputedStyle& a , const ComputedStyle& b)
260 {
261 return a.columnGap() == b.columnGap();
262 }
263
264 bool CSSPropertyEqualityCustom::CSSPropertyMaskSourceTypeEqual(const ComputedSty le& a, const ComputedStyle& b)
265 {
266 return fillLayersEqual<CSSPropertyMaskSourceType>(a.maskLayers(), b.maskLaye rs());
267 }
268
269 bool CSSPropertyEqualityCustom::CSSPropertySnapHeightEqual(const ComputedStyle& a, const ComputedStyle& b)
270 {
271 return a.snapHeightPosition() == b.snapHeightPosition() && a.snapHeightUnit( ) == b.snapHeightUnit();
272 }
273
274 bool CSSPropertyEqualityCustom::CSSPropertyBackgroundRepeatYEqual(const Computed Style& a, const ComputedStyle& b)
275 {
276 return fillLayersEqual<CSSPropertyBackgroundRepeatY>(a.backgroundLayers(), b .backgroundLayers());
277 }
278
279 bool CSSPropertyEqualityCustom::CSSPropertyWebkitAppRegionEqual(const ComputedSt yle& a, const ComputedStyle& b)
280 {
281 return a.getDraggableRegionMode() == b.getDraggableRegionMode();
282 }
283
284 bool CSSPropertyEqualityCustom::CSSPropertyWebkitTextFillColorEqual(const Comput edStyle& a, const ComputedStyle& b)
285 {
286 return a.textFillColor() == b.textFillColor()
287 && a.visitedLinkTextFillColor() == b.visitedLinkTextFillColor();
288 }
289
290 bool CSSPropertyEqualityCustom::CSSPropertyBackgroundClipEqual(const ComputedSty le& a, const ComputedStyle& b)
291 {
292 return fillLayersEqual<CSSPropertyBackgroundClip>(a.backgroundLayers(), b.ba ckgroundLayers());
293 }
294
295 bool CSSPropertyEqualityCustom::CSSPropertyOutlineStyleEqual(const ComputedStyle & a, const ComputedStyle& b)
296 {
297 return a.outlineStyleIsAuto() == b.outlineStyleIsAuto()
298 && a.outlineStyle() == b.outlineStyle();
299 }
300
301 bool CSSPropertyEqualityCustom::CSSPropertyBorderRightColorEqual(const ComputedS tyle& a, const ComputedStyle& b)
302 {
303 return a.borderRightColor() == b.borderRightColor()
304 && a.visitedLinkBorderRightColor() == b.visitedLinkBorderRightColor();
305 }
306
307 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskSizeEqual(const ComputedSty le& a, const ComputedStyle& b)
308 {
309 return fillLayersEqual<CSSPropertyWebkitMaskSize>(a.maskLayers(), b.maskLaye rs());
310 }
311
312 bool CSSPropertyEqualityCustom::CSSPropertyBorderImageWidthEqual(const ComputedS tyle& a, const ComputedStyle& b)
313 {
314 return a.borderImageWidth() == b.borderImageWidth();
315 }
316
317 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskImageEqual(const ComputedSt yle& a, const ComputedStyle& b)
318 {
319 return dataEquivalent(a.maskImage(), b.maskImage());
320 }
321
322 bool CSSPropertyEqualityCustom::CSSPropertyGridTemplateAreasEqual(const Computed Style& a, const ComputedStyle& b)
323 {
324 return a.namedGridArea() == b.namedGridArea()
325 && a.namedGridAreaRowCount() == b.namedGridAreaRowCount()
326 && b.namedGridAreaColumnCount() == b.namedGridAreaColumnCount();
327 }
328
329 bool CSSPropertyEqualityCustom::CSSPropertyBackgroundSizeEqual(const ComputedSty le& a, const ComputedStyle& b)
330 {
331 return fillLayersEqual<CSSPropertyBackgroundSize>(a.backgroundLayers(), b.ba ckgroundLayers());
332 }
333
334 bool CSSPropertyEqualityCustom::CSSPropertyClipEqual(const ComputedStyle& a, con st ComputedStyle& b)
335 {
336 return a.clip() == b.clip();
337 }
338
339 bool CSSPropertyEqualityCustom::CSSPropertyColorEqual(const ComputedStyle& a, co nst ComputedStyle& b)
340 {
341 return a.color() == b.color()
342 && a.visitedLinkColor() == b.visitedLinkColor();
343 }
344
345 bool CSSPropertyEqualityCustom::CSSPropertyBorderLeftColorEqual(const ComputedSt yle& a, const ComputedStyle& b)
346 {
347 return a.borderLeftColor() == b.borderLeftColor()
348 && a.visitedLinkBorderLeftColor() == b.visitedLinkBorderLeftColor();
349 }
350
351 bool CSSPropertyEqualityCustom::CSSPropertyStrokeEqual(const ComputedStyle& a, c onst ComputedStyle& b)
352 {
353 const SVGComputedStyle& aSVG = a.svgStyle();
354 const SVGComputedStyle& bSVG = b.svgStyle();
355 return aSVG.strokePaintType() == bSVG.strokePaintType()
356 && (aSVG.strokePaintType() != SVG_PAINTTYPE_RGBCOLOR || aSVG.strokePaint Color() == bSVG.strokePaintColor())
357 && aSVG.visitedLinkStrokePaintType() == bSVG.visitedLinkStrokePaintType( )
358 && (aSVG.visitedLinkStrokePaintType() != SVG_PAINTTYPE_RGBCOLOR || aSVG. visitedLinkStrokePaintColor() == bSVG.visitedLinkStrokePaintColor());
359 }
360
361 bool CSSPropertyEqualityCustom::CSSPropertyWillChangeEqual(const ComputedStyle& a, const ComputedStyle& b)
362 {
363 return a.willChangeProperties() == b.willChangeProperties();
364 }
365
366 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskBoxImageSliceEqual(const Co mputedStyle& a, const ComputedStyle& b)
367 {
368 return a.maskBoxImageSlices() == b.maskBoxImageSlices();
369 }
370
371 bool CSSPropertyEqualityCustom::CSSPropertyBackgroundPositionYEqual(const Comput edStyle& a, const ComputedStyle& b)
372 {
373 return fillLayersEqual<CSSPropertyBackgroundPositionY>(a.backgroundLayers(), b.backgroundLayers());
374 }
375
376 bool CSSPropertyEqualityCustom::CSSPropertyBackgroundPositionXEqual(const Comput edStyle& a, const ComputedStyle& b)
377 {
378 return fillLayersEqual<CSSPropertyBackgroundPositionX>(a.backgroundLayers(), b.backgroundLayers());
379 }
380
381 bool CSSPropertyEqualityCustom::CSSPropertyBackgroundOriginEqual(const ComputedS tyle& a, const ComputedStyle& b)
382 {
383 return fillLayersEqual<CSSPropertyBackgroundOrigin>(a.backgroundLayers(), b. backgroundLayers());
384 }
385
386 bool CSSPropertyEqualityCustom::CSSPropertyColumnWidthEqual(const ComputedStyle& a, const ComputedStyle& b)
387 {
388 return a.columnWidth() == b.columnWidth();
389 }
390
391 bool CSSPropertyEqualityCustom::CSSPropertyCursorEqual(const ComputedStyle& a, c onst ComputedStyle& b)
392 {
393 return a.cursor() == b.cursor()
394 && (a.cursors() == b.cursors() || (a.cursors() && b.cursors() && *a.curs ors() == *b.cursors()));
395 }
396
397 bool CSSPropertyEqualityCustom::CSSPropertyCounterIncrementEqual(const ComputedS tyle& a, const ComputedStyle& b)
398 {
399 const CounterDirectiveMap* aMap = a.counterDirectives();
400 const CounterDirectiveMap* bMap = b.counterDirectives();
401
402 if (!aMap || !bMap)
403 return true;
404
405 if (!aMap) {
406 aMap = bMap;
407 bMap = nullptr;
408 }
409
410 for (const auto& aItem : *aMap) {
411 if (!aItem.value.isIncrement())
412 continue;
413
414 if (!bMap)
415 return false;
416
417 if (!bMap->contains(aItem.key))
418 return false;
419
420 const auto& bItem = bMap->get(aItem.key);
421 if (aItem.value.incrementValue() != bItem.incrementValue())
422 return false;
423 }
424
425 return true;
426 }
427
428 bool CSSPropertyEqualityCustom::CSSPropertyBackgroundBlendModeEqual(const Comput edStyle& a, const ComputedStyle& b)
429 {
430 return fillLayersEqual<CSSPropertyBackgroundBlendMode>(a.backgroundLayers(), b.backgroundLayers());
431 }
432
433 bool CSSPropertyEqualityCustom::CSSPropertyBackgroundRepeatXEqual(const Computed Style& a, const ComputedStyle& b)
434 {
435 return fillLayersEqual<CSSPropertyBackgroundRepeatX>(a.backgroundLayers(), b .backgroundLayers());
436 }
437
438 bool CSSPropertyEqualityCustom::CSSPropertyBorderTopColorEqual(const ComputedSty le& a, const ComputedStyle& b)
439 {
440 return a.borderTopColor() == b.borderTopColor()
441 && a.visitedLinkBorderTopColor() == b.visitedLinkBorderTopColor();
442 }
443
444 bool CSSPropertyEqualityCustom::CSSPropertyBackgroundColorEqual(const ComputedSt yle& a, const ComputedStyle& b)
445 {
446 return a.backgroundColor() == b.backgroundColor()
447 && a.visitedLinkBackgroundColor() == b.visitedLinkBackgroundColor();
448 }
449
450 bool CSSPropertyEqualityCustom::CSSPropertyWebkitTextEmphasisColorEqual(const Co mputedStyle& a, const ComputedStyle& b)
451 {
452 return a.textEmphasisColor() == b.textEmphasisColor()
453 && a.visitedLinkTextEmphasisColor() == b.visitedLinkTextEmphasisColor();
454 }
455
456 bool CSSPropertyEqualityCustom::CSSPropertyZIndexEqual(const ComputedStyle& a, c onst ComputedStyle& b)
457 {
458 return a.hasAutoZIndex() == b.hasAutoZIndex() && (a.hasAutoZIndex() || a.zIn dex() == b.zIndex());
459 }
460
461 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskRepeatYEqual(const Computed Style& a, const ComputedStyle& b)
462 {
463 return fillLayersEqual<CSSPropertyWebkitMaskRepeatY>(a.maskLayers(), b.maskL ayers());
464 }
465
466 bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskRepeatXEqual(const Computed Style& a, const ComputedStyle& b)
467 {
468 return fillLayersEqual<CSSPropertyWebkitMaskRepeatX>(a.maskLayers(), b.maskL ayers());
469 }
470
471 bool CSSPropertyEqualityCustom::CSSPropertyBorderBottomColorEqual(const Computed Style& a, const ComputedStyle& b)
472 {
473 return a.borderBottomColor() == b.borderBottomColor()
474 && a.visitedLinkBorderBottomColor() == b.visitedLinkBorderBottomColor();
475 }
476
477 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698