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

Side by Side Diff: third_party/WebKit/Source/core/style/SVGComputedStyle.cpp

Issue 2753013004: Apply SVG styles paint-order, stroke-linejoin, and stroke-linecap on DOM text
Patch Set: Apply SVG styles paint-order, stroke-linejoin, and stroke-linecap on DOM text Created 3 years, 9 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
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 11 matching lines...) Expand all
22 You should have received a copy of the GNU Library General Public License 22 You should have received a copy of the GNU Library General Public License
23 along with this library; see the file COPYING.LIB. If not, write to 23 along with this library; see the file COPYING.LIB. If not, write to
24 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 Boston, MA 02110-1301, USA. 25 Boston, MA 02110-1301, USA.
26 */ 26 */
27 27
28 #include "core/style/SVGComputedStyle.h" 28 #include "core/style/SVGComputedStyle.h"
29 29
30 namespace blink { 30 namespace blink {
31 31
32 static const int kPaintOrderBitwidth = 2;
33
34 SVGComputedStyle::SVGComputedStyle() { 32 SVGComputedStyle::SVGComputedStyle() {
35 static SVGComputedStyle* initialStyle = new SVGComputedStyle(CreateInitial); 33 static SVGComputedStyle* initialStyle = new SVGComputedStyle(CreateInitial);
36 34
37 fill = initialStyle->fill; 35 fill = initialStyle->fill;
38 stroke = initialStyle->stroke; 36 stroke = initialStyle->stroke;
39 stops = initialStyle->stops; 37 stops = initialStyle->stops;
40 misc = initialStyle->misc; 38 misc = initialStyle->misc;
41 inheritedResources = initialStyle->inheritedResources; 39 inheritedResources = initialStyle->inheritedResources;
42 geometry = initialStyle->geometry; 40 geometry = initialStyle->geometry;
43 resources = initialStyle->resources; 41 resources = initialStyle->resources;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 svg_noninherited_flags.f.alignmentBaseline != 144 svg_noninherited_flags.f.alignmentBaseline !=
147 other->svg_noninherited_flags.f.alignmentBaseline || 145 other->svg_noninherited_flags.f.alignmentBaseline ||
148 svg_noninherited_flags.f.baselineShift != 146 svg_noninherited_flags.f.baselineShift !=
149 other->svg_noninherited_flags.f.baselineShift) 147 other->svg_noninherited_flags.f.baselineShift)
150 return true; 148 return true;
151 149
152 // Text related properties influence layout. 150 // Text related properties influence layout.
153 if (misc->baselineShiftValue != other->misc->baselineShiftValue) 151 if (misc->baselineShiftValue != other->misc->baselineShiftValue)
154 return true; 152 return true;
155 153
156 // These properties affect the cached stroke bounding box rects.
157 if (svg_inherited_flags.capStyle != other->svg_inherited_flags.capStyle ||
158 svg_inherited_flags.joinStyle != other->svg_inherited_flags.joinStyle)
159 return true;
160
161 // vector-effect changes require a re-layout. 154 // vector-effect changes require a re-layout.
162 if (svg_noninherited_flags.f.vectorEffect != 155 if (svg_noninherited_flags.f.vectorEffect !=
163 other->svg_noninherited_flags.f.vectorEffect) 156 other->svg_noninherited_flags.f.vectorEffect)
164 return true; 157 return true;
165 158
166 // Some stroke properties, requires relayouts, as the cached stroke boundaries 159 // Some stroke properties, requires relayouts, as the cached stroke boundaries
167 // need to be recalculated. 160 // need to be recalculated.
168 if (stroke.get() != other->stroke.get()) { 161 if (stroke.get() != other->stroke.get()) {
169 if (stroke->width != other->stroke->width || 162 if (stroke->paintType != other->stroke->paintType ||
170 stroke->paintType != other->stroke->paintType ||
171 stroke->paintColor != other->stroke->paintColor || 163 stroke->paintColor != other->stroke->paintColor ||
172 stroke->paintUri != other->stroke->paintUri || 164 stroke->paintUri != other->stroke->paintUri ||
173 stroke->miterLimit != other->stroke->miterLimit || 165 stroke->miterLimit != other->stroke->miterLimit ||
174 *stroke->dashArray != *other->stroke->dashArray || 166 *stroke->dashArray != *other->stroke->dashArray ||
175 stroke->dashOffset != other->stroke->dashOffset || 167 stroke->dashOffset != other->stroke->dashOffset ||
176 stroke->visitedLinkPaintColor != other->stroke->visitedLinkPaintColor || 168 stroke->visitedLinkPaintColor != other->stroke->visitedLinkPaintColor ||
177 stroke->visitedLinkPaintUri != other->stroke->visitedLinkPaintUri || 169 stroke->visitedLinkPaintUri != other->stroke->visitedLinkPaintUri ||
178 stroke->visitedLinkPaintType != other->stroke->visitedLinkPaintType) 170 stroke->visitedLinkPaintType != other->stroke->visitedLinkPaintType)
179 return true; 171 return true;
180 } 172 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // Changes of these flags only cause paint invalidations. 209 // Changes of these flags only cause paint invalidations.
218 if (svg_inherited_flags.colorRendering != 210 if (svg_inherited_flags.colorRendering !=
219 other->svg_inherited_flags.colorRendering || 211 other->svg_inherited_flags.colorRendering ||
220 svg_inherited_flags.shapeRendering != 212 svg_inherited_flags.shapeRendering !=
221 other->svg_inherited_flags.shapeRendering || 213 other->svg_inherited_flags.shapeRendering ||
222 svg_inherited_flags.clipRule != other->svg_inherited_flags.clipRule || 214 svg_inherited_flags.clipRule != other->svg_inherited_flags.clipRule ||
223 svg_inherited_flags.fillRule != other->svg_inherited_flags.fillRule || 215 svg_inherited_flags.fillRule != other->svg_inherited_flags.fillRule ||
224 svg_inherited_flags.colorInterpolation != 216 svg_inherited_flags.colorInterpolation !=
225 other->svg_inherited_flags.colorInterpolation || 217 other->svg_inherited_flags.colorInterpolation ||
226 svg_inherited_flags.colorInterpolationFilters != 218 svg_inherited_flags.colorInterpolationFilters !=
227 other->svg_inherited_flags.colorInterpolationFilters || 219 other->svg_inherited_flags.colorInterpolationFilters)
228 svg_inherited_flags.paintOrder != other->svg_inherited_flags.paintOrder)
229 return true; 220 return true;
230 221
231 if (svg_noninherited_flags.f.bufferedRendering != 222 if (svg_noninherited_flags.f.bufferedRendering !=
232 other->svg_noninherited_flags.f.bufferedRendering) 223 other->svg_noninherited_flags.f.bufferedRendering)
233 return true; 224 return true;
234 225
235 if (svg_noninherited_flags.f.maskType != 226 if (svg_noninherited_flags.f.maskType !=
236 other->svg_noninherited_flags.f.maskType) 227 other->svg_noninherited_flags.f.maskType)
237 return true; 228 return true;
238 229
239 return false; 230 return false;
240 } 231 }
241 232
242 unsigned paintOrderSequence(EPaintOrderType first,
243 EPaintOrderType second,
244 EPaintOrderType third) {
245 return (((third << kPaintOrderBitwidth) | second) << kPaintOrderBitwidth) |
246 first;
247 }
248
249 EPaintOrderType SVGComputedStyle::paintOrderType(unsigned index) const {
250 unsigned pt = 0;
251 ASSERT(index < ((1 << kPaintOrderBitwidth) - 1));
252 switch (this->paintOrder()) {
253 case PaintOrderNormal:
254 case PaintOrderFillStrokeMarkers:
255 pt = paintOrderSequence(PT_FILL, PT_STROKE, PT_MARKERS);
256 break;
257 case PaintOrderFillMarkersStroke:
258 pt = paintOrderSequence(PT_FILL, PT_MARKERS, PT_STROKE);
259 break;
260 case PaintOrderStrokeFillMarkers:
261 pt = paintOrderSequence(PT_STROKE, PT_FILL, PT_MARKERS);
262 break;
263 case PaintOrderStrokeMarkersFill:
264 pt = paintOrderSequence(PT_STROKE, PT_MARKERS, PT_FILL);
265 break;
266 case PaintOrderMarkersFillStroke:
267 pt = paintOrderSequence(PT_MARKERS, PT_FILL, PT_STROKE);
268 break;
269 case PaintOrderMarkersStrokeFill:
270 pt = paintOrderSequence(PT_MARKERS, PT_STROKE, PT_FILL);
271 break;
272 }
273
274 pt =
275 (pt >> (kPaintOrderBitwidth * index)) & ((1u << kPaintOrderBitwidth) - 1);
276 return (EPaintOrderType)pt;
277 }
278
279 } // namespace blink 233 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/SVGComputedStyle.h ('k') | third_party/WebKit/Source/core/style/SVGComputedStyleDefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698