mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:38:10 +00:00
LibWeb: Make intrinsic width/height/ratio a Box concept and simplify it
Apparently it's not only replaced elements that can have intrinsic sizes, so let's move this concept from ReplacedBox to Box. To avoid bloating Box, we make the accessors virtual.
This commit is contained in:
parent
1b1bf5c321
commit
81590b1804
9 changed files with 21 additions and 40 deletions
|
@ -37,25 +37,20 @@ int ImageBox::preferred_height() const
|
|||
void ImageBox::prepare_for_replaced_layout()
|
||||
{
|
||||
if (!m_image_loader.has_loaded_or_failed()) {
|
||||
set_has_intrinsic_width(true);
|
||||
set_has_intrinsic_height(true);
|
||||
set_intrinsic_width(0);
|
||||
set_intrinsic_height(0);
|
||||
} else {
|
||||
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);
|
||||
set_intrinsic_ratio({});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue