LibWeb: Update layout when view box properties are changed

This commit is contained in:
Tim Ledbetter 2025-08-27 22:19:12 +01:00 committed by Jelle Raaijmakers
parent ea41aba6c7
commit b23fd1f440
Notes: github-actions[bot] 2025-08-28 13:44:02 +00:00
6 changed files with 166 additions and 1 deletions

View file

@ -22,7 +22,7 @@ void SVGFitToViewBox::visit_edges(JS::Cell::Visitor& visitor)
visitor.visit(m_view_box_for_bindings);
}
void SVGFitToViewBox::attribute_changed(DOM::Element&, FlyString const& name, Optional<String> const& value)
void SVGFitToViewBox::attribute_changed(DOM::Element& element, FlyString const& name, Optional<String> const& value)
{
if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox)) {
if (!value.has_value()) {
@ -35,8 +35,10 @@ void SVGFitToViewBox::attribute_changed(DOM::Element&, FlyString const& name, Op
m_view_box_for_bindings->set_anim_val(Gfx::DoubleRect { m_view_box->min_x, m_view_box->min_y, m_view_box->width, m_view_box->height });
}
}
element.set_needs_layout_tree_update(true, DOM::SetNeedsLayoutTreeUpdateReason::SVGViewBoxChange);
} else if (name.equals_ignoring_ascii_case(SVG::AttributeNames::preserveAspectRatio)) {
m_preserve_aspect_ratio = AttributeParser::parse_preserve_aspect_ratio(value.value_or(String {}));
element.set_needs_layout_tree_update(true, DOM::SetNeedsLayoutTreeUpdateReason::SVGViewBoxChange);
}
}