@@ -135,17 +135,28 @@ void SVGRenderStyle::copyNonInheritedFrom(const SVGRenderStyle& other)
135135 m_layoutData = other.m_layoutData ;
136136}
137137
138- StyleDifference SVGRenderStyle::diff (const SVGRenderStyle& other) const
138+ static bool colorChangeRequiresRepaint (const StyleColor& a, const StyleColor& b, bool currentColorDiffers)
139139{
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 ;
141142
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+ {
142153 // If kerning changes, we need a relayout, to force SVGCharacterData to be recalculated in the SVGRootInlineBox.
143154 if (m_textData != other.m_textData )
144- return StyleDifference::Layout ;
155+ return true ;
145156
146157 // If markers change, we need a relayout, as marker boundaries are cached in RenderSVGPath.
147158 if (m_inheritedResourceData != other.m_inheritedResourceData )
148- return StyleDifference::Layout ;
159+ return true ;
149160
150161 // All text related properties influence layout.
151162 if (m_inheritedFlags.textAnchor != other.m_inheritedFlags .textAnchor
@@ -154,72 +165,71 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle& other) const
154165 || m_nonInheritedFlags.flagBits .alignmentBaseline != other.m_nonInheritedFlags .flagBits .alignmentBaseline
155166 || m_nonInheritedFlags.flagBits .dominantBaseline != other.m_nonInheritedFlags .flagBits .dominantBaseline
156167 || m_nonInheritedFlags.flagBits .baselineShift != other.m_nonInheritedFlags .flagBits .baselineShift )
157- return StyleDifference::Layout ;
168+ return true ;
158169
159170 // 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 ;
163173
164174 // The x or y properties require relayout.
165175 if (m_layoutData != other.m_layoutData )
166- return StyleDifference::Layout ;
176+ return true ;
167177
168178 // 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 ;
184186
185187 // vector-effect changes require a re-layout.
186188 if (m_nonInheritedFlags.flagBits .vectorEffect != other.m_nonInheritedFlags .flagBits .vectorEffect )
187- return StyleDifference::Layout ;
189+ return true ;
188190
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 ;
190200
191201 // 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 ;
198206
199207 // 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 ;
203213
204214 // If gradient stops change, we just need to repaint. Style updates are already handled through RenderSVGGradientSTop.
205215 if (m_stopData != other.m_stopData )
206- return StyleDifference::Repaint ;
216+ return true ;
207217
208218 // Changes of these flags only cause repaints.
209219 if (m_inheritedFlags.shapeRendering != other.m_inheritedFlags .shapeRendering
210220 || m_inheritedFlags.clipRule != other.m_inheritedFlags .clipRule
211221 || m_inheritedFlags.fillRule != other.m_inheritedFlags .fillRule
212222 || m_inheritedFlags.colorInterpolation != other.m_inheritedFlags .colorInterpolation
213223 || m_inheritedFlags.colorInterpolationFilters != other.m_inheritedFlags .colorInterpolationFilters )
214- return StyleDifference::Repaint ;
224+ return true ;
215225
216226 if (m_nonInheritedFlags.flagBits .bufferedRendering != other.m_nonInheritedFlags .flagBits .bufferedRendering )
217- return StyleDifference::Repaint ;
227+ return true ;
218228
219229 if (m_nonInheritedFlags.flagBits .maskType != other.m_nonInheritedFlags .flagBits .maskType )
220- return StyleDifference::Repaint ;
230+ return true ;
221231
222- return StyleDifference::Equal ;
232+ return false ;
223233}
224234
225235}
0 commit comments