LibWeb: Do nothing when calling CanvasPath.closePath() with empty path
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:
Tim Ledbetter 2025-09-06 02:20:48 +01:00 committed by Tim Flynn
commit 3c6472dc00
Notes: github-actions[bot] 2025-09-06 12:48:46 +00:00
3 changed files with 31 additions and 0 deletions

View file

@ -23,8 +23,14 @@ void CanvasPath::ensure_subpath(float x, float y)
m_path.move_to(Gfx::FloatPoint { x, y });
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-closepath
void CanvasPath::close_path()
{
// The closePath() method, when invoked, must do nothing if the object's path has no subpaths. Otherwise, it must
// mark the last subpath as closed, create a new subpath whose first point is the same as the previous subpath's
// first point, and finally add this new subpath to the path.
if (m_path.is_empty())
return;
m_path.close();
}