LibWeb: Mark canvas element for relayout when width or height changes

While width and height are presentational hints on canvas, they actually
map to the CSS aspect-ratio attribute, not to CSS width and height.
For this reason, we actually need to manually mark for relayout here.

Also import a WPT test that was flaky before this change.
This commit is contained in:
Andreas Kling 2025-05-19 11:04:13 +02:00 committed by Andreas Kling
parent 14d5c638eb
commit 1a055fcb24
Notes: github-actions[bot] 2025-05-19 11:59:00 +00:00
5 changed files with 42 additions and 0 deletions

View file

@ -193,6 +193,8 @@ void HTMLCanvasElement::attribute_changed(FlyString const& local_name, Optional<
if (local_name.equals_ignoring_ascii_case(HTML::AttributeNames::width) || local_name.equals_ignoring_ascii_case(HTML::AttributeNames::height)) {
notify_context_about_canvas_size_change();
reset_context_to_default_state();
if (auto layout_node = this->layout_node())
layout_node->set_needs_layout_update(DOM::SetNeedsLayoutReason::HTMLCanvasElementWidthOrHeightChange);
}
}