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

Side by Side Diff: Source/core/rendering/svg/RenderSVGShape.cpp

Issue 261773008: [SVG2] css 'outline' property should apply to svg elements (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: moar tests Created 6 years, 7 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 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> 8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com>
9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> 9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
10 * Copyright (C) 2011 University of Szeged 10 * Copyright (C) 2011 University of Szeged
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::s haredSolidPaintingResource(); 228 RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::s haredSolidPaintingResource();
229 if (fallbackResource->applyResource(this, style, context, ApplyToStr okeMode)) 229 if (fallbackResource->applyResource(this, style, context, ApplyToStr okeMode))
230 fallbackResource->postApplyResource(this, context, ApplyToStroke Mode, 0, this); 230 fallbackResource->postApplyResource(this, context, ApplyToStroke Mode, 0, this);
231 } 231 }
232 } 232 }
233 } 233 }
234 234
235 void RenderSVGShape::paint(PaintInfo& paintInfo, const LayoutPoint&) 235 void RenderSVGShape::paint(PaintInfo& paintInfo, const LayoutPoint&)
236 { 236 {
237 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); 237 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this);
238 if (paintInfo.context->paintingDisabled()
239 || paintInfo.phase != PaintPhaseForeground
240 || style()->visibility() == HIDDEN
241 || isShapeEmpty())
242 return;
238 243
239 if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || isShapeEmpty())
240 return;
241 FloatRect boundingBox = repaintRectInLocalCoordinates(); 244 FloatRect boundingBox = repaintRectInLocalCoordinates();
242 if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTr ansform, paintInfo)) 245 if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTr ansform, paintInfo))
243 return; 246 return;
244 247
245 PaintInfo childPaintInfo(paintInfo); 248 PaintInfo childPaintInfo(paintInfo);
246 bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == Pain tPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline);
247 if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) {
248 GraphicsContextStateSaver stateSaver(*childPaintInfo.context);
249 childPaintInfo.applyTransform(m_localTransform);
250 249
251 if (childPaintInfo.phase == PaintPhaseForeground) { 250 GraphicsContextStateSaver stateSaver(*childPaintInfo.context);
252 SVGRenderingContext renderingContext(this, childPaintInfo); 251 childPaintInfo.applyTransform(m_localTransform);
253 252
254 if (renderingContext.isRenderingPrepared()) { 253 SVGRenderingContext renderingContext(this, childPaintInfo);
255 const SVGRenderStyle* svgStyle = style()->svgStyle();
256 if (svgStyle->shapeRendering() == SR_CRISPEDGES)
257 childPaintInfo.context->setShouldAntialias(false);
258 254
259 for (int i = 0; i < 3; i++) { 255 if (renderingContext.isRenderingPrepared()) {
260 switch (svgStyle->paintOrderType(i)) { 256 const SVGRenderStyle* svgStyle = style()->svgStyle();
261 case PT_FILL: 257 if (svgStyle->shapeRendering() == SR_CRISPEDGES)
262 fillShape(this->style(), childPaintInfo.context); 258 childPaintInfo.context->setShouldAntialias(false);
263 break;
264 case PT_STROKE:
265 if (svgStyle->hasVisibleStroke()) {
266 GraphicsContextStateSaver stateSaver(*childPaintInfo .context, false);
267 AffineTransform nonScalingTransform;
268 259
269 if (hasNonScalingStroke()) { 260 for (int i = 0; i < 3; i++) {
270 AffineTransform nonScalingTransform = nonScaling StrokeTransform(); 261 switch (svgStyle->paintOrderType(i)) {
271 if (!setupNonScalingStrokeContext(nonScalingTran sform, stateSaver)) 262 case PT_FILL:
272 return; 263 fillShape(this->style(), childPaintInfo.context);
273 } 264 break;
265 case PT_STROKE:
266 if (svgStyle->hasVisibleStroke()) {
267 GraphicsContextStateSaver stateSaver(*childPaintInfo.context , false);
268 AffineTransform nonScalingTransform;
274 269
275 strokeShape(this->style(), childPaintInfo.context); 270 if (hasNonScalingStroke()) {
276 } 271 AffineTransform nonScalingTransform = nonScalingStrokeTr ansform();
277 break; 272 if (!setupNonScalingStrokeContext(nonScalingTransform, s tateSaver))
278 case PT_MARKERS: 273 return;
279 if (!m_markerPositions.isEmpty())
280 drawMarkers(childPaintInfo);
281 break;
282 default:
283 ASSERT_NOT_REACHED();
284 break;
285 } 274 }
275
276 strokeShape(this->style(), childPaintInfo.context);
286 } 277 }
278 break;
279 case PT_MARKERS:
280 if (!m_markerPositions.isEmpty())
281 drawMarkers(childPaintInfo);
282 break;
283 default:
284 ASSERT_NOT_REACHED();
285 break;
287 } 286 }
288 } 287 }
288 }
289 289
290 if (drawsOutline) 290 if (style()->outlineWidth())
291 paintOutline(childPaintInfo, IntRect(boundingBox)); 291 paintOutline(childPaintInfo, IntRect(boundingBox));
292 }
293 } 292 }
294 293
295 // This method is called from inside paintOutline() since we call paintOutline() 294 // This method is called from inside paintOutline() since we call paintOutline()
296 // while transformed to our coord system, return local coords 295 // while transformed to our coord system, return local coords
297 void RenderSVGShape::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint &, const RenderLayerModelObject*) 296 void RenderSVGShape::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint &, const RenderLayerModelObject*)
298 { 297 {
299 IntRect rect = enclosingIntRect(repaintRectInLocalCoordinates()); 298 IntRect rect = enclosingIntRect(repaintRectInLocalCoordinates());
300 if (!rect.isEmpty()) 299 if (!rect.isEmpty())
301 rects.append(rect); 300 rects.append(rect);
302 } 301 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 return; 457 return;
459 458
460 ASSERT(m_path); 459 ASSERT(m_path);
461 460
462 SVGMarkerData markerData(m_markerPositions); 461 SVGMarkerData markerData(m_markerPositions);
463 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement); 462 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement);
464 markerData.pathIsDone(); 463 markerData.pathIsDone();
465 } 464 }
466 465
467 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698