@@ -135,17 +135,28 @@ void SVGRenderStyle::copyNonInheritedFrom(const SVGRenderStyle& other)
135
135
m_layoutData = other.m_layoutData ;
136
136
}
137
137
138
- StyleDifference SVGRenderStyle::diff (const SVGRenderStyle& other) const
138
+ static bool colorChangeRequiresRepaint (const StyleColor& a, const StyleColor& b, bool currentColorDiffers)
139
139
{
140
- // NOTE: All comparisions that may return StyleDifference::Layout have to go before those who return StyleDifference::Repaint
140
+ if (a != b)
141
+ return true ;
141
142
143
+ if (a.isCurrentColor ()) {
144
+ ASSERT (b.isCurrentColor ());
145
+ return currentColorDiffers;
146
+ }
147
+
148
+ return false ;
149
+ }
150
+
151
+ bool SVGRenderStyle::changeRequiresLayout (const SVGRenderStyle& other) const
152
+ {
142
153
// If kerning changes, we need a relayout, to force SVGCharacterData to be recalculated in the SVGRootInlineBox.
143
154
if (m_textData != other.m_textData )
144
- return StyleDifference::Layout ;
155
+ return true ;
145
156
146
157
// If markers change, we need a relayout, as marker boundaries are cached in RenderSVGPath.
147
158
if (m_inheritedResourceData != other.m_inheritedResourceData )
148
- return StyleDifference::Layout ;
159
+ return true ;
149
160
150
161
// All text related properties influence layout.
151
162
if (m_inheritedFlags.textAnchor != other.m_inheritedFlags .textAnchor
@@ -154,72 +165,71 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle& other) const
154
165
|| m_nonInheritedFlags.flagBits .alignmentBaseline != other.m_nonInheritedFlags .flagBits .alignmentBaseline
155
166
|| m_nonInheritedFlags.flagBits .dominantBaseline != other.m_nonInheritedFlags .flagBits .dominantBaseline
156
167
|| m_nonInheritedFlags.flagBits .baselineShift != other.m_nonInheritedFlags .flagBits .baselineShift )
157
- return StyleDifference::Layout ;
168
+ return true ;
158
169
159
170
// Text related properties influence layout.
160
- bool miscNotEqual = m_miscData != other.m_miscData ;
161
- if (miscNotEqual && m_miscData->baselineShiftValue != other.m_miscData ->baselineShiftValue )
162
- return StyleDifference::Layout;
171
+ if (m_miscData->baselineShiftValue != other.m_miscData ->baselineShiftValue )
172
+ return true ;
163
173
164
174
// The x or y properties require relayout.
165
175
if (m_layoutData != other.m_layoutData )
166
- return StyleDifference::Layout ;
176
+ return true ;
167
177
168
178
// Some stroke properties, requires relayouts, as the cached stroke boundaries need to be recalculated.
169
- if (m_strokeData != other.m_strokeData ) {
170
- if (m_strokeData->paintType != other.m_strokeData ->paintType
171
- || m_strokeData->paintColor != other.m_strokeData ->paintColor
172
- || m_strokeData->paintUri != other.m_strokeData ->paintUri
173
- || m_strokeData->dashArray != other.m_strokeData ->dashArray
174
- || m_strokeData->dashOffset != other.m_strokeData ->dashOffset
175
- || m_strokeData->visitedLinkPaintColor != other.m_strokeData ->visitedLinkPaintColor
176
- || m_strokeData->visitedLinkPaintUri != other.m_strokeData ->visitedLinkPaintUri
177
- || m_strokeData->visitedLinkPaintType != other.m_strokeData ->visitedLinkPaintType )
178
- return StyleDifference::Layout;
179
-
180
- // Only the stroke-opacity case remains, where we only need a repaint.
181
- ASSERT (m_strokeData->opacity != other.m_strokeData ->opacity );
182
- return StyleDifference::Repaint;
183
- }
179
+ if (m_strokeData->paintType != other.m_strokeData ->paintType
180
+ || m_strokeData->paintUri != other.m_strokeData ->paintUri
181
+ || m_strokeData->dashArray != other.m_strokeData ->dashArray
182
+ || m_strokeData->dashOffset != other.m_strokeData ->dashOffset
183
+ || m_strokeData->visitedLinkPaintUri != other.m_strokeData ->visitedLinkPaintUri
184
+ || m_strokeData->visitedLinkPaintType != other.m_strokeData ->visitedLinkPaintType )
185
+ return true ;
184
186
185
187
// vector-effect changes require a re-layout.
186
188
if (m_nonInheritedFlags.flagBits .vectorEffect != other.m_nonInheritedFlags .flagBits .vectorEffect )
187
- return StyleDifference::Layout ;
189
+ return true ;
188
190
189
- // NOTE: All comparisions below may only return StyleDifference::Repaint
191
+ return false ;
192
+ }
193
+
194
+ bool SVGRenderStyle::changeRequiresRepaint (const SVGRenderStyle& other, bool currentColorDiffers) const
195
+ {
196
+ if (m_strokeData->opacity != other.m_strokeData ->opacity
197
+ || colorChangeRequiresRepaint (m_strokeData->paintColor , other.m_strokeData ->paintColor , currentColorDiffers)
198
+ || colorChangeRequiresRepaint (m_strokeData->visitedLinkPaintColor , other.m_strokeData ->visitedLinkPaintColor , currentColorDiffers))
199
+ return true ;
190
200
191
201
// Painting related properties only need repaints.
192
- if (miscNotEqual) {
193
- if (m_miscData->floodColor != other.m_miscData ->floodColor
194
- || m_miscData->floodOpacity != other.m_miscData ->floodOpacity
195
- || m_miscData->lightingColor != other.m_miscData ->lightingColor )
196
- return StyleDifference::Repaint;
197
- }
202
+ if (colorChangeRequiresRepaint (m_miscData->floodColor , other.m_miscData ->floodColor , currentColorDiffers)
203
+ || m_miscData->floodOpacity != other.m_miscData ->floodOpacity
204
+ || colorChangeRequiresRepaint (m_miscData->lightingColor , other.m_miscData ->lightingColor , currentColorDiffers))
205
+ return true ;
198
206
199
207
// If fill data changes, we just need to repaint. Fill boundaries are not influenced by this, only by the Path, that RenderSVGPath contains.
200
- if (m_fillData->paintType != other.m_fillData ->paintType || m_fillData->paintColor != other.m_fillData ->paintColor
201
- || m_fillData->paintUri != other.m_fillData ->paintUri || m_fillData->opacity != other.m_fillData ->opacity )
202
- return StyleDifference::Repaint;
208
+ if (m_fillData->paintType != other.m_fillData ->paintType
209
+ || colorChangeRequiresRepaint (m_fillData->paintColor , other.m_fillData ->paintColor , currentColorDiffers)
210
+ || m_fillData->paintUri != other.m_fillData ->paintUri
211
+ || m_fillData->opacity != other.m_fillData ->opacity )
212
+ return true ;
203
213
204
214
// If gradient stops change, we just need to repaint. Style updates are already handled through RenderSVGGradientSTop.
205
215
if (m_stopData != other.m_stopData )
206
- return StyleDifference::Repaint ;
216
+ return true ;
207
217
208
218
// Changes of these flags only cause repaints.
209
219
if (m_inheritedFlags.shapeRendering != other.m_inheritedFlags .shapeRendering
210
220
|| m_inheritedFlags.clipRule != other.m_inheritedFlags .clipRule
211
221
|| m_inheritedFlags.fillRule != other.m_inheritedFlags .fillRule
212
222
|| m_inheritedFlags.colorInterpolation != other.m_inheritedFlags .colorInterpolation
213
223
|| m_inheritedFlags.colorInterpolationFilters != other.m_inheritedFlags .colorInterpolationFilters )
214
- return StyleDifference::Repaint ;
224
+ return true ;
215
225
216
226
if (m_nonInheritedFlags.flagBits .bufferedRendering != other.m_nonInheritedFlags .flagBits .bufferedRendering )
217
- return StyleDifference::Repaint ;
227
+ return true ;
218
228
219
229
if (m_nonInheritedFlags.flagBits .maskType != other.m_nonInheritedFlags .flagBits .maskType )
220
- return StyleDifference::Repaint ;
230
+ return true ;
221
231
222
- return StyleDifference::Equal ;
232
+ return false ;
223
233
}
224
234
225
235
}
0 commit comments