LibWeb: Use XML parser for SVG-as-image documents

We were already using the XML parser for SVG files when opening at the
top level. This patch makes things consistent by using the same code
path when parsing SVG-as-image.

We also make some tweaks in SVG presentation attribute handling since
we can no longer rely on the HTML length attribute parsing quirk when
parsing width/height attributes.
This commit is contained in:
Andreas Kling 2025-08-21 15:53:37 +02:00 committed by Andreas Kling
commit 3c808de270
Notes: github-actions[bot] 2025-08-22 09:36:57 +00:00
4 changed files with 11 additions and 15 deletions

View file

@ -65,7 +65,7 @@ bool SVGForeignObjectElement::is_presentational_hint(FlyString const& name) cons
void SVGForeignObjectElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties> cascaded_properties) const
{
Base::apply_presentational_hints(cascaded_properties);
auto parsing_context = CSS::Parser::ParsingParams { document() };
auto parsing_context = CSS::Parser::ParsingParams { document(), CSS::Parser::ParsingMode::SVGPresentationAttribute };
if (auto width_value = parse_css_value(parsing_context, get_attribute_value(Web::HTML::AttributeNames::width), CSS::PropertyID::Width))
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Width, width_value.release_nonnull());