mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibWeb: Account for paint style and global alpha when drawing shadows
This commit is contained in:
committed by
Jelle Raaijmakers
parent
553a7a9278
commit
b99c0c6a7f
Notes:
github-actions[bot]
2025-10-21 16:57:04 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/b99c0c6a7f2 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6530 Reviewed-by: https://github.com/gmta ✅
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<meta charset="UTF-8">
|
||||
<title>Canvas test: 2d.shadow.alpha.1</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.shadow.alpha.1</h1>
|
||||
<p class="desc">Shadow color alpha components are used</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("Shadow color alpha components are used");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
ctx.shadowColor = 'rgba(255, 0, 0, 0.01)';
|
||||
ctx.shadowOffsetY = 50;
|
||||
ctx.fillRect(0, -50, 100, 50);
|
||||
|
||||
_assertPixelApprox(canvas, 50,25, 0,255,0,255, 4);
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<meta charset="UTF-8">
|
||||
<title>Canvas test: 2d.shadow.alpha.2</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.shadow.alpha.2</h1>
|
||||
<p class="desc">Shadow color alpha components are used</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="2d.shadow.alpha.2.png" class="output expected" id="expected" alt="">
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("Shadow color alpha components are used");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
ctx.shadowColor = 'rgba(0, 0, 255, 0.5)';
|
||||
ctx.shadowOffsetY = 50;
|
||||
ctx.fillRect(0, -50, 100, 50);
|
||||
|
||||
_assertPixelApprox(canvas, 50,25, 127,0,127,255, 2);
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 206 B |
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<meta charset="UTF-8">
|
||||
<title>Canvas test: 2d.shadow.alpha.3</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.shadow.alpha.3</h1>
|
||||
<p class="desc">Shadows are affected by globalAlpha</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="2d.shadow.alpha.3.png" class="output expected" id="expected" alt="">
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("Shadows are affected by globalAlpha");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
ctx.fillStyle = '#f00'; // (work around broken Firefox globalAlpha caching)
|
||||
ctx.shadowColor = '#00f';
|
||||
ctx.shadowOffsetY = 50;
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.fillRect(0, -50, 100, 50);
|
||||
|
||||
_assertPixelApprox(canvas, 50,25, 127,0,127,255, 2);
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 206 B |
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<meta charset="UTF-8">
|
||||
<title>Canvas test: 2d.shadow.alpha.4</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.shadow.alpha.4</h1>
|
||||
<p class="desc">Shadows with alpha components are correctly affected by globalAlpha</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="2d.shadow.alpha.4.png" class="output expected" id="expected" alt="">
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("Shadows with alpha components are correctly affected by globalAlpha");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
ctx.fillStyle = '#f00'; // (work around broken Firefox globalAlpha caching)
|
||||
ctx.shadowColor = 'rgba(0, 0, 255, 0.707)';
|
||||
ctx.shadowOffsetY = 50;
|
||||
ctx.globalAlpha = 0.707;
|
||||
ctx.fillRect(0, -50, 100, 50);
|
||||
|
||||
_assertPixelApprox(canvas, 50,25, 127,0,127,255, 2);
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 206 B |
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<meta charset="UTF-8">
|
||||
<title>Canvas test: 2d.shadow.alpha.5</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.shadow.alpha.5</h1>
|
||||
<p class="desc">Shadows of shapes with alpha components are drawn correctly</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="2d.shadow.alpha.5.png" class="output expected" id="expected" alt="">
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("Shadows of shapes with alpha components are drawn correctly");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
ctx.fillStyle = 'rgba(64, 0, 0, 0.5)';
|
||||
ctx.shadowColor = '#00f';
|
||||
ctx.shadowOffsetY = 50;
|
||||
ctx.fillRect(0, -50, 100, 50);
|
||||
|
||||
_assertPixelApprox(canvas, 50,25, 127,0,127,255, 2);
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 206 B |
Reference in New Issue
Block a user