Skip to content

Commit

Permalink
Use DOMPointInit for roundRect
Browse files Browse the repository at this point in the history
This is what we decided on in the spec debate.
whatwg/html#6765

Bug: 1193694
Change-Id: Ic24a8cf9ec61ab584318a40660c0c0e06a0b9848
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3016815
Commit-Queue: Aaron Krajeski <[email protected]>
Reviewed-by: Justin Novosad <[email protected]>
Cr-Commit-Position: refs/heads/master@{#899818}
  • Loading branch information
mysteryDate authored and chromium-wpt-export-bot committed Jul 9, 2021
1 parent 5d10b8c commit 84dcb62
Show file tree
Hide file tree
Showing 32 changed files with 1,770 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>Canvas test: 2d.path.roundrect.1.radius.dompointinit</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<body class="show_output">

<h1>2d.path.roundrect.1.radius.dompointinit</h1>
<p class="desc">Verify that when two radii are given to roundRect(), the first radius, specified as a DOMPointInit, applies to the top-left and bottom-left corners.</p>


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("Verify that when two radii are given to roundRect(), the first radius, specified as a DOMPointInit, applies to the top-left and bottom-left corners.");
_addTest(function(canvas, ctx) {

ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.roundRect(0, 0, 100, 50, [{x: 40, y: 20}]);
ctx.fillStyle = '#0f0';
ctx.fill();

// top-left corner
_assertPixel(canvas, 20,1, 255,0,0,255, "20,1", "255,0,0,255");
_assertPixel(canvas, 41,1, 0,255,0,255, "41,1", "0,255,0,255");
_assertPixel(canvas, 1,10, 255,0,0,255, "1,10", "255,0,0,255");
_assertPixel(canvas, 1,21, 0,255,0,255, "1,21", "0,255,0,255");

// top-right corner
_assertPixel(canvas, 79,1, 255,0,0,255, "79,1", "255,0,0,255");
_assertPixel(canvas, 58,1, 0,255,0,255, "58,1", "0,255,0,255");
_assertPixel(canvas, 98,10, 255,0,0,255, "98,10", "255,0,0,255");
_assertPixel(canvas, 98,21, 0,255,0,255, "98,21", "0,255,0,255");

// bottom-right corner
_assertPixel(canvas, 79,48, 255,0,0,255, "79,48", "255,0,0,255");
_assertPixel(canvas, 58,48, 0,255,0,255, "58,48", "0,255,0,255");
_assertPixel(canvas, 98,39, 255,0,0,255, "98,39", "255,0,0,255");
_assertPixel(canvas, 98,28, 0,255,0,255, "98,28", "0,255,0,255");

// bottom-left corner
_assertPixel(canvas, 20,48, 255,0,0,255, "20,48", "255,0,0,255");
_assertPixel(canvas, 41,48, 0,255,0,255, "41,48", "0,255,0,255");
_assertPixel(canvas, 1,39, 255,0,0,255, "1,39", "255,0,0,255");
_assertPixel(canvas, 1,28, 0,255,0,255, "1,28", "0,255,0,255");


});
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>Canvas test: 2d.path.roundrect.2.radii.1.dompointinit</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<body class="show_output">

<h1>2d.path.roundrect.2.radii.1.dompointinit</h1>
<p class="desc">Verify that when two radii are given to roundRect(), the first radius, specified as a DOMPointInit, applies to the top-left and bottom-right corners.</p>


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("Verify that when two radii are given to roundRect(), the first radius, specified as a DOMPointInit, applies to the top-left and bottom-right corners.");
_addTest(function(canvas, ctx) {

ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.roundRect(0, 0, 100, 50, [{x: 40, y: 20}, 0]);
ctx.fillStyle = '#0f0';
ctx.fill();

// top-left corner
_assertPixel(canvas, 20,1, 255,0,0,255, "20,1", "255,0,0,255");
_assertPixel(canvas, 41,1, 0,255,0,255, "41,1", "0,255,0,255");
_assertPixel(canvas, 1,10, 255,0,0,255, "1,10", "255,0,0,255");
_assertPixel(canvas, 1,21, 0,255,0,255, "1,21", "0,255,0,255");

// bottom-right corner
_assertPixel(canvas, 79,48, 255,0,0,255, "79,48", "255,0,0,255");
_assertPixel(canvas, 58,48, 0,255,0,255, "58,48", "0,255,0,255");
_assertPixel(canvas, 98,39, 255,0,0,255, "98,39", "255,0,0,255");
_assertPixel(canvas, 98,28, 0,255,0,255, "98,28", "0,255,0,255");

// other corners
_assertPixel(canvas, 98,1, 0,255,0,255, "98,1", "0,255,0,255");
_assertPixel(canvas, 1,48, 0,255,0,255, "1,48", "0,255,0,255");


});
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>Canvas test: 2d.path.roundrect.2.radii.2.dompointinit</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<body class="show_output">

<h1>2d.path.roundrect.2.radii.2.dompointinit</h1>
<p class="desc">Verify that when two radii are given to roundRect(), the second radius, specified as a DOMPointInit, applies to the top-right and bottom-left corners.</p>


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("Verify that when two radii are given to roundRect(), the second radius, specified as a DOMPointInit, applies to the top-right and bottom-left corners.");
_addTest(function(canvas, ctx) {

ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.roundRect(0, 0, 100, 50, [0, {x: 40, y: 20}]);
ctx.fillStyle = '#0f0';
ctx.fill();

// top-right corner
_assertPixel(canvas, 79,1, 255,0,0,255, "79,1", "255,0,0,255");
_assertPixel(canvas, 58,1, 0,255,0,255, "58,1", "0,255,0,255");
_assertPixel(canvas, 98,10, 255,0,0,255, "98,10", "255,0,0,255");
_assertPixel(canvas, 98,21, 0,255,0,255, "98,21", "0,255,0,255");

// bottom-left corner
_assertPixel(canvas, 20,48, 255,0,0,255, "20,48", "255,0,0,255");
_assertPixel(canvas, 41,48, 0,255,0,255, "41,48", "0,255,0,255");
_assertPixel(canvas, 1,39, 255,0,0,255, "1,39", "255,0,0,255");
_assertPixel(canvas, 1,28, 0,255,0,255, "1,28", "0,255,0,255");

// other corners
_assertPixel(canvas, 1,1, 0,255,0,255, "1,1", "0,255,0,255");
_assertPixel(canvas, 98,48, 0,255,0,255, "98,48", "0,255,0,255");


});
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>Canvas test: 2d.path.roundrect.3.radii.1.dompointinit</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<body class="show_output">

<h1>2d.path.roundrect.3.radii.1.dompointinit</h1>
<p class="desc">Verify that when three radii are given to roundRect(), the first radius, specified as a DOMPointInit, applies to the top-left corner.</p>


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("Verify that when three radii are given to roundRect(), the first radius, specified as a DOMPointInit, applies to the top-left corner.");
_addTest(function(canvas, ctx) {

ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.roundRect(0, 0, 100, 50, [{x: 40, y: 20}, 0, 0]);
ctx.fillStyle = '#0f0';
ctx.fill();

// top-left corner
_assertPixel(canvas, 20,1, 255,0,0,255, "20,1", "255,0,0,255");
_assertPixel(canvas, 41,1, 0,255,0,255, "41,1", "0,255,0,255");
_assertPixel(canvas, 1,10, 255,0,0,255, "1,10", "255,0,0,255");
_assertPixel(canvas, 1,21, 0,255,0,255, "1,21", "0,255,0,255");

// other corners
_assertPixel(canvas, 98,1, 0,255,0,255, "98,1", "0,255,0,255");
_assertPixel(canvas, 98,48, 0,255,0,255, "98,48", "0,255,0,255");
_assertPixel(canvas, 1,48, 0,255,0,255, "1,48", "0,255,0,255");


});
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>Canvas test: 2d.path.roundrect.3.radii.2.dompointinit</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<body class="show_output">

<h1>2d.path.roundrect.3.radii.2.dompointinit</h1>
<p class="desc">Verify that when three radii are given to roundRect(), the second radius, specified as a DOMPoint, applies to the top-right and bottom-left corners.</p>


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("Verify that when three radii are given to roundRect(), the second radius, specified as a DOMPoint, applies to the top-right and bottom-left corners.");
_addTest(function(canvas, ctx) {

ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.roundRect(0, 0, 100, 50, [0, {x: 40, y: 20}, 0]);
ctx.fillStyle = '#0f0';
ctx.fill();

// top-right corner
_assertPixel(canvas, 79,1, 255,0,0,255, "79,1", "255,0,0,255");
_assertPixel(canvas, 58,1, 0,255,0,255, "58,1", "0,255,0,255");
_assertPixel(canvas, 98,10, 255,0,0,255, "98,10", "255,0,0,255");
_assertPixel(canvas, 98,21, 0,255,0,255, "98,21", "0,255,0,255");

// bottom-left corner
_assertPixel(canvas, 20,48, 255,0,0,255, "20,48", "255,0,0,255");
_assertPixel(canvas, 41,48, 0,255,0,255, "41,48", "0,255,0,255");
_assertPixel(canvas, 1,39, 255,0,0,255, "1,39", "255,0,0,255");
_assertPixel(canvas, 1,28, 0,255,0,255, "1,28", "0,255,0,255");

// other corners
_assertPixel(canvas, 1,1, 0,255,0,255, "1,1", "0,255,0,255");
_assertPixel(canvas, 98,48, 0,255,0,255, "98,48", "0,255,0,255");


});
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>Canvas test: 2d.path.roundrect.3.radii.3.dompointinit</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<body class="show_output">

<h1>2d.path.roundrect.3.radii.3.dompointinit</h1>
<p class="desc">Verify that when three radii are given to roundRect(), the third radius, specified as a DOMPointInit, applies to the bottom-right corner.</p>


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("Verify that when three radii are given to roundRect(), the third radius, specified as a DOMPointInit, applies to the bottom-right corner.");
_addTest(function(canvas, ctx) {

ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.roundRect(0, 0, 100, 50, [0, 0, {x: 40, y: 20}]);
ctx.fillStyle = '#0f0';
ctx.fill();

// bottom-right corner
_assertPixel(canvas, 79,48, 255,0,0,255, "79,48", "255,0,0,255");
_assertPixel(canvas, 58,48, 0,255,0,255, "58,48", "0,255,0,255");
_assertPixel(canvas, 98,39, 255,0,0,255, "98,39", "255,0,0,255");
_assertPixel(canvas, 98,28, 0,255,0,255, "98,28", "0,255,0,255");

// other corners
_assertPixel(canvas, 1,1, 0,255,0,255, "1,1", "0,255,0,255");
_assertPixel(canvas, 98,1, 0,255,0,255, "98,1", "0,255,0,255");
_assertPixel(canvas, 1,48, 0,255,0,255, "1,48", "0,255,0,255");


});
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>Canvas test: 2d.path.roundrect.4.radii.1.dompointinit</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<body class="show_output">

<h1>2d.path.roundrect.4.radii.1.dompointinit</h1>
<p class="desc">Verify that when four radii are given to roundRect(), the first radius, specified as a DOMPointInit, applies to the top-left corner.</p>


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("Verify that when four radii are given to roundRect(), the first radius, specified as a DOMPointInit, applies to the top-left corner.");
_addTest(function(canvas, ctx) {

ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.roundRect(0, 0, 100, 50, [{x: 40, y: 20}, 0, 0, 0]);
ctx.fillStyle = '#0f0';
ctx.fill();

// top-left corner
_assertPixel(canvas, 20,1, 255,0,0,255, "20,1", "255,0,0,255");
_assertPixel(canvas, 41,1, 0,255,0,255, "41,1", "0,255,0,255");
_assertPixel(canvas, 1,10, 255,0,0,255, "1,10", "255,0,0,255");
_assertPixel(canvas, 1,21, 0,255,0,255, "1,21", "0,255,0,255");

// other corners
_assertPixel(canvas, 98,1, 0,255,0,255, "98,1", "0,255,0,255");
_assertPixel(canvas, 98,48, 0,255,0,255, "98,48", "0,255,0,255");
_assertPixel(canvas, 1,48, 0,255,0,255, "1,48", "0,255,0,255");


});
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>Canvas test: 2d.path.roundrect.4.radii.2.dompointinit</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<body class="show_output">

<h1>2d.path.roundrect.4.radii.2.dompointinit</h1>
<p class="desc">Verify that when four radii are given to roundRect(), the second radius, specified as a DOMPointInit, applies to the top-right corner.</p>


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("Verify that when four radii are given to roundRect(), the second radius, specified as a DOMPointInit, applies to the top-right corner.");
_addTest(function(canvas, ctx) {

ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.roundRect(0, 0, 100, 50, [0, {x: 40, y: 20}, 0, 0]);
ctx.fillStyle = '#0f0';
ctx.fill();

// top-right corner
_assertPixel(canvas, 79,1, 255,0,0,255, "79,1", "255,0,0,255");
_assertPixel(canvas, 58,1, 0,255,0,255, "58,1", "0,255,0,255");
_assertPixel(canvas, 98,10, 255,0,0,255, "98,10", "255,0,0,255");
_assertPixel(canvas, 98,21, 0,255,0,255, "98,21", "0,255,0,255");

// other corners
_assertPixel(canvas, 1,1, 0,255,0,255, "1,1", "0,255,0,255");
_assertPixel(canvas, 98,48, 0,255,0,255, "98,48", "0,255,0,255");
_assertPixel(canvas, 1,48, 0,255,0,255, "1,48", "0,255,0,255");


});
</script>

Loading

0 comments on commit 84dcb62

Please sign in to comment.