From 111153a6a1a07f81843be06af305be197e2fdf4a Mon Sep 17 00:00:00 2001 From: Yi Xu Date: Fri, 6 Oct 2023 13:21:55 -0700 Subject: [PATCH] Skip line caps for closed ellipse paths As discussed in the github issue, https://github.com/whatwg/html/issues/1079, it's generally agreed to skip drawing line caps for closed paths. Add test cases for full ellipse path. Bug: 644067 Change-Id: I3fde274f4b15a96d4ecaa593b0317c585eeb4a25 --- .../2d.path.stroke.prune.ellipse.html | 38 ++++++++++++++++++ .../2d.path.stroke.prune.ellipse.html | 39 +++++++++++++++++++ .../2d.path.stroke.prune.ellipse.worker.js | 34 ++++++++++++++++ html/canvas/tools/yaml-new/path-objects.yaml | 17 ++++++++ 4 files changed, 128 insertions(+) create mode 100644 html/canvas/element/path-objects/2d.path.stroke.prune.ellipse.html create mode 100644 html/canvas/offscreen/path-objects/2d.path.stroke.prune.ellipse.html create mode 100644 html/canvas/offscreen/path-objects/2d.path.stroke.prune.ellipse.worker.js diff --git a/html/canvas/element/path-objects/2d.path.stroke.prune.ellipse.html b/html/canvas/element/path-objects/2d.path.stroke.prune.ellipse.html new file mode 100644 index 000000000000000..d55507935d24595 --- /dev/null +++ b/html/canvas/element/path-objects/2d.path.stroke.prune.ellipse.html @@ -0,0 +1,38 @@ + + +Canvas test: 2d.path.stroke.prune.ellipse + + + + + + +

2d.path.stroke.prune.ellipse

+

Zero-length full ellipse are removed before stroking with miters

+ + +

Actual output:

+

FAIL (fallback content)

+

Expected output:

+

+ + diff --git a/html/canvas/offscreen/path-objects/2d.path.stroke.prune.ellipse.html b/html/canvas/offscreen/path-objects/2d.path.stroke.prune.ellipse.html new file mode 100644 index 000000000000000..5eea85482453b97 --- /dev/null +++ b/html/canvas/offscreen/path-objects/2d.path.stroke.prune.ellipse.html @@ -0,0 +1,39 @@ + + +OffscreenCanvas test: 2d.path.stroke.prune.ellipse + + + + +

2d.path.stroke.prune.ellipse

+

Zero-length full ellipse are removed before stroking with miters

+ + + diff --git a/html/canvas/offscreen/path-objects/2d.path.stroke.prune.ellipse.worker.js b/html/canvas/offscreen/path-objects/2d.path.stroke.prune.ellipse.worker.js new file mode 100644 index 000000000000000..a1fbabdebadba4d --- /dev/null +++ b/html/canvas/offscreen/path-objects/2d.path.stroke.prune.ellipse.worker.js @@ -0,0 +1,34 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.path.stroke.prune.ellipse +// Description:Zero-length full ellipse are removed before stroking with miters +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Zero-length full ellipse are removed before stroking with miters"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + + var canvas = new OffscreenCanvas(100, 50); + var ctx = canvas.getContext('2d'); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.ellipse(25, 25, 0, 0, 0, 0, 2 * Math.PI); + ctx.stroke(); + + _assertPixel(canvas, 50,25, 0,255,0,255); + t.done(); +}); +done(); diff --git a/html/canvas/tools/yaml-new/path-objects.yaml b/html/canvas/tools/yaml-new/path-objects.yaml index eec142c7692bc5f..fab92b930cfc265 100644 --- a/html/canvas/tools/yaml-new/path-objects.yaml +++ b/html/canvas/tools/yaml-new/path-objects.yaml @@ -2853,6 +2853,23 @@ @assert pixel 50,25 == 0,255,0,255; expected: green +- name: 2d.path.stroke.prune.ellipse + desc: Zero-length full ellipse are removed before stroking with miters + code: | + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.ellipse(25, 25, 0, 0, 0, 0, 2 * Math.PI); + ctx.stroke(); + + @assert pixel 50,25 == 0,255,0,255; + expected: green - name: 2d.path.transformation.basic code: |