mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-17 15:02:24 +00: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
Notes:
github-actions[bot]
2025-07-21 09:30:46 +00:00
Author: https://github.com/tcl3
Commit: 1263d58689
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5538
Reviewed-by: https://github.com/gmta ✅
2 changed files with 3 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue