| 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 "sky/engine/core/animation/css/CSSPropertyEquality.h" | |
| 6 | |
| 7 #include "sky/engine/core/animation/css/CSSAnimations.h" | |
| 8 #include "sky/engine/core/rendering/style/DataEquivalency.h" | |
| 9 #include "sky/engine/core/rendering/style/RenderStyle.h" | |
| 10 #include "sky/engine/core/rendering/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 if (aLayer->xPosition() != bLayer->xPosition()) | |
| 25 return false; | |
| 26 break; | |
| 27 case CSSPropertyBackgroundPositionY: | |
| 28 if (aLayer->yPosition() != bLayer->yPosition()) | |
| 29 return false; | |
| 30 break; | |
| 31 case CSSPropertyBackgroundSize: | |
| 32 case CSSPropertyWebkitBackgroundSize: | |
| 33 if (!(aLayer->sizeLength() == bLayer->sizeLength())) | |
| 34 return false; | |
| 35 break; | |
| 36 case CSSPropertyBackgroundImage: | |
| 37 if (!dataEquivalent(aLayer->image(), bLayer->image())) | |
| 38 return false; | |
| 39 break; | |
| 40 default: | |
| 41 ASSERT_NOT_REACHED(); | |
| 42 return true; | |
| 43 } | |
| 44 | |
| 45 aLayer = aLayer->next(); | |
| 46 bLayer = bLayer->next(); | |
| 47 } | |
| 48 | |
| 49 // FIXME: Shouldn't this be return !aLayer && !bLayer; ? | |
| 50 return true; | |
| 51 } | |
| 52 | |
| 53 } | |
| 54 | |
| 55 bool CSSPropertyEquality::propertiesEqual(CSSPropertyID prop, const RenderStyle&
a, const RenderStyle& b) | |
| 56 { | |
| 57 switch (prop) { | |
| 58 case CSSPropertyBackgroundColor: | |
| 59 return a.backgroundColor().resolve(a.color()) == b.backgroundColor().res
olve(b.color()); | |
| 60 case CSSPropertyBackgroundImage: | |
| 61 return fillLayersEqual<CSSPropertyBackgroundImage>(a.backgroundLayers(),
b.backgroundLayers()); | |
| 62 case CSSPropertyBackgroundPositionX: | |
| 63 return fillLayersEqual<CSSPropertyBackgroundPositionX>(a.backgroundLayer
s(), b.backgroundLayers()); | |
| 64 case CSSPropertyBackgroundPositionY: | |
| 65 return fillLayersEqual<CSSPropertyBackgroundPositionY>(a.backgroundLayer
s(), b.backgroundLayers()); | |
| 66 case CSSPropertyBackgroundSize: | |
| 67 return fillLayersEqual<CSSPropertyBackgroundSize>(a.backgroundLayers(),
b.backgroundLayers()); | |
| 68 case CSSPropertyBorderBottomColor: | |
| 69 return a.borderBottomColor().resolve(a.color()) == b.borderBottomColor()
.resolve(b.color()); | |
| 70 case CSSPropertyBorderBottomLeftRadius: | |
| 71 return a.borderBottomLeftRadius() == b.borderBottomLeftRadius(); | |
| 72 case CSSPropertyBorderBottomRightRadius: | |
| 73 return a.borderBottomRightRadius() == b.borderBottomRightRadius(); | |
| 74 case CSSPropertyBorderBottomWidth: | |
| 75 return a.borderBottomWidth() == b.borderBottomWidth(); | |
| 76 case CSSPropertyBorderImageOutset: | |
| 77 return a.borderImageOutset() == b.borderImageOutset(); | |
| 78 case CSSPropertyBorderImageSlice: | |
| 79 return a.borderImageSlices() == b.borderImageSlices(); | |
| 80 case CSSPropertyBorderImageSource: | |
| 81 return dataEquivalent(a.borderImageSource(), b.borderImageSource()); | |
| 82 case CSSPropertyBorderImageWidth: | |
| 83 return a.borderImageWidth() == b.borderImageWidth(); | |
| 84 case CSSPropertyBorderLeftColor: | |
| 85 return a.borderLeftColor().resolve(a.color()) == b.borderLeftColor().res
olve(b.color()); | |
| 86 case CSSPropertyBorderLeftWidth: | |
| 87 return a.borderLeftWidth() == b.borderLeftWidth(); | |
| 88 case CSSPropertyBorderRightColor: | |
| 89 return a.borderRightColor().resolve(a.color()) == b.borderRightColor().r
esolve(b.color()); | |
| 90 case CSSPropertyBorderRightWidth: | |
| 91 return a.borderRightWidth() == b.borderRightWidth(); | |
| 92 case CSSPropertyBorderTopColor: | |
| 93 return a.borderTopColor().resolve(a.color()) == b.borderTopColor().resol
ve(b.color()); | |
| 94 case CSSPropertyBorderTopLeftRadius: | |
| 95 return a.borderTopLeftRadius() == b.borderTopLeftRadius(); | |
| 96 case CSSPropertyBorderTopRightRadius: | |
| 97 return a.borderTopRightRadius() == b.borderTopRightRadius(); | |
| 98 case CSSPropertyBorderTopWidth: | |
| 99 return a.borderTopWidth() == b.borderTopWidth(); | |
| 100 case CSSPropertyBottom: | |
| 101 return a.bottom() == b.bottom(); | |
| 102 case CSSPropertyBoxShadow: | |
| 103 return dataEquivalent(a.boxShadow(), b.boxShadow()); | |
| 104 case CSSPropertyClip: | |
| 105 return a.clip() == b.clip(); | |
| 106 case CSSPropertyColor: | |
| 107 return a.color() == b.color(); | |
| 108 case CSSPropertyFilter: | |
| 109 return a.filter() == b.filter(); | |
| 110 case CSSPropertyFlexBasis: | |
| 111 return a.flexBasis() == b.flexBasis(); | |
| 112 case CSSPropertyFlexGrow: | |
| 113 return a.flexGrow() == b.flexGrow(); | |
| 114 case CSSPropertyFlexShrink: | |
| 115 return a.flexShrink() == b.flexShrink(); | |
| 116 case CSSPropertyFontSize: | |
| 117 // CSSPropertyFontSize: Must pass a specified size to setFontSize if Tex
t Autosizing is enabled, but a computed size | |
| 118 // if text zoom is enabled (if neither is enabled it's irrelevant as the
y're probably the same). | |
| 119 // FIXME: Should we introduce an option to pass the computed font size h
ere, allowing consumers to | |
| 120 // enable text zoom rather than Text Autosizing? See http://crbug.com/22
7545. | |
| 121 return a.specifiedFontSize() == b.specifiedFontSize(); | |
| 122 case CSSPropertyFontStretch: | |
| 123 return a.fontStretch() == b.fontStretch(); | |
| 124 case CSSPropertyFontWeight: | |
| 125 return a.fontWeight() == b.fontWeight(); | |
| 126 case CSSPropertyHeight: | |
| 127 return a.height() == b.height(); | |
| 128 case CSSPropertyLeft: | |
| 129 return a.left() == b.left(); | |
| 130 case CSSPropertyLetterSpacing: | |
| 131 return a.letterSpacing() == b.letterSpacing(); | |
| 132 case CSSPropertyLineHeight: | |
| 133 return a.specifiedLineHeight() == b.specifiedLineHeight(); | |
| 134 case CSSPropertyMarginBottom: | |
| 135 return a.marginBottom() == b.marginBottom(); | |
| 136 case CSSPropertyMarginLeft: | |
| 137 return a.marginLeft() == b.marginLeft(); | |
| 138 case CSSPropertyMarginRight: | |
| 139 return a.marginRight() == b.marginRight(); | |
| 140 case CSSPropertyMarginTop: | |
| 141 return a.marginTop() == b.marginTop(); | |
| 142 case CSSPropertyMaxHeight: | |
| 143 return a.maxHeight() == b.maxHeight(); | |
| 144 case CSSPropertyMaxWidth: | |
| 145 return a.maxWidth() == b.maxWidth(); | |
| 146 case CSSPropertyMinHeight: | |
| 147 return a.minHeight() == b.minHeight(); | |
| 148 case CSSPropertyMinWidth: | |
| 149 return a.minWidth() == b.minWidth(); | |
| 150 case CSSPropertyObjectPosition: | |
| 151 return a.objectPosition() == b.objectPosition(); | |
| 152 case CSSPropertyOpacity: | |
| 153 return a.opacity() == b.opacity(); | |
| 154 case CSSPropertyOutlineColor: | |
| 155 return a.outlineColor().resolve(a.color()) == b.outlineColor().resolve(b
.color()); | |
| 156 case CSSPropertyOutlineOffset: | |
| 157 return a.outlineOffset() == b.outlineOffset(); | |
| 158 case CSSPropertyOutlineWidth: | |
| 159 return a.outlineWidth() == b.outlineWidth(); | |
| 160 case CSSPropertyPaddingBottom: | |
| 161 return a.paddingBottom() == b.paddingBottom(); | |
| 162 case CSSPropertyPaddingLeft: | |
| 163 return a.paddingLeft() == b.paddingLeft(); | |
| 164 case CSSPropertyPaddingRight: | |
| 165 return a.paddingRight() == b.paddingRight(); | |
| 166 case CSSPropertyPaddingTop: | |
| 167 return a.paddingTop() == b.paddingTop(); | |
| 168 case CSSPropertyRight: | |
| 169 return a.right() == b.right(); | |
| 170 case CSSPropertyTextDecorationColor: | |
| 171 return a.textDecorationColor().resolve(a.color()) == b.textDecorationCol
or().resolve(b.color()); | |
| 172 case CSSPropertyTextIndent: | |
| 173 return a.textIndent() == b.textIndent(); | |
| 174 case CSSPropertyTextShadow: | |
| 175 return dataEquivalent(a.textShadow(), b.textShadow()); | |
| 176 case CSSPropertyTop: | |
| 177 return a.top() == b.top(); | |
| 178 case CSSPropertyVerticalAlign: | |
| 179 return a.verticalAlign() == b.verticalAlign() | |
| 180 && (a.verticalAlign() != LENGTH || a.verticalAlignLength() == b.vert
icalAlignLength()); | |
| 181 case CSSPropertyWebkitBackgroundSize: | |
| 182 return fillLayersEqual<CSSPropertyWebkitBackgroundSize>(a.backgroundLaye
rs(), b.backgroundLayers()); | |
| 183 case CSSPropertyWebkitBorderHorizontalSpacing: | |
| 184 return a.horizontalBorderSpacing() == b.horizontalBorderSpacing(); | |
| 185 case CSSPropertyWebkitBorderVerticalSpacing: | |
| 186 return a.verticalBorderSpacing() == b.verticalBorderSpacing(); | |
| 187 case CSSPropertyWebkitBoxShadow: | |
| 188 return dataEquivalent(a.boxShadow(), b.boxShadow()); | |
| 189 case CSSPropertyWebkitClipPath: | |
| 190 return dataEquivalent(a.clipPath(), b.clipPath()); | |
| 191 case CSSPropertyPerspective: | |
| 192 return a.perspective() == b.perspective(); | |
| 193 case CSSPropertyPerspectiveOrigin: | |
| 194 return a.perspectiveOriginX() == b.perspectiveOriginX() && a.perspective
OriginY() == b.perspectiveOriginY(); | |
| 195 case CSSPropertyWebkitTextStrokeColor: | |
| 196 return a.textStrokeColor().resolve(a.color()) == b.textStrokeColor().res
olve(b.color()); | |
| 197 case CSSPropertyTransform: | |
| 198 return a.transform() == b.transform(); | |
| 199 case CSSPropertyTransformOrigin: | |
| 200 return a.transformOriginX() == b.transformOriginX() && a.transformOrigin
Y() == b.transformOriginY() && a.transformOriginZ() == b.transformOriginZ(); | |
| 201 case CSSPropertyWidth: | |
| 202 return a.width() == b.width(); | |
| 203 case CSSPropertyWordSpacing: | |
| 204 return a.wordSpacing() == b.wordSpacing(); | |
| 205 case CSSPropertyZIndex: | |
| 206 return a.zIndex() == b.zIndex(); | |
| 207 default: | |
| 208 ASSERT_NOT_REACHED(); | |
| 209 return true; | |
| 210 } | |
| 211 } | |
| 212 | |
| 213 } | |
| OLD | NEW |