| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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/animation/css/CSSPropertyEquality.h" | |
| 6 | |
| 7 #include "core/animation/css/CSSAnimations.h" | |
| 8 #include "core/style/DataEquivalency.h" | |
| 9 #include "core/style/ComputedStyle.h" | |
| 10 #include "core/style/ShadowList.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 template <CSSPropertyID property> | |
| 17 bool fillLayersEqual(const FillLayer& aLayers, const FillLayer& bLayers) | |
| 18 { | |
| 19 const FillLayer* aLayer = &aLayers; | |
| 20 const FillLayer* bLayer = &bLayers; | |
| 21 while (aLayer && bLayer) { | |
| 22 switch (property) { | |
| 23 case CSSPropertyBackgroundPositionX: | |
| 24 case CSSPropertyWebkitMaskPositionX: | |
| 25 if (aLayer->xPosition() != bLayer->xPosition()) | |
| 26 return false; | |
| 27 break; | |
| 28 case CSSPropertyBackgroundPositionY: | |
| 29 case CSSPropertyWebkitMaskPositionY: | |
| 30 if (aLayer->yPosition() != bLayer->yPosition()) | |
| 31 return false; | |
| 32 break; | |
| 33 case CSSPropertyBackgroundSize: | |
| 34 case CSSPropertyWebkitMaskSize: | |
| 35 if (!(aLayer->sizeLength() == bLayer->sizeLength())) | |
| 36 return false; | |
| 37 break; | |
| 38 case CSSPropertyBackgroundImage: | |
| 39 if (!dataEquivalent(aLayer->image(), bLayer->image())) | |
| 40 return false; | |
| 41 break; | |
| 42 default: | |
| 43 ASSERT_NOT_REACHED(); | |
| 44 return true; | |
| 45 } | |
| 46 | |
| 47 aLayer = aLayer->next(); | |
| 48 bLayer = bLayer->next(); | |
| 49 } | |
| 50 | |
| 51 // FIXME: Shouldn't this be return !aLayer && !bLayer; ? | |
| 52 return true; | |
| 53 } | |
| 54 | |
| 55 } // namespace | |
| 56 | |
| 57 bool CSSPropertyEquality::propertiesEqual(CSSPropertyID prop, const ComputedStyl
e& a, const ComputedStyle& b) | |
| 58 { | |
| 59 switch (prop) { | |
| 60 case CSSPropertyBackgroundColor: | |
| 61 return a.backgroundColor() == b.backgroundColor() | |
| 62 && a.visitedLinkBackgroundColor() == b.visitedLinkBackgroundColor(); | |
| 63 case CSSPropertyBackgroundImage: | |
| 64 return fillLayersEqual<CSSPropertyBackgroundImage>(a.backgroundLayers(),
b.backgroundLayers()); | |
| 65 case CSSPropertyBackgroundPositionX: | |
| 66 return fillLayersEqual<CSSPropertyBackgroundPositionX>(a.backgroundLayer
s(), b.backgroundLayers()); | |
| 67 case CSSPropertyBackgroundPositionY: | |
| 68 return fillLayersEqual<CSSPropertyBackgroundPositionY>(a.backgroundLayer
s(), b.backgroundLayers()); | |
| 69 case CSSPropertyBackgroundSize: | |
| 70 return fillLayersEqual<CSSPropertyBackgroundSize>(a.backgroundLayers(),
b.backgroundLayers()); | |
| 71 case CSSPropertyBaselineShift: | |
| 72 return a.baselineShiftValue() == b.baselineShiftValue(); | |
| 73 case CSSPropertyBorderBottomColor: | |
| 74 return a.borderBottomColor() == b.borderBottomColor() | |
| 75 && a.visitedLinkBorderBottomColor() == b.visitedLinkBorderBottomColo
r(); | |
| 76 case CSSPropertyBorderBottomLeftRadius: | |
| 77 return a.borderBottomLeftRadius() == b.borderBottomLeftRadius(); | |
| 78 case CSSPropertyBorderBottomRightRadius: | |
| 79 return a.borderBottomRightRadius() == b.borderBottomRightRadius(); | |
| 80 case CSSPropertyBorderBottomWidth: | |
| 81 return a.borderBottomWidth() == b.borderBottomWidth(); | |
| 82 case CSSPropertyBorderImageOutset: | |
| 83 return a.borderImageOutset() == b.borderImageOutset(); | |
| 84 case CSSPropertyBorderImageSlice: | |
| 85 return a.borderImageSlices() == b.borderImageSlices(); | |
| 86 case CSSPropertyBorderImageSource: | |
| 87 return dataEquivalent(a.borderImageSource(), b.borderImageSource()); | |
| 88 case CSSPropertyBorderImageWidth: | |
| 89 return a.borderImageWidth() == b.borderImageWidth(); | |
| 90 case CSSPropertyBorderLeftColor: | |
| 91 return a.borderLeftColor() == b.borderLeftColor() | |
| 92 && a.visitedLinkBorderLeftColor() == b.visitedLinkBorderLeftColor(); | |
| 93 case CSSPropertyBorderLeftWidth: | |
| 94 return a.borderLeftWidth() == b.borderLeftWidth(); | |
| 95 case CSSPropertyBorderRightColor: | |
| 96 return a.borderRightColor() == b.borderRightColor() | |
| 97 && a.visitedLinkBorderRightColor() == b.visitedLinkBorderRightColor(
); | |
| 98 case CSSPropertyBorderRightWidth: | |
| 99 return a.borderRightWidth() == b.borderRightWidth(); | |
| 100 case CSSPropertyBorderTopColor: | |
| 101 return a.borderTopColor() == b.borderTopColor() | |
| 102 && a.visitedLinkBorderTopColor() == b.visitedLinkBorderTopColor(); | |
| 103 case CSSPropertyBorderTopLeftRadius: | |
| 104 return a.borderTopLeftRadius() == b.borderTopLeftRadius(); | |
| 105 case CSSPropertyBorderTopRightRadius: | |
| 106 return a.borderTopRightRadius() == b.borderTopRightRadius(); | |
| 107 case CSSPropertyBorderTopWidth: | |
| 108 return a.borderTopWidth() == b.borderTopWidth(); | |
| 109 case CSSPropertyBottom: | |
| 110 return a.bottom() == b.bottom(); | |
| 111 case CSSPropertyBoxShadow: | |
| 112 return dataEquivalent(a.boxShadow(), b.boxShadow()); | |
| 113 case CSSPropertyClip: | |
| 114 return a.clip() == b.clip(); | |
| 115 case CSSPropertyColor: | |
| 116 return a.color() == b.color() && a.visitedLinkColor() == b.visitedLinkCo
lor(); | |
| 117 case CSSPropertyFill: { | |
| 118 const SVGComputedStyle& aSVG = a.svgStyle(); | |
| 119 const SVGComputedStyle& bSVG = b.svgStyle(); | |
| 120 return aSVG.fillPaintType() == bSVG.fillPaintType() | |
| 121 && (aSVG.fillPaintType() != SVG_PAINTTYPE_RGBCOLOR || aSVG.fillPaint
Color() == bSVG.fillPaintColor()) | |
| 122 && aSVG.visitedLinkFillPaintType() == bSVG.visitedLinkFillPaintType(
) | |
| 123 && (aSVG.visitedLinkFillPaintType() != SVG_PAINTTYPE_RGBCOLOR || aSV
G.visitedLinkFillPaintColor() == bSVG.visitedLinkFillPaintColor()); | |
| 124 } | |
| 125 case CSSPropertyFillOpacity: | |
| 126 return a.fillOpacity() == b.fillOpacity(); | |
| 127 case CSSPropertyFlexBasis: | |
| 128 return a.flexBasis() == b.flexBasis(); | |
| 129 case CSSPropertyFlexGrow: | |
| 130 return a.flexGrow() == b.flexGrow(); | |
| 131 case CSSPropertyFlexShrink: | |
| 132 return a.flexShrink() == b.flexShrink(); | |
| 133 case CSSPropertyFloodColor: | |
| 134 return a.floodColor() == b.floodColor(); | |
| 135 case CSSPropertyFloodOpacity: | |
| 136 return a.floodOpacity() == b.floodOpacity(); | |
| 137 case CSSPropertyFontSize: | |
| 138 // CSSPropertyFontSize: Must pass a specified size to setFontSize if Tex
t Autosizing is enabled, but a computed size | |
| 139 // if text zoom is enabled (if neither is enabled it's irrelevant as the
y're probably the same). | |
| 140 // FIXME: Should we introduce an option to pass the computed font size h
ere, allowing consumers to | |
| 141 // enable text zoom rather than Text Autosizing? See http://crbug.com/22
7545. | |
| 142 return a.specifiedFontSize() == b.specifiedFontSize(); | |
| 143 case CSSPropertyFontSizeAdjust: | |
| 144 return a.fontSizeAdjust() == b.fontSizeAdjust(); | |
| 145 case CSSPropertyFontStretch: | |
| 146 return a.fontStretch() == b.fontStretch(); | |
| 147 case CSSPropertyFontWeight: | |
| 148 return a.fontWeight() == b.fontWeight(); | |
| 149 case CSSPropertyHeight: | |
| 150 return a.height() == b.height(); | |
| 151 case CSSPropertyLeft: | |
| 152 return a.left() == b.left(); | |
| 153 case CSSPropertyLetterSpacing: | |
| 154 return a.letterSpacing() == b.letterSpacing(); | |
| 155 case CSSPropertyLightingColor: | |
| 156 return a.lightingColor() == b.lightingColor(); | |
| 157 case CSSPropertyLineHeight: | |
| 158 return a.specifiedLineHeight() == b.specifiedLineHeight(); | |
| 159 case CSSPropertyListStyleImage: | |
| 160 return dataEquivalent(a.listStyleImage(), b.listStyleImage()); | |
| 161 case CSSPropertyMarginBottom: | |
| 162 return a.marginBottom() == b.marginBottom(); | |
| 163 case CSSPropertyMarginLeft: | |
| 164 return a.marginLeft() == b.marginLeft(); | |
| 165 case CSSPropertyMarginRight: | |
| 166 return a.marginRight() == b.marginRight(); | |
| 167 case CSSPropertyMarginTop: | |
| 168 return a.marginTop() == b.marginTop(); | |
| 169 case CSSPropertyMaxHeight: | |
| 170 return a.maxHeight() == b.maxHeight(); | |
| 171 case CSSPropertyMaxWidth: | |
| 172 return a.maxWidth() == b.maxWidth(); | |
| 173 case CSSPropertyMinHeight: | |
| 174 return a.minHeight() == b.minHeight(); | |
| 175 case CSSPropertyMinWidth: | |
| 176 return a.minWidth() == b.minWidth(); | |
| 177 case CSSPropertyMotionOffset: | |
| 178 return a.motionOffset() == b.motionOffset(); | |
| 179 case CSSPropertyMotionRotation: | |
| 180 return a.motionRotation() == b.motionRotation(); | |
| 181 case CSSPropertyObjectPosition: | |
| 182 return a.objectPosition() == b.objectPosition(); | |
| 183 case CSSPropertyOpacity: | |
| 184 return a.opacity() == b.opacity(); | |
| 185 case CSSPropertyOrphans: | |
| 186 return a.orphans() == b.orphans(); | |
| 187 case CSSPropertyOutlineColor: | |
| 188 return a.outlineColor() == b.outlineColor() | |
| 189 && a.visitedLinkOutlineColor() == b.visitedLinkOutlineColor(); | |
| 190 case CSSPropertyOutlineOffset: | |
| 191 return a.outlineOffset() == b.outlineOffset(); | |
| 192 case CSSPropertyOutlineWidth: | |
| 193 return a.outlineWidth() == b.outlineWidth(); | |
| 194 case CSSPropertyPaddingBottom: | |
| 195 return a.paddingBottom() == b.paddingBottom(); | |
| 196 case CSSPropertyPaddingLeft: | |
| 197 return a.paddingLeft() == b.paddingLeft(); | |
| 198 case CSSPropertyPaddingRight: | |
| 199 return a.paddingRight() == b.paddingRight(); | |
| 200 case CSSPropertyPaddingTop: | |
| 201 return a.paddingTop() == b.paddingTop(); | |
| 202 case CSSPropertyRight: | |
| 203 return a.right() == b.right(); | |
| 204 case CSSPropertyShapeImageThreshold: | |
| 205 return a.shapeImageThreshold() == b.shapeImageThreshold(); | |
| 206 case CSSPropertyShapeMargin: | |
| 207 return a.shapeMargin() == b.shapeMargin(); | |
| 208 case CSSPropertyShapeOutside: | |
| 209 return dataEquivalent(a.shapeOutside(), b.shapeOutside()); | |
| 210 case CSSPropertyStopColor: | |
| 211 return a.stopColor() == b.stopColor(); | |
| 212 case CSSPropertyStopOpacity: | |
| 213 return a.stopOpacity() == b.stopOpacity(); | |
| 214 case CSSPropertyStroke: { | |
| 215 const SVGComputedStyle& aSVG = a.svgStyle(); | |
| 216 const SVGComputedStyle& bSVG = b.svgStyle(); | |
| 217 return aSVG.strokePaintType() == bSVG.strokePaintType() | |
| 218 && (aSVG.strokePaintType() != SVG_PAINTTYPE_RGBCOLOR || aSVG.strokeP
aintColor() == bSVG.strokePaintColor()) | |
| 219 && aSVG.visitedLinkStrokePaintType() == bSVG.visitedLinkStrokePaintT
ype() | |
| 220 && (aSVG.visitedLinkStrokePaintType() != SVG_PAINTTYPE_RGBCOLOR || a
SVG.visitedLinkStrokePaintColor() == bSVG.visitedLinkStrokePaintColor()); | |
| 221 } | |
| 222 case CSSPropertyStrokeDasharray: | |
| 223 return a.strokeDashArray() == b.strokeDashArray(); | |
| 224 case CSSPropertyStrokeDashoffset: | |
| 225 return a.strokeDashOffset() == b.strokeDashOffset(); | |
| 226 case CSSPropertyStrokeMiterlimit: | |
| 227 return a.strokeMiterLimit() == b.strokeMiterLimit(); | |
| 228 case CSSPropertyStrokeOpacity: | |
| 229 return a.strokeOpacity() == b.strokeOpacity(); | |
| 230 case CSSPropertyStrokeWidth: | |
| 231 return a.strokeWidth() == b.strokeWidth(); | |
| 232 case CSSPropertyTextDecorationColor: | |
| 233 return a.textDecorationColor() == b.textDecorationColor() | |
| 234 && a.visitedLinkTextDecorationColor() == b.visitedLinkTextDecoration
Color(); | |
| 235 case CSSPropertyTextIndent: | |
| 236 return a.textIndent() == b.textIndent(); | |
| 237 case CSSPropertyTextShadow: | |
| 238 return dataEquivalent(a.textShadow(), b.textShadow()); | |
| 239 case CSSPropertyTop: | |
| 240 return a.top() == b.top(); | |
| 241 case CSSPropertyVerticalAlign: | |
| 242 return a.verticalAlign() == b.verticalAlign() | |
| 243 && (a.verticalAlign() != VerticalAlignLength || a.getVerticalAlignLe
ngth() == b.getVerticalAlignLength()); | |
| 244 case CSSPropertyVisibility: | |
| 245 return a.visibility() == b.visibility(); | |
| 246 case CSSPropertyWebkitBorderHorizontalSpacing: | |
| 247 return a.horizontalBorderSpacing() == b.horizontalBorderSpacing(); | |
| 248 case CSSPropertyWebkitBorderVerticalSpacing: | |
| 249 return a.verticalBorderSpacing() == b.verticalBorderSpacing(); | |
| 250 case CSSPropertyWebkitClipPath: | |
| 251 return dataEquivalent(a.clipPath(), b.clipPath()); | |
| 252 case CSSPropertyColumnCount: | |
| 253 return a.columnCount() == b.columnCount(); | |
| 254 case CSSPropertyColumnGap: | |
| 255 return a.columnGap() == b.columnGap(); | |
| 256 case CSSPropertyColumnRuleColor: | |
| 257 return a.columnRuleColor() == b.columnRuleColor() | |
| 258 && a.visitedLinkColumnRuleColor() == b.visitedLinkColumnRuleColor(); | |
| 259 case CSSPropertyColumnRuleWidth: | |
| 260 return a.columnRuleWidth() == b.columnRuleWidth(); | |
| 261 case CSSPropertyColumnWidth: | |
| 262 return a.columnWidth() == b.columnWidth(); | |
| 263 case CSSPropertyWebkitFilter: | |
| 264 return a.filter() == b.filter(); | |
| 265 case CSSPropertyBackdropFilter: | |
| 266 return a.backdropFilter() == b.backdropFilter(); | |
| 267 case CSSPropertyWebkitMaskBoxImageOutset: | |
| 268 return a.maskBoxImageOutset() == b.maskBoxImageOutset(); | |
| 269 case CSSPropertyWebkitMaskBoxImageSlice: | |
| 270 return a.maskBoxImageSlices() == b.maskBoxImageSlices(); | |
| 271 case CSSPropertyWebkitMaskBoxImageSource: | |
| 272 return dataEquivalent(a.maskBoxImageSource(), b.maskBoxImageSource()); | |
| 273 case CSSPropertyWebkitMaskBoxImageWidth: | |
| 274 return a.maskBoxImageWidth() == b.maskBoxImageWidth(); | |
| 275 case CSSPropertyWebkitMaskImage: | |
| 276 return dataEquivalent(a.maskImage(), b.maskImage()); | |
| 277 case CSSPropertyWebkitMaskPositionX: | |
| 278 return fillLayersEqual<CSSPropertyWebkitMaskPositionX>(a.maskLayers(), b
.maskLayers()); | |
| 279 case CSSPropertyWebkitMaskPositionY: | |
| 280 return fillLayersEqual<CSSPropertyWebkitMaskPositionY>(a.maskLayers(), b
.maskLayers()); | |
| 281 case CSSPropertyWebkitMaskSize: | |
| 282 return fillLayersEqual<CSSPropertyWebkitMaskSize>(a.maskLayers(), b.mask
Layers()); | |
| 283 case CSSPropertyPerspective: | |
| 284 return a.perspective() == b.perspective(); | |
| 285 case CSSPropertyPerspectiveOrigin: | |
| 286 return a.perspectiveOriginX() == b.perspectiveOriginX() && a.perspective
OriginY() == b.perspectiveOriginY(); | |
| 287 case CSSPropertyWebkitTextStrokeColor: | |
| 288 return a.textStrokeColor() == b.textStrokeColor() | |
| 289 && a.visitedLinkTextStrokeColor() == b.visitedLinkTextStrokeColor(); | |
| 290 case CSSPropertyTransform: | |
| 291 return a.transform() == b.transform(); | |
| 292 case CSSPropertyTranslate: | |
| 293 return dataEquivalent<TransformOperation>(a.translate(), b.translate()); | |
| 294 case CSSPropertyRotate: | |
| 295 return dataEquivalent<TransformOperation>(a.rotate(), b.rotate()); | |
| 296 case CSSPropertyScale: | |
| 297 return dataEquivalent<TransformOperation>(a.scale(), b.scale()); | |
| 298 case CSSPropertyTransformOrigin: | |
| 299 return a.transformOriginX() == b.transformOriginX() && a.transformOrigin
Y() == b.transformOriginY() && a.transformOriginZ() == b.transformOriginZ(); | |
| 300 case CSSPropertyWebkitPerspectiveOriginX: | |
| 301 return a.perspectiveOriginX() == b.perspectiveOriginX(); | |
| 302 case CSSPropertyWebkitPerspectiveOriginY: | |
| 303 return a.perspectiveOriginY() == b.perspectiveOriginY(); | |
| 304 case CSSPropertyWebkitTransformOriginX: | |
| 305 return a.transformOriginX() == b.transformOriginX(); | |
| 306 case CSSPropertyWebkitTransformOriginY: | |
| 307 return a.transformOriginY() == b.transformOriginY(); | |
| 308 case CSSPropertyWebkitTransformOriginZ: | |
| 309 return a.transformOriginZ() == b.transformOriginZ(); | |
| 310 case CSSPropertyWidows: | |
| 311 return a.widows() == b.widows(); | |
| 312 case CSSPropertyWidth: | |
| 313 return a.width() == b.width(); | |
| 314 case CSSPropertyWordSpacing: | |
| 315 return a.wordSpacing() == b.wordSpacing(); | |
| 316 case CSSPropertyD: | |
| 317 return dataEquivalent(a.svgStyle().d(), b.svgStyle().d()); | |
| 318 case CSSPropertyCx: | |
| 319 return a.svgStyle().cx() == b.svgStyle().cx(); | |
| 320 case CSSPropertyCy: | |
| 321 return a.svgStyle().cy() == b.svgStyle().cy(); | |
| 322 case CSSPropertyX: | |
| 323 return a.svgStyle().x() == b.svgStyle().x(); | |
| 324 case CSSPropertyY: | |
| 325 return a.svgStyle().y() == b.svgStyle().y(); | |
| 326 case CSSPropertyR: | |
| 327 return a.svgStyle().r() == b.svgStyle().r(); | |
| 328 case CSSPropertyRx: | |
| 329 return a.svgStyle().rx() == b.svgStyle().rx(); | |
| 330 case CSSPropertyRy: | |
| 331 return a.svgStyle().ry() == b.svgStyle().ry(); | |
| 332 case CSSPropertyZIndex: | |
| 333 return a.hasAutoZIndex() == b.hasAutoZIndex() && (a.hasAutoZIndex() || a
.zIndex() == b.zIndex()); | |
| 334 default: | |
| 335 ASSERT_NOT_REACHED(); | |
| 336 return true; | |
| 337 } | |
| 338 } | |
| 339 | |
| 340 } // namespace blink | |
| OLD | NEW |