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

Side by Side Diff: Source/core/rendering/style/SVGRenderStyle.cpp

Issue 236203020: Separate repaint and layout requirements of StyleDifference (Step 1) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update layout test expectations Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2010 Rob Buis <buis@kde.org> 3 2004, 2005, 2010 Rob Buis <buis@kde.org>
4 Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 Copyright (C) Research In Motion Limited 2010. All rights reserved.
5 5
6 Based on khtml code by: 6 Based on khtml code by:
7 Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) 7 Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
8 Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) 8 Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
9 Copyright (C) 2002-2003 Dirk Mueller (mueller@kde.org) 9 Copyright (C) 2002-2003 Dirk Mueller (mueller@kde.org)
10 Copyright (C) 2002 Apple Computer, Inc. 10 Copyright (C) 2002 Apple Computer, Inc.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 void SVGRenderStyle::copyNonInheritedFrom(const SVGRenderStyle* other) 113 void SVGRenderStyle::copyNonInheritedFrom(const SVGRenderStyle* other)
114 { 114 {
115 svg_noninherited_flags = other->svg_noninherited_flags; 115 svg_noninherited_flags = other->svg_noninherited_flags;
116 stops = other->stops; 116 stops = other->stops;
117 misc = other->misc; 117 misc = other->misc;
118 resources = other->resources; 118 resources = other->resources;
119 } 119 }
120 120
121 StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const 121 StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
122 { 122 {
123 // NOTE: All comparisions that may return StyleDifferenceLayout have to go b efore those who return StyleDifferenceRepaint 123 StyleDifference styleDifference;
124 124
125 if (diffNeedsLayoutAndRepaint(other)) {
126 styleDifference.setNeedsFullLayout();
127 styleDifference.setNeedsRepaintSelf();
128 } else if (diffNeedsRepaintOnly(other)) {
129 styleDifference.setNeedsRepaintSelf();
130 }
131
132 return styleDifference;
133 }
134
135 bool SVGRenderStyle::diffNeedsLayoutAndRepaint(const SVGRenderStyle* other) cons t
136 {
125 // If resources change, we need a relayout, as the presence of resources inf luences the repaint rect. 137 // If resources change, we need a relayout, as the presence of resources inf luences the repaint rect.
126 if (resources != other->resources) 138 if (resources != other->resources)
127 return StyleDifferenceLayout; 139 return true;
128 140
129 // If markers change, we need a relayout, as marker boundaries are cached in RenderSVGPath. 141 // If markers change, we need a relayout, as marker boundaries are cached in RenderSVGPath.
130 if (inheritedResources != other->inheritedResources) 142 if (inheritedResources != other->inheritedResources)
131 return StyleDifferenceLayout; 143 return true;
132 144
133 // All text related properties influence layout. 145 // All text related properties influence layout.
134 if (svg_inherited_flags._textAnchor != other->svg_inherited_flags._textAncho r 146 if (svg_inherited_flags._textAnchor != other->svg_inherited_flags._textAncho r
135 || svg_inherited_flags._writingMode != other->svg_inherited_flags._writi ngMode 147 || svg_inherited_flags._writingMode != other->svg_inherited_flags._writi ngMode
136 || svg_inherited_flags._glyphOrientationHorizontal != other->svg_inherit ed_flags._glyphOrientationHorizontal 148 || svg_inherited_flags._glyphOrientationHorizontal != other->svg_inherit ed_flags._glyphOrientationHorizontal
137 || svg_inherited_flags._glyphOrientationVertical != other->svg_inherited _flags._glyphOrientationVertical 149 || svg_inherited_flags._glyphOrientationVertical != other->svg_inherited _flags._glyphOrientationVertical
138 || svg_noninherited_flags.f._alignmentBaseline != other->svg_noninherite d_flags.f._alignmentBaseline 150 || svg_noninherited_flags.f._alignmentBaseline != other->svg_noninherite d_flags.f._alignmentBaseline
139 || svg_noninherited_flags.f._dominantBaseline != other->svg_noninherited _flags.f._dominantBaseline 151 || svg_noninherited_flags.f._dominantBaseline != other->svg_noninherited _flags.f._dominantBaseline
140 || svg_noninherited_flags.f._baselineShift != other->svg_noninherited_fl ags.f._baselineShift) 152 || svg_noninherited_flags.f._baselineShift != other->svg_noninherited_fl ags.f._baselineShift)
141 return StyleDifferenceLayout; 153 return true;
142 154
143 // Text related properties influence layout. 155 // Text related properties influence layout.
144 bool miscNotEqual = misc != other->misc; 156 if (misc != other->misc && misc->baselineShiftValue != other->misc->baseline ShiftValue)
145 if (miscNotEqual && misc->baselineShiftValue != other->misc->baselineShiftVa lue) 157 return true;
146 return StyleDifferenceLayout;
147 158
148 // These properties affect the cached stroke bounding box rects. 159 // These properties affect the cached stroke bounding box rects.
149 if (svg_inherited_flags._capStyle != other->svg_inherited_flags._capStyle 160 if (svg_inherited_flags._capStyle != other->svg_inherited_flags._capStyle
150 || svg_inherited_flags._joinStyle != other->svg_inherited_flags._joinSty le) 161 || svg_inherited_flags._joinStyle != other->svg_inherited_flags._joinSty le)
151 return StyleDifferenceLayout; 162 return true;
163
164 // vector-effect changes require a re-layout.
165 if (svg_noninherited_flags.f._vectorEffect != other->svg_noninherited_flags. f._vectorEffect)
166 return true;
152 167
153 // Some stroke properties, requires relayouts, as the cached stroke boundari es need to be recalculated. 168 // Some stroke properties, requires relayouts, as the cached stroke boundari es need to be recalculated.
154 if (stroke != other->stroke) { 169 if (stroke != other->stroke) {
155 if (stroke->width != other->stroke->width 170 if (stroke->width != other->stroke->width
156 || stroke->paintType != other->stroke->paintType 171 || stroke->paintType != other->stroke->paintType
157 || stroke->paintColor != other->stroke->paintColor 172 || stroke->paintColor != other->stroke->paintColor
158 || stroke->paintUri != other->stroke->paintUri 173 || stroke->paintUri != other->stroke->paintUri
159 || stroke->miterLimit != other->stroke->miterLimit 174 || stroke->miterLimit != other->stroke->miterLimit
160 || stroke->dashArray != other->stroke->dashArray 175 || stroke->dashArray != other->stroke->dashArray
161 || stroke->dashOffset != other->stroke->dashOffset 176 || stroke->dashOffset != other->stroke->dashOffset
162 || stroke->visitedLinkPaintColor != other->stroke->visitedLinkPaintC olor 177 || stroke->visitedLinkPaintColor != other->stroke->visitedLinkPaintC olor
163 || stroke->visitedLinkPaintUri != other->stroke->visitedLinkPaintUri 178 || stroke->visitedLinkPaintUri != other->stroke->visitedLinkPaintUri
164 || stroke->visitedLinkPaintType != other->stroke->visitedLinkPaintTy pe) 179 || stroke->visitedLinkPaintType != other->stroke->visitedLinkPaintTy pe)
165 return StyleDifferenceLayout; 180 return true;
181 }
166 182
183 return false;
184 }
185
186 bool SVGRenderStyle::diffNeedsRepaintOnly(const SVGRenderStyle* other) const
187 {
188 if (stroke != other->stroke) {
167 // Only the stroke-opacity case remains, where we only need a repaint. 189 // Only the stroke-opacity case remains, where we only need a repaint.
168 ASSERT(stroke->opacity != other->stroke->opacity); 190 ASSERT(stroke->opacity != other->stroke->opacity);
169 return StyleDifferenceRepaint; 191 return true;
170 } 192 }
171 193
172 // vector-effect changes require a re-layout.
173 if (svg_noninherited_flags.f._vectorEffect != other->svg_noninherited_flags. f._vectorEffect)
174 return StyleDifferenceLayout;
175
176 // NOTE: All comparisions below may only return StyleDifferenceRepaint
177
178 // Painting related properties only need repaints. 194 // Painting related properties only need repaints.
179 if (miscNotEqual) { 195 if (misc != other->misc) {
180 if (misc->floodColor != other->misc->floodColor 196 if (misc->floodColor != other->misc->floodColor
181 || misc->floodOpacity != other->misc->floodOpacity 197 || misc->floodOpacity != other->misc->floodOpacity
182 || misc->lightingColor != other->misc->lightingColor) 198 || misc->lightingColor != other->misc->lightingColor)
183 return StyleDifferenceRepaint; 199 return true;
184 } 200 }
185 201
186 // If fill changes, we just need to repaint. Fill boundaries are not influen ced by this, only by the Path, that RenderSVGPath contains. 202 // If fill changes, we just need to repaint. Fill boundaries are not influen ced by this, only by the Path, that RenderSVGPath contains.
187 if (fill->paintType != other->fill->paintType || fill->paintColor != other-> fill->paintColor 203 if (fill->paintType != other->fill->paintType || fill->paintColor != other-> fill->paintColor
188 || fill->paintUri != other->fill->paintUri || fill->opacity != other->fi ll->opacity) 204 || fill->paintUri != other->fill->paintUri || fill->opacity != other->fi ll->opacity)
189 return StyleDifferenceRepaint; 205 return true;
190 206
191 // If gradient stops change, we just need to repaint. Style updates are alre ady handled through RenderSVGGradientSTop. 207 // If gradient stops change, we just need to repaint. Style updates are alre ady handled through RenderSVGGradientSTop.
192 if (stops != other->stops) 208 if (stops != other->stops)
193 return StyleDifferenceRepaint; 209 return true;
194 210
195 // Changes of these flags only cause repaints. 211 // Changes of these flags only cause repaints.
196 if (svg_inherited_flags._colorRendering != other->svg_inherited_flags._color Rendering 212 if (svg_inherited_flags._colorRendering != other->svg_inherited_flags._color Rendering
197 || svg_inherited_flags._shapeRendering != other->svg_inherited_flags._sh apeRendering 213 || svg_inherited_flags._shapeRendering != other->svg_inherited_flags._sh apeRendering
198 || svg_inherited_flags._clipRule != other->svg_inherited_flags._clipRule 214 || svg_inherited_flags._clipRule != other->svg_inherited_flags._clipRule
199 || svg_inherited_flags._fillRule != other->svg_inherited_flags._fillRule 215 || svg_inherited_flags._fillRule != other->svg_inherited_flags._fillRule
200 || svg_inherited_flags._colorInterpolation != other->svg_inherited_flags ._colorInterpolation 216 || svg_inherited_flags._colorInterpolation != other->svg_inherited_flags ._colorInterpolation
201 || svg_inherited_flags._colorInterpolationFilters != other->svg_inherite d_flags._colorInterpolationFilters 217 || svg_inherited_flags._colorInterpolationFilters != other->svg_inherite d_flags._colorInterpolationFilters
202 || svg_inherited_flags._paintOrder != other->svg_inherited_flags._paintO rder) 218 || svg_inherited_flags._paintOrder != other->svg_inherited_flags._paintO rder)
203 return StyleDifferenceRepaint; 219 return true;
204 220
205 if (svg_noninherited_flags.f.bufferedRendering != other->svg_noninherited_fl ags.f.bufferedRendering) 221 if (svg_noninherited_flags.f.bufferedRendering != other->svg_noninherited_fl ags.f.bufferedRendering)
206 return StyleDifferenceRepaint; 222 return true;
207 223
208 if (svg_noninherited_flags.f.maskType != other->svg_noninherited_flags.f.mas kType) 224 if (svg_noninherited_flags.f.maskType != other->svg_noninherited_flags.f.mas kType)
209 return StyleDifferenceRepaint; 225 return true;
210 226
211 return StyleDifferenceEqual; 227 return false;
212 } 228 }
213 229
214 EPaintOrderType SVGRenderStyle::paintOrderType(unsigned index) const 230 EPaintOrderType SVGRenderStyle::paintOrderType(unsigned index) const
215 { 231 {
216 ASSERT(index < ((1 << kPaintOrderBitwidth)-1)); 232 ASSERT(index < ((1 << kPaintOrderBitwidth)-1));
217 unsigned pt = (paintOrder() >> (kPaintOrderBitwidth*index)) & ((1u << kPaint OrderBitwidth) - 1); 233 unsigned pt = (paintOrder() >> (kPaintOrderBitwidth*index)) & ((1u << kPaint OrderBitwidth) - 1);
218 return (EPaintOrderType)pt; 234 return (EPaintOrderType)pt;
219 } 235 }
220 236
221 } 237 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698