diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-03 10:25:01 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-03 10:27:23 +0100 |
commit | 642915215f6f87f88e37c0a2621f8ddba73beee8 (patch) | |
tree | 78d345f1f0e787f4d4be28a7ac59963277dfbdcb /Userland | |
parent | 409b20e31680f00d642521ef885ee35c7c6ba26c (diff) | |
download | serenity-642915215f6f87f88e37c0a2621f8ddba73beee8.zip |
LibWeb: Size non-loaded <img> to fit the replacement (alt) text
We achieve this by simply setting the intrinsic size to the size needed
to render the replacement text.
This fixes a long-standing issue where non-loaded images would default
to the goofy-looking 300x150 fallback size for replaced elements.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/ImageBox.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp index 975c99d47d..28a89d5098 100644 --- a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp @@ -60,8 +60,8 @@ void ImageBox::prepare_for_replaced_layout() auto alt = image_element.alt(); if (alt.is_empty()) alt = image_element.src(); - set_width(font.width(alt) + 16); - set_height(font.glyph_height() + 16); + set_intrinsic_width(font.width(alt) + 16); + set_intrinsic_height(font.glyph_height() + 16); } if (!has_intrinsic_width() && !has_intrinsic_height()) { |