mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:37:35 +00:00
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.
This commit is contained in:
parent
409b20e316
commit
642915215f
1 changed files with 2 additions and 2 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue