-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As discussed in the github issue, whatwg/html#1079, it's generally agreed to skip drawing line caps for closed paths. This is a follow up cl of: https://chromium-review.googlesource.com/c/chromium/src/+/4864061. In this cl, it verifies if each closed path is empty, then it removes the empty closed subpaths from path. As the subpaths are removed, the corresponding line caps are skipped. Bug: 644067 Change-Id: I14c5c4819a31eb9249d01574ff1b5c60826c3b9e
- Loading branch information
1 parent
32017da
commit ea59111
Showing
21 changed files
with
851 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
html/canvas/element/path-objects/2d.path.stroke.prune.closePath.arc-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.arc</title> | ||
<h1>2d.path.stroke.prune.closePath.arc</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after arc are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.quadraticCurveTo(75, 20, 0, Math.PI); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
</script> |
35 changes: 35 additions & 0 deletions
35
html/canvas/element/path-objects/2d.path.stroke.prune.closePath.arc.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<link rel="match" href="2d.path.stroke.prune.closePath.arc-expected.html"> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.arc</title> | ||
<h1>2d.path.stroke.prune.closePath.arc</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after arc are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.beginPath(); | ||
ctx.moveTo(50, 25); | ||
ctx.lineTo(50, 25); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.quadraticCurveTo(75, 20, 0, Math.PI); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(50, 50); | ||
ctx.lineTo(50, 50); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
</script> |
25 changes: 25 additions & 0 deletions
25
html/canvas/element/path-objects/2d.path.stroke.prune.closePath.bezierCurve-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.bezierCurve</title> | ||
<h1>2d.path.stroke.prune.closePath.bezierCurve</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after bezier curve are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.bezierCurveTo(10, 30, 40, 50, 100, 50); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
</script> |
35 changes: 35 additions & 0 deletions
35
html/canvas/element/path-objects/2d.path.stroke.prune.closePath.bezierCurve.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<link rel="match" href="2d.path.stroke.prune.closePath.bezierCurve-expected.html"> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.bezierCurve</title> | ||
<h1>2d.path.stroke.prune.closePath.bezierCurve</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after bezier curve are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.beginPath(); | ||
ctx.moveTo(50, 25); | ||
ctx.lineTo(50, 25); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.bezierCurveTo(10, 30, 40, 50, 100, 50); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(20, 50); | ||
ctx.lineTo(20, 50); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
</script> |
25 changes: 25 additions & 0 deletions
25
html/canvas/element/path-objects/2d.path.stroke.prune.closePath.line-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.line</title> | ||
<h1>2d.path.stroke.prune.closePath.line</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after line are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.lineTo(40, 40); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
</script> |
35 changes: 35 additions & 0 deletions
35
html/canvas/element/path-objects/2d.path.stroke.prune.closePath.line.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<link rel="match" href="2d.path.stroke.prune.closePath.line-expected.html"> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.line</title> | ||
<h1>2d.path.stroke.prune.closePath.line</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after line are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.beginPath(); | ||
ctx.moveTo(50, 25); | ||
ctx.lineTo(50, 25); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.lineTo(40, 40); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(50, 50); | ||
ctx.lineTo(50, 50); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
</script> |
25 changes: 25 additions & 0 deletions
25
html/canvas/element/path-objects/2d.path.stroke.prune.closePath.quadraticCurve-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.quadraticCurve</title> | ||
<h1>2d.path.stroke.prune.closePath.quadraticCurve</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after quadratic curve are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.quadraticCurveTo(80, 10, 100, 50); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
</script> |
35 changes: 35 additions & 0 deletions
35
html/canvas/element/path-objects/2d.path.stroke.prune.closePath.quadraticCurve.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<link rel="match" href="2d.path.stroke.prune.closePath.quadraticCurve-expected.html"> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.quadraticCurve</title> | ||
<h1>2d.path.stroke.prune.closePath.quadraticCurve</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after quadratic curve are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.beginPath(); | ||
ctx.moveTo(50, 25); | ||
ctx.lineTo(50, 25); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.quadraticCurveTo(80, 10, 100, 50); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(50, 50); | ||
ctx.lineTo(50, 50); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
</script> |
25 changes: 25 additions & 0 deletions
25
html/canvas/offscreen/path-objects/2d.path.stroke.prune.closePath.arc-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.arc</title> | ||
<h1>2d.path.stroke.prune.closePath.arc</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after arc are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.quadraticCurveTo(75, 20, 0, Math.PI); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
</script> |
38 changes: 38 additions & 0 deletions
38
html/canvas/offscreen/path-objects/2d.path.stroke.prune.closePath.arc.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<link rel="match" href="2d.path.stroke.prune.closePath.arc-expected.html"> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.arc</title> | ||
<h1>2d.path.stroke.prune.closePath.arc</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after arc are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script> | ||
const canvas = new OffscreenCanvas(100, 50); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.beginPath(); | ||
ctx.moveTo(50, 25); | ||
ctx.lineTo(50, 25); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.quadraticCurveTo(75, 20, 0, Math.PI); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(50, 50); | ||
ctx.lineTo(50, 50); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
|
||
const outputCanvas = document.getElementById("canvas"); | ||
outputCanvas.getContext('2d').drawImage(canvas, 0, 0); | ||
</script> |
52 changes: 52 additions & 0 deletions
52
html/canvas/offscreen/path-objects/2d.path.stroke.prune.closePath.arc.w.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<html class="reftest-wait"> | ||
<link rel="match" href="2d.path.stroke.prune.closePath.arc-expected.html"> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.arc</title> | ||
<h1>2d.path.stroke.prune.closePath.arc</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after arc are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script id='myWorker' type='text/worker'> | ||
self.onmessage = function(e) { | ||
const canvas = new OffscreenCanvas(100, 50); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.beginPath(); | ||
ctx.moveTo(50, 25); | ||
ctx.lineTo(50, 25); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.quadraticCurveTo(75, 20, 0, Math.PI); | ||
ctx.closePath(); | ||
|
||
ctx.moveTo(50, 50); | ||
ctx.lineTo(50, 50); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
|
||
const bitmap = canvas.transferToImageBitmap(); | ||
self.postMessage(bitmap, bitmap); | ||
}; | ||
</script> | ||
<script> | ||
const blob = new Blob([document.getElementById('myWorker').textContent]); | ||
const worker = new Worker(URL.createObjectURL(blob)); | ||
worker.addEventListener('message', msg => { | ||
const outputCtx = document.getElementById("canvas").getContext('2d'); | ||
outputCtx.drawImage(msg.data, 0, 0); | ||
document.documentElement.classList.remove("reftest-wait"); | ||
}); | ||
worker.postMessage(null); | ||
</script> | ||
</html> |
25 changes: 25 additions & 0 deletions
25
html/canvas/offscreen/path-objects/2d.path.stroke.prune.closePath.bezierCurve-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>Canvas test: 2d.path.stroke.prune.closePath.bezierCurve</title> | ||
<h1>2d.path.stroke.prune.closePath.bezierCurve</h1> | ||
<p class="desc">Test if zero-lengthed closePath before and after bezier curve are ignored corrected.</p> | ||
<canvas id="canvas" width="100" height="50"> | ||
<p class="fallback">FAIL (fallback content)</p> | ||
</canvas> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
ctx.strokeStyle = '#f00'; | ||
ctx.lineWidth = 10; | ||
ctx.lineCap = 'round'; | ||
ctx.lineJoin = 'round'; | ||
|
||
ctx.moveTo(10, 10); | ||
ctx.bezierCurveTo(10, 30, 40, 50, 100, 50); | ||
ctx.closePath(); | ||
ctx.stroke(); | ||
</script> |
Oops, something went wrong.