LibWeb: Use correct root element when resolving paint properties

Previously, the first `HTMLHtmlELement` in the given document would
always be  used when determining whether to propagate background
properties to the body element. This meant the wrong root element was
used for SVG `foreignObject` elements, which could lead to a crash.
This commit is contained in:
Tim Ledbetter 2025-09-10 09:51:56 +01:00 committed by Jelle Raaijmakers
commit 551c7f966b
Notes: github-actions[bot] 2025-09-10 09:36:15 +00:00
2 changed files with 8 additions and 1 deletions

View file

@ -1537,7 +1537,8 @@ void PaintableBox::resolve_paint_properties()
// Section 2.11.2: If the computed value of background-image on the root element is none and its background-color is transparent,
// user agents must instead propagate the computed values of the background properties from that elements first HTML BODY child element.
if (document().html_element()->should_use_body_background_properties()) {
auto& html_element = as<HTML::HTMLHtmlElement>(*layout_node_with_style_and_box_metrics().dom_node());
if (html_element.should_use_body_background_properties()) {
background_layers = document().background_layers();
background_color = document().background_color();
}

View file

@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" >
<foreignObject>
<html xmlns="http://www.w3.org/1999/xhtml">
</html>
</foreignObject>
</svg>

After

Width:  |  Height:  |  Size: 158 B