<Error>: CGContextSetLineDash: invalid dash array: at least one element must be non...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Oct 2016 23:02:04 +0000 (23:02 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Oct 2016 23:02:04 +0000 (23:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138555

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2016-10-10
Reviewed by Simon Fraser.

Ensure the dashArray has at least one non-zero element before calling
GraphicsContext::setLineDash(). Call GraphicsContext::setStrokeStyle()
instead, if the dashArray does not have one.

* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::applyStrokeStyleToContext):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207030 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/SVGRenderSupport.cpp

index 8d8a21b..e0b8300 100644 (file)
@@ -1,3 +1,17 @@
+2016-10-10  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        <Error>: CGContextSetLineDash: invalid dash array: at least one element must be non-zero
+        https://bugs.webkit.org/show_bug.cgi?id=138555
+
+        Reviewed by Simon Fraser.
+
+        Ensure the dashArray has at least one non-zero element before calling
+        GraphicsContext::setLineDash(). Call GraphicsContext::setStrokeStyle()
+        instead, if the dashArray does not have one.
+
+        * rendering/svg/SVGRenderSupport.cpp:
+        (WebCore::SVGRenderSupport::applyStrokeStyleToContext):
+
 2016-10-10  Brent Fulgham  <bfulgham@apple.com>
 
         [Win][Direct2D] Correct Radial Graident Bug
index 5b25a37..4c7dcc2 100644 (file)
@@ -439,10 +439,18 @@ void SVGRenderSupport::applyStrokeStyleToContext(GraphicsContext* context, const
     else {
         DashArray dashArray;
         dashArray.reserveInitialCapacity(dashes.size());
-        for (auto& dash : dashes)
+        bool canSetLineDash = false;
+
+        for (auto& dash : dashes) {
             dashArray.uncheckedAppend(dash.value(lengthContext));
+            if (dashArray.last() > 0)
+                canSetLineDash = true;
+        }
 
-        context->setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeDashOffset()));
+        if (canSetLineDash)
+            context->setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeDashOffset()));
+        else
+            context->setStrokeStyle(SolidStroke);
     }
 }