From 5f570eddfa914f30495661869d3edf404f6f811e Mon Sep 17 00:00:00 2001 From: Robert Longson Date: Sat, 10 Jan 2015 22:17:57 +0000 Subject: [PATCH] Bug 1117514 - lines with zero length dashes are not rendered. r=jwatt --- dom/svg/SVGContentUtils.cpp | 20 +++++++++++++++---- ...ke-linecap-round-w-zero-length-segs-01.svg | 8 ++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/dom/svg/SVGContentUtils.cpp b/dom/svg/SVGContentUtils.cpp index dee47cb5befb..9fef9b3bb731 100644 --- a/dom/svg/SVGContentUtils.cpp +++ b/dom/svg/SVGContentUtils.cpp @@ -138,12 +138,24 @@ GetStrokeDashData(SVGContentUtils::AutoStrokeOptions* aStrokeOptions, totalLengthOfGaps += origTotalLengthOfDashes; } - if (totalLengthOfDashes <= 0 || totalLengthOfGaps <= 0) { - if (totalLengthOfGaps > 0 && totalLengthOfDashes <= 0) { - return eNoStroke; - } + // Stroking using dashes is much slower than stroking a continuous line + // (see bug 609361 comment 40), and much, much slower than not stroking the + // line at all. Here we check for cases when the dash pattern causes the + // stroke to essentially be continuous or to be nonexistent in which case + // we can avoid expensive stroking operations (the underlying platform + // graphics libraries don't seem to optimize for this). + if (totalLengthOfDashes <= 0 && totalLengthOfGaps <= 0) { + return eNoStroke; + } + if (totalLengthOfGaps <= 0) { return eContinuousStroke; } + // We can only return eNoStroke if the value of stroke-linecap isn't + // adding caps to zero length dashes. + if (totalLengthOfDashes <= 0 && + aStyleSVG->mStrokeLinecap == NS_STYLE_STROKE_LINECAP_BUTT) { + return eNoStroke; + } if (aContextPaint && aStyleSVG->mStrokeDashoffsetFromObject) { aStrokeOptions->mDashOffset = Float(aContextPaint->GetStrokeDashOffset()); diff --git a/layout/reftests/svg/stroke-linecap-round-w-zero-length-segs-01.svg b/layout/reftests/svg/stroke-linecap-round-w-zero-length-segs-01.svg index 19059b6ccfa4..475b536ef4d9 100644 --- a/layout/reftests/svg/stroke-linecap-round-w-zero-length-segs-01.svg +++ b/layout/reftests/svg/stroke-linecap-round-w-zero-length-segs-01.svg @@ -144,4 +144,12 @@ path.coverer { + + + + + + + +