LibWeb: Account for natural aspect ratio in calculate_min_content_height

By the time we calculate the min-content height, the width is already
known, so we can use it to calculate the height based on the natural
aspect ratio.
This commit is contained in:
Aliaksandr Kalenik 2025-07-08 20:10:51 +02:00 committed by Alexander Kalenik
commit 8d9920af16
Notes: github-actions[bot] 2025-07-08 20:36:08 +00:00
4 changed files with 29 additions and 5 deletions

View file

@ -1513,8 +1513,11 @@ CSSPixels FormattingContext::calculate_min_content_height(Layout::Box const& box
if (box.is_block_container() || box.display().is_table_inside())
return calculate_max_content_height(box, width);
if (box.has_natural_height())
if (box.has_natural_height()) {
if (box.has_natural_aspect_ratio())
return width / *box.natural_aspect_ratio();
return *box.natural_height();
}
auto& cache = box.cached_intrinsic_sizes().min_content_height.ensure(width);
if (cache.has_value())