LibWeb: Layout foreignObject as block-level element with hidden overflow

This is according to the default user-agent style from the SVG2 spec.

In order for this to work correctly, we also have to assign width and
height to foreignObject boxes during SVG layout, since they are handled
manually by SVGFormattingContext.
This commit is contained in:
Andreas Kling 2025-07-07 19:30:38 +02:00 committed by Andreas Kling
commit b4708510fb
Notes: github-actions[bot] 2025-07-09 12:37:48 +00:00
4 changed files with 35 additions and 17 deletions

View file

@ -282,6 +282,8 @@ void SVGFormattingContext::layout_svg_element(Box const& child)
bfc.run(*m_available_space);
auto& child_state = m_state.get_mutable(child);
child_state.set_content_offset(child_state.offset.translated(m_svg_offset));
child_state.set_content_width(child.computed_values().width().to_px(child, m_available_space->width.to_px_or_zero()));
child_state.set_content_height(child.computed_values().height().to_px(child, m_available_space->height.to_px_or_zero()));
child.for_each_child_of_type<SVGMaskBox>([&](SVGMaskBox const& child) {
layout_svg_element(child);
return IterationDecision::Continue;