mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 23:25:20 +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:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user