From dc2daaef9e6370a3f7282352eca3f497ce9b1469 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Tue, 30 Sep 2014 18:08:13 +0100 Subject: [PATCH] Bug 1074475 - Fix a bug in GetStrokeDashData. r=longsonr --- content/svg/content/src/SVGContentUtils.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/content/svg/content/src/SVGContentUtils.cpp b/content/svg/content/src/SVGContentUtils.cpp index 65fe81c094a4..9c4e8471f82f 100644 --- a/content/svg/content/src/SVGContentUtils.cpp +++ b/content/svg/content/src/SVGContentUtils.cpp @@ -122,10 +122,21 @@ GetStrokeDashData(SVGContentUtils::AutoStrokeOptions* aStrokeOptions, } } - // Now that aStrokeOptions.mDashPattern is fully initialized we can safely - // set mDashLength: + // Now that aStrokeOptions.mDashPattern is fully initialized (we didn't + // return early above) we can safely set mDashLength: aStrokeOptions->mDashLength = dashArrayLength; + if ((dashArrayLength % 2) == 1) { + // If we have a dash pattern with an odd number of lengths the pattern + // repeats a second time, per the SVG spec., and as implemented by Moz2D. + // When deciding whether to return eNoStroke or eContinuousStroke below we + // need to take into account that in the repeat pattern the dashes become + // gaps, and the gaps become dashes. + Float origTotalLengthOfDashes = totalLengthOfDashes; + totalLengthOfDashes += totalLengthOfGaps; + totalLengthOfGaps += origTotalLengthOfDashes; + } + if (totalLengthOfDashes <= 0 || totalLengthOfGaps <= 0) { if (totalLengthOfGaps > 0 && totalLengthOfDashes <= 0) { return eNoStroke;