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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/CSSPropertyEqualityCustom.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSPropertyEqualityCustom.cpp b/third_party/WebKit/Source/core/css/CSSPropertyEqualityCustom.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..60829b0a152f71a435b074b8fa2861cae9eae462
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/CSSPropertyEqualityCustom.cpp
@@ -0,0 +1,477 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/CSSPropertyEqualityCustom.h"
+
+#include "core/CSSPropertyNames.h"
+#include "core/css/CSSPropertyEquality.h"
+#include "core/style/ComputedStyle.h"
+#include "core/style/DataEquivalency.h"
+#include "core/style/FillLayer.h"
+
+namespace blink {
+
+namespace {
+
+template <CSSPropertyID property>
+bool fillLayersEqual(const FillLayer& aLayers, const FillLayer& bLayers)
+{
+ const FillLayer* aLayer = &aLayers;
+ const FillLayer* bLayer = &bLayers;
+ while (aLayer && bLayer) {
+ switch (property) {
Timothy Loh 2016/05/24 05:38:35 Maybe it's nicer to pass a getter as the template
+ case CSSPropertyBackgroundPositionX:
+ case CSSPropertyWebkitMaskPositionX:
+ if (aLayer->xPosition() != bLayer->xPosition())
+ return false;
+ break;
+ case CSSPropertyBackgroundPositionY:
+ case CSSPropertyWebkitMaskPositionY:
+ if (aLayer->yPosition() != bLayer->yPosition())
+ return false;
+ break;
+ case CSSPropertyBackgroundSize:
+ case CSSPropertyWebkitMaskSize:
+ if (!(aLayer->sizeLength() == bLayer->sizeLength()))
+ return false;
+ break;
+ case CSSPropertyBackgroundImage:
+ if (!dataEquivalent(aLayer->image(), bLayer->image()))
+ return false;
+ break;
Timothy Loh 2016/05/24 04:38:20 missing breaks on subsequent cases
+ case CSSPropertyWebkitMaskComposite:
+ if (aLayer->composite() != bLayer->composite())
+ return false;
+ case CSSPropertyBackgroundOrigin:
+ case CSSPropertyWebkitMaskOrigin:
+ if (aLayer->origin() != bLayer->origin())
+ return false;
+ case CSSPropertyBackgroundBlendMode:
+ if (aLayer->blendMode() != bLayer->blendMode())
+ return false;
+ case CSSPropertyBackgroundAttachment:
+ if (aLayer->attachment() != bLayer->attachment())
+ return false;
+ case CSSPropertyBackgroundRepeatX:
+ case CSSPropertyWebkitMaskRepeatX:
+ if (aLayer->repeatX() != bLayer->repeatX())
+ return false;
+ case CSSPropertyBackgroundRepeatY:
+ case CSSPropertyWebkitMaskRepeatY:
+ if (aLayer->repeatY() != bLayer->repeatY())
+ return false;
+ case CSSPropertyBackgroundClip:
+ case CSSPropertyWebkitMaskClip:
+ if (aLayer->clip() != bLayer->clip())
+ return false;
+ case CSSPropertyMaskSourceType:
+ if (aLayer->maskSourceType() != bLayer->maskSourceType())
+ return false;
+ default:
+ NOTREACHED();
+ return true;
+ }
+
+ aLayer = aLayer->next();
+ bLayer = bLayer->next();
+ }
+
+ // FIXME: Shouldn't this be return !aLayer && !bLayer; ?
+ return true;
+}
+
+} // namespace
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskBoxImageWidthEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.maskBoxImageWidth() == b.maskBoxImageWidth();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertySizeEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.pageSize() == b.pageSize() && a.getPageSizeType() == b.getPageSizeType();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyTextDecorationColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.textDecorationColor() == b.textDecorationColor()
+ && a.visitedLinkTextDecorationColor() == b.visitedLinkTextDecorationColor();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskCompositeEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyWebkitMaskComposite>(a.maskLayers(), b.maskLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskPositionYEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyWebkitMaskPositionY>(a.maskLayers(), b.maskLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskPositionXEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyWebkitMaskPositionX>(a.maskLayers(), b.maskLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyContentEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.contentDataEquivalent(&b);
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyOutlineColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.outlineColor() == b.outlineColor()
+ && a.visitedLinkOutlineColor() == b.visitedLinkOutlineColor();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitTextEmphasisStyleEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return CSSPropertyEquality::propertiesEqual(CSSPropertyWebkitTextEmphasisColor, a, b)
+ && CSSPropertyEquality::propertiesEqual(CSSPropertyWebkitTextEmphasisStyle, a, b);
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitTextStrokeColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.textStrokeColor() == b.textStrokeColor()
+ && a.visitedLinkTextStrokeColor() == b.visitedLinkTextStrokeColor();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskBoxImageOutsetEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.maskBoxImageOutset() == b.maskBoxImageOutset();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyColumnCountEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.columnCount() == b.columnCount();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyGridTemplateRowsEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.gridTemplateRows() == b.gridTemplateRows();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskOriginEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyWebkitMaskOrigin>(a.maskLayers(), b.maskLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyFillEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ const SVGComputedStyle& aSVG = a.svgStyle();
+ const SVGComputedStyle& bSVG = b.svgStyle();
+ return aSVG.fillPaintType() == bSVG.fillPaintType()
+ && (aSVG.fillPaintType() != SVG_PAINTTYPE_RGBCOLOR || aSVG.fillPaintColor() == bSVG.fillPaintColor())
+ && aSVG.visitedLinkFillPaintType() == bSVG.visitedLinkFillPaintType()
+ && (aSVG.visitedLinkFillPaintType() != SVG_PAINTTYPE_RGBCOLOR || aSVG.visitedLinkFillPaintColor() == bSVG.visitedLinkFillPaintColor());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyZoomEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.zoom() == b.zoom();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskBoxImageRepeatEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.maskBoxImage().horizontalRule() == b.maskBoxImage().horizontalRule()
+ && a.maskBoxImage().verticalRule() == b.maskBoxImage().verticalRule();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBackgroundAttachmentEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyBackgroundAttachment>(a.backgroundLayers(), b.backgroundLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBackgroundImageEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyBackgroundImage>(a.backgroundLayers(), b.backgroundLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskClipEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyWebkitMaskClip>(a.maskLayers(), b.maskLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyCounterResetEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ const CounterDirectiveMap* aMap = a.counterDirectives();
+ const CounterDirectiveMap* bMap = b.counterDirectives();
+
+ if (!aMap || !bMap)
+ return true;
+
+ if (!aMap) {
+ aMap = bMap;
+ bMap = nullptr;
+ }
+
+ for (const auto& aItem : *aMap) {
+ if (!aItem.value.isReset())
+ continue;
+
+ if (!bMap)
+ return false;
+
+ if (!bMap->contains(aItem.key))
+ return false;
+
+ const auto& bItem = bMap->get(aItem.key);
+ if (aItem.value.resetValue() != bItem.resetValue())
+ return false;
+ }
+
+ return true;
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBorderImageSliceEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.borderImageSlices() == b.borderImageSlices();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyTextIndentEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.textIndent() == b.textIndent();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBorderImageOutsetEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.borderImageOutset() == b.borderImageOutset();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBorderImageRepeatEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.borderImage().horizontalRule() == b.borderImage().horizontalRule()
+ && a.borderImage().verticalRule() == b.borderImage().verticalRule();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyColumnRuleColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.columnRuleColor() == b.columnRuleColor()
+ && a.visitedLinkColumnRuleColor() == b.visitedLinkColumnRuleColor();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyGridTemplateColumnsEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.gridTemplateColumns() == b.gridTemplateColumns();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyColumnGapEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.columnGap() == b.columnGap();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyMaskSourceTypeEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyMaskSourceType>(a.maskLayers(), b.maskLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertySnapHeightEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.snapHeightPosition() == b.snapHeightPosition() && a.snapHeightUnit() == b.snapHeightUnit();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBackgroundRepeatYEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyBackgroundRepeatY>(a.backgroundLayers(), b.backgroundLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitAppRegionEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.getDraggableRegionMode() == b.getDraggableRegionMode();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitTextFillColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.textFillColor() == b.textFillColor()
+ && a.visitedLinkTextFillColor() == b.visitedLinkTextFillColor();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBackgroundClipEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyBackgroundClip>(a.backgroundLayers(), b.backgroundLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyOutlineStyleEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.outlineStyleIsAuto() == b.outlineStyleIsAuto()
+ && a.outlineStyle() == b.outlineStyle();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBorderRightColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.borderRightColor() == b.borderRightColor()
+ && a.visitedLinkBorderRightColor() == b.visitedLinkBorderRightColor();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskSizeEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyWebkitMaskSize>(a.maskLayers(), b.maskLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBorderImageWidthEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.borderImageWidth() == b.borderImageWidth();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskImageEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return dataEquivalent(a.maskImage(), b.maskImage());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyGridTemplateAreasEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.namedGridArea() == b.namedGridArea()
+ && a.namedGridAreaRowCount() == b.namedGridAreaRowCount()
+ && b.namedGridAreaColumnCount() == b.namedGridAreaColumnCount();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBackgroundSizeEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyBackgroundSize>(a.backgroundLayers(), b.backgroundLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyClipEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.clip() == b.clip();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.color() == b.color()
+ && a.visitedLinkColor() == b.visitedLinkColor();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBorderLeftColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.borderLeftColor() == b.borderLeftColor()
+ && a.visitedLinkBorderLeftColor() == b.visitedLinkBorderLeftColor();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyStrokeEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ const SVGComputedStyle& aSVG = a.svgStyle();
+ const SVGComputedStyle& bSVG = b.svgStyle();
+ return aSVG.strokePaintType() == bSVG.strokePaintType()
+ && (aSVG.strokePaintType() != SVG_PAINTTYPE_RGBCOLOR || aSVG.strokePaintColor() == bSVG.strokePaintColor())
+ && aSVG.visitedLinkStrokePaintType() == bSVG.visitedLinkStrokePaintType()
+ && (aSVG.visitedLinkStrokePaintType() != SVG_PAINTTYPE_RGBCOLOR || aSVG.visitedLinkStrokePaintColor() == bSVG.visitedLinkStrokePaintColor());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWillChangeEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.willChangeProperties() == b.willChangeProperties();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskBoxImageSliceEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.maskBoxImageSlices() == b.maskBoxImageSlices();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBackgroundPositionYEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyBackgroundPositionY>(a.backgroundLayers(), b.backgroundLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBackgroundPositionXEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyBackgroundPositionX>(a.backgroundLayers(), b.backgroundLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBackgroundOriginEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyBackgroundOrigin>(a.backgroundLayers(), b.backgroundLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyColumnWidthEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.columnWidth() == b.columnWidth();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyCursorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.cursor() == b.cursor()
+ && (a.cursors() == b.cursors() || (a.cursors() && b.cursors() && *a.cursors() == *b.cursors()));
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyCounterIncrementEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ const CounterDirectiveMap* aMap = a.counterDirectives();
+ const CounterDirectiveMap* bMap = b.counterDirectives();
+
+ if (!aMap || !bMap)
+ return true;
+
+ if (!aMap) {
+ aMap = bMap;
+ bMap = nullptr;
+ }
+
+ for (const auto& aItem : *aMap) {
+ if (!aItem.value.isIncrement())
+ continue;
+
+ if (!bMap)
+ return false;
+
+ if (!bMap->contains(aItem.key))
+ return false;
+
+ const auto& bItem = bMap->get(aItem.key);
+ if (aItem.value.incrementValue() != bItem.incrementValue())
+ return false;
+ }
+
+ return true;
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBackgroundBlendModeEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyBackgroundBlendMode>(a.backgroundLayers(), b.backgroundLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBackgroundRepeatXEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyBackgroundRepeatX>(a.backgroundLayers(), b.backgroundLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBorderTopColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.borderTopColor() == b.borderTopColor()
+ && a.visitedLinkBorderTopColor() == b.visitedLinkBorderTopColor();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBackgroundColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.backgroundColor() == b.backgroundColor()
+ && a.visitedLinkBackgroundColor() == b.visitedLinkBackgroundColor();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitTextEmphasisColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.textEmphasisColor() == b.textEmphasisColor()
+ && a.visitedLinkTextEmphasisColor() == b.visitedLinkTextEmphasisColor();
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyZIndexEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.hasAutoZIndex() == b.hasAutoZIndex() && (a.hasAutoZIndex() || a.zIndex() == b.zIndex());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskRepeatYEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyWebkitMaskRepeatY>(a.maskLayers(), b.maskLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyWebkitMaskRepeatXEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return fillLayersEqual<CSSPropertyWebkitMaskRepeatX>(a.maskLayers(), b.maskLayers());
+}
+
+bool CSSPropertyEqualityCustom::CSSPropertyBorderBottomColorEqual(const ComputedStyle& a, const ComputedStyle& b)
+{
+ return a.borderBottomColor() == b.borderBottomColor()
+ && a.visitedLinkBorderBottomColor() == b.visitedLinkBorderBottomColor();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698