mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:58:11 +00:00
LibWeb: Until an image has loaded or failed, don't occupy layout size
This patch makes images have an implicit zero intrinsic size before they have either loaded or failed to load. This is tracked by the ImageLoader object. This fixes a long-standing issue with images occupying empty 150x150 rectangles of space.
This commit is contained in:
parent
bd54854c64
commit
305e2ef69c
3 changed files with 33 additions and 11 deletions
|
@ -54,20 +54,27 @@ int LayoutImage::preferred_height() const
|
|||
|
||||
void LayoutImage::layout(LayoutMode layout_mode)
|
||||
{
|
||||
if (m_image_loader.width()) {
|
||||
if (!m_image_loader.has_loaded_or_failed()) {
|
||||
set_has_intrinsic_width(true);
|
||||
set_intrinsic_width(m_image_loader.width());
|
||||
}
|
||||
if (m_image_loader.height()) {
|
||||
set_has_intrinsic_height(true);
|
||||
set_intrinsic_height(m_image_loader.height());
|
||||
}
|
||||
|
||||
if (m_image_loader.width() && m_image_loader.height()) {
|
||||
set_has_intrinsic_ratio(true);
|
||||
set_intrinsic_ratio((float)m_image_loader.width() / (float)m_image_loader.height());
|
||||
set_intrinsic_width(0);
|
||||
set_intrinsic_height(0);
|
||||
} else {
|
||||
set_has_intrinsic_ratio(false);
|
||||
if (m_image_loader.width()) {
|
||||
set_has_intrinsic_width(true);
|
||||
set_intrinsic_width(m_image_loader.width());
|
||||
}
|
||||
if (m_image_loader.height()) {
|
||||
set_has_intrinsic_height(true);
|
||||
set_intrinsic_height(m_image_loader.height());
|
||||
}
|
||||
|
||||
if (m_image_loader.width() && m_image_loader.height()) {
|
||||
set_has_intrinsic_ratio(true);
|
||||
set_intrinsic_ratio((float)m_image_loader.width() / (float)m_image_loader.height());
|
||||
} else {
|
||||
set_has_intrinsic_ratio(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (renders_as_alt_text()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue