Title: [187859] releases/WebKitGTK/webkit-2.8
Revision
187859
Author
[email protected]
Date
2015-08-04 06:26:32 -0700 (Tue, 04 Aug 2015)

Log Message

Merge r187171 - [WinCairo] SVG path not rendered with all-zero dasharray
https://bugs.webkit.org/show_bug.cgi?id=146997

Patch by Jinyoung Hur <[email protected]> on 2015-07-22
Reviewed by Martin Robinson.

Source/WebCore:

All-zero dash array should not be passed to cairo_set_dash() as an argument, because it will cause an internal Cairo error.
Rather call cairo_set_dash() with num_dashes=0 to disable dash line.

Tests: fast/canvas/canvas-lineDash.html
       svg/custom/zero-dasharray.html

* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::setLineDash):

LayoutTests:

Canvas 2D context and SVG stroke tests with all-zero dash array are added.

* fast/canvas/canvas-lineDash-expected.txt:
* fast/canvas/script-tests/canvas-lineDash.js:
* svg/custom/zero-dasharray.html: Added
* svg/custom/zero-dasharray-expected.html: Added

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.8/LayoutTests/ChangeLog (187858 => 187859)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/ChangeLog	2015-08-04 13:24:06 UTC (rev 187858)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/ChangeLog	2015-08-04 13:26:32 UTC (rev 187859)
@@ -1,3 +1,17 @@
+2015-07-22  Jinyoung Hur  <[email protected]>
+
+        [WinCairo] SVG path not rendered with all-zero dasharray
+        https://bugs.webkit.org/show_bug.cgi?id=146997
+
+        Reviewed by Martin Robinson.
+
+        Canvas 2D context and SVG stroke tests with all-zero dash array are added.
+
+        * fast/canvas/canvas-lineDash-expected.txt:
+        * fast/canvas/script-tests/canvas-lineDash.js:
+        * svg/custom/zero-dasharray.html: Added
+        * svg/custom/zero-dasharray-expected.html: Added
+
 2015-07-22  Mark Dittmer  <[email protected]>
 
         New test: Object.create(window).location will trigger a crash when toJSDOMWindow() returns NULL on an object that have the JS DOM Window in its prototype chain.

Modified: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/canvas/canvas-lineDash-expected.txt (187858 => 187859)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/canvas/canvas-lineDash-expected.txt	2015-08-04 13:24:06 UTC (rev 187858)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/canvas/canvas-lineDash-expected.txt	2015-08-04 13:26:32 UTC (rev 187859)
@@ -40,6 +40,14 @@
 PASS getPixel(105,40) is [0,255,0,255]
 PASS getPixel(90,35) is [0,0,0,0]
 PASS getPixel(90,25) is [0,255,0,255]
+PASS getPixel(145,10) is [0,255,0,255]
+PASS getPixel(155,10) is [0,255,0,255]
+PASS getPixel(160,25) is [0,255,0,255]
+PASS getPixel(160,35) is [0,255,0,255]
+PASS getPixel(145,40) is [0,255,0,255]
+PASS getPixel(135,40) is [0,255,0,255]
+PASS getPixel(130,25) is [0,255,0,255]
+PASS getPixel(130,15) is [0,255,0,255]
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/canvas/script-tests/canvas-lineDash.js (187858 => 187859)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/canvas/script-tests/canvas-lineDash.js	2015-08-04 13:24:06 UTC (rev 187858)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/canvas/script-tests/canvas-lineDash.js	2015-08-04 13:26:32 UTC (rev 187859)
@@ -104,3 +104,18 @@
 pixelShouldBe(90, 35, [0, 0, 0, 0]);
 pixelShouldBe(90, 25, [0, 255, 0, 255]);
 
+// Verify all-zero dash rendering.
+ctx.setLineDash([0, 0]);
+ctx.lineDashOffset = 0;
+ctx.lineWidth = 4; // To make the test immune to plaform anti-aliasing discrepancies.
+ctx.strokeStyle = '#00FF00';
+ctx.strokeRect(130.5, 10.5, 30, 30);
+
+pixelShouldBe(145, 10, [0, 255, 0, 255]);
+pixelShouldBe(155, 10, [0, 255, 0, 255]);
+pixelShouldBe(160, 25, [0, 255, 0, 255]);
+pixelShouldBe(160, 35, [0, 255, 0, 255]);
+pixelShouldBe(145, 40, [0, 255, 0, 255]);
+pixelShouldBe(135, 40, [0, 255, 0, 255]);
+pixelShouldBe(130, 25, [0, 255, 0, 255]);
+pixelShouldBe(130, 15, [0, 255, 0, 255]);

Added: releases/WebKitGTK/webkit-2.8/LayoutTests/svg/custom/zero-dasharray-expected.html (0 => 187859)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/svg/custom/zero-dasharray-expected.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/svg/custom/zero-dasharray-expected.html	2015-08-04 13:26:32 UTC (rev 187859)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
+        <rect id="rect" fill="none" stroke="green" stroke-width="10" stroke-dasharray:none width="100" height="100"/>
+    </svg>
+  </body>
+</html>
\ No newline at end of file

Added: releases/WebKitGTK/webkit-2.8/LayoutTests/svg/custom/zero-dasharray.html (0 => 187859)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/svg/custom/zero-dasharray.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/svg/custom/zero-dasharray.html	2015-08-04 13:26:32 UTC (rev 187859)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
+        <rect id="rect" fill="none" stroke="green" stroke-width="10" stroke-dasharray="0" width="100" height="100"/>
+    </svg>
+  </body>
+</html>
\ No newline at end of file

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog (187858 => 187859)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog	2015-08-04 13:24:06 UTC (rev 187858)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog	2015-08-04 13:26:32 UTC (rev 187859)
@@ -1,3 +1,19 @@
+2015-07-22  Jinyoung Hur  <[email protected]>
+
+        [WinCairo] SVG path not rendered with all-zero dasharray
+        https://bugs.webkit.org/show_bug.cgi?id=146997
+
+        Reviewed by Martin Robinson.
+
+        All-zero dash array should not be passed to cairo_set_dash() as an argument, because it will cause an internal Cairo error.
+        Rather call cairo_set_dash() with num_dashes=0 to disable dash line.
+
+        Tests: fast/canvas/canvas-lineDash.html
+               svg/custom/zero-dasharray.html
+
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::setLineDash):
+
 2015-07-22  Mark Dittmer  <[email protected]>
 
         Fix toJSDOMWindow() in the case of an object that has the actual JS DOM window in its prototype chain.

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (187858 => 187859)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	2015-08-04 13:24:06 UTC (rev 187858)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	2015-08-04 13:26:32 UTC (rev 187859)
@@ -895,9 +895,21 @@
     cairo_set_line_cap(platformContext()->cr(), cairoCap);
 }
 
+static inline bool isDashArrayAllZero(const DashArray& dashes)
+{
+    for (auto& dash : dashes) {
+        if (dash)
+            return false;
+    }
+    return true;
+}
+
 void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
 {
-    cairo_set_dash(platformContext()->cr(), dashes.data(), dashes.size(), dashOffset);
+    if (isDashArrayAllZero(dashes))
+        cairo_set_dash(platformContext()->cr(), 0, 0, 0);
+    else
+        cairo_set_dash(platformContext()->cr(), dashes.data(), dashes.size(), dashOffset);
 }
 
 void GraphicsContext::setLineJoin(LineJoin lineJoin)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to