mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Ignore non-finite args in CanvasRenderingContext2D::clear_rect()
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);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-clearrect
|
||||
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()) {
|
||||
auto rect = Gfx::FloatRect(x, y, width, height);
|
||||
painter->clear_rect(rect, clear_color());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue