1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +00:00

LibWeb: Use width & height to create fallback viewBox for SVG-as-image

When embedding an SVG in an img element, if the external SVG's root
element has both width and height attributes, but no viewBox attribute,
we now create a fallback viewBox with "0 0 width height".

This appears to match the behavior of other browsers. Inspired by
discussion on Mozilla's bug tracker:
https://bugzilla.mozilla.org/show_bug.cgi?id=614649
This commit is contained in:
Andreas Kling 2023-06-20 09:39:14 +02:00
parent a0b4987e92
commit 9f24c1b34c
6 changed files with 66 additions and 2 deletions

View file

@ -159,7 +159,7 @@ void SVGFormattingContext::run(Box const& box, LayoutMode layout_mode, Available
auto path_transform = dom_node.get_transform();
double viewbox_scale = 1;
auto& maybe_view_box = svg_svg_element.view_box();
auto maybe_view_box = svg_svg_element.view_box();
if (maybe_view_box.has_value()) {
// FIXME: This should allow just one of width or height to be specified.
// E.g. We should be able to layout <svg width="100%"> where height is unspecified/auto.