mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb: Ignore zero width when calculating SVG intrinsic aspect ratio
Previously, an SVG with width of zero would have am intrinsic aspect ratio of zero. With this change, if an SVG has a width or height of zero, the intrinsic aspect ratio is determined by the SVG's viewbox.
This commit is contained in:
parent
16ef883e44
commit
1263d58689
|
|
@ -172,10 +172,7 @@ Optional<CSSPixelFraction> SVGDecodedImageData::intrinsic_aspect_ratio() const
|
|||
// https://www.w3.org/TR/SVG2/coords.html#SizingSVGInCSS
|
||||
auto width = intrinsic_width();
|
||||
auto height = intrinsic_height();
|
||||
if (height.has_value() && *height == 0)
|
||||
return {};
|
||||
|
||||
if (width.has_value() && height.has_value())
|
||||
if (width.has_value() && height.has_value() && *width > 0 && *height > 0)
|
||||
return *width / *height;
|
||||
|
||||
if (auto const& viewbox = m_root_element->view_box(); viewbox.has_value()) {
|
||||
|
|
|
|||
2
Tests/LibWeb/Crash/SVG/zero-width-svg.html
Normal file
2
Tests/LibWeb/Crash/SVG/zero-width-svg.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='0' height='1'></svg>">
|
||||
Loading…
Reference in New Issue
Block a user