From 642915215f6f87f88e37c0a2621f8ddba73beee8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 3 Nov 2021 10:25:01 +0100 Subject: [PATCH] LibWeb: Size non-loaded 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. --- Userland/Libraries/LibWeb/Layout/ImageBox.cpp | 4 ++-- 1 file 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()) {