mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-27 10:29:23 +00:00
LibWeb: Ignore non-finite args in CanvasRenderingContext2D::clear_rect()
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This commit is contained in:
parent
b1801c0bc9
commit
7fb65283c2
Notes:
github-actions[bot]
2025-10-17 16:43:13 +00:00
Author: https://github.com/ljamar
Commit: 7fb65283c2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6454
Reviewed-by: https://github.com/Lubrsi ✅
3 changed files with 63 additions and 0 deletions
|
|
@ -100,8 +100,13 @@ void CanvasRenderingContext2D::fill_rect(float x, float y, float width, float he
|
||||||
fill_internal(rect_path(x, y, width, height), Gfx::WindingRule::EvenOdd);
|
fill_internal(rect_path(x, y, width, height), Gfx::WindingRule::EvenOdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-clearrect
|
||||||
void CanvasRenderingContext2D::clear_rect(float x, float y, float width, float height)
|
void CanvasRenderingContext2D::clear_rect(float x, float y, float width, float height)
|
||||||
{
|
{
|
||||||
|
// 1. If any of the arguments are infinite or NaN, then return.
|
||||||
|
if (!isfinite(x) || !isfinite(y) || !isfinite(width) || !isfinite(height))
|
||||||
|
return;
|
||||||
|
|
||||||
if (auto* painter = this->painter()) {
|
if (auto* painter = this->painter()) {
|
||||||
auto rect = Gfx::FloatRect(x, y, width, height);
|
auto rect = Gfx::FloatRect(x, y, width, height);
|
||||||
painter->clear_rect(rect, clear_color());
|
painter->clear_rect(rect, clear_color());
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
Harness status: OK
|
||||||
|
|
||||||
|
Found 1 tests
|
||||||
|
|
||||||
|
1 Pass
|
||||||
|
Pass clearRect() with Infinity/NaN is ignored
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Canvas test: 2d.clearRect.nonfinite</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.clearRect.nonfinite</h1>
|
||||||
|
<p class="desc">clearRect() with Infinity/NaN is ignored</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p class="output">Actual output:</p>
|
||||||
|
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||||
|
<p class="output expectedtext">Expected output:<p><img src="../../../../images/green-100x50.png" class="output expected" id="expected" alt="">
|
||||||
|
<ul id="d"></ul>
|
||||||
|
<script>
|
||||||
|
var t = async_test("clearRect() with Infinity/NaN is ignored");
|
||||||
|
_addTest(function(canvas, ctx) {
|
||||||
|
|
||||||
|
ctx.fillStyle = '#0f0';
|
||||||
|
ctx.fillRect(0, 0, 100, 50);
|
||||||
|
ctx.clearRect(Infinity, 0, 100, 50);
|
||||||
|
ctx.clearRect(-Infinity, 0, 100, 50);
|
||||||
|
ctx.clearRect(NaN, 0, 100, 50);
|
||||||
|
ctx.clearRect(0, Infinity, 100, 50);
|
||||||
|
ctx.clearRect(0, -Infinity, 100, 50);
|
||||||
|
ctx.clearRect(0, NaN, 100, 50);
|
||||||
|
ctx.clearRect(0, 0, Infinity, 50);
|
||||||
|
ctx.clearRect(0, 0, -Infinity, 50);
|
||||||
|
ctx.clearRect(0, 0, NaN, 50);
|
||||||
|
ctx.clearRect(0, 0, 100, Infinity);
|
||||||
|
ctx.clearRect(0, 0, 100, -Infinity);
|
||||||
|
ctx.clearRect(0, 0, 100, NaN);
|
||||||
|
ctx.clearRect(Infinity, Infinity, 100, 50);
|
||||||
|
ctx.clearRect(Infinity, Infinity, Infinity, 50);
|
||||||
|
ctx.clearRect(Infinity, Infinity, Infinity, Infinity);
|
||||||
|
ctx.clearRect(Infinity, Infinity, 100, Infinity);
|
||||||
|
ctx.clearRect(Infinity, 0, Infinity, 50);
|
||||||
|
ctx.clearRect(Infinity, 0, Infinity, Infinity);
|
||||||
|
ctx.clearRect(Infinity, 0, 100, Infinity);
|
||||||
|
ctx.clearRect(0, Infinity, Infinity, 50);
|
||||||
|
ctx.clearRect(0, Infinity, Infinity, Infinity);
|
||||||
|
ctx.clearRect(0, Infinity, 100, Infinity);
|
||||||
|
ctx.clearRect(0, 0, Infinity, Infinity);
|
||||||
|
_assertPixel(canvas, 50,25, 0,255,0,255);
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue