From 4e06e86438136323f6de6dbac1a0a363fe35ef8b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 23 Jan 2023 17:24:56 +0100 Subject: [PATCH] LibWeb: Make min-content height equivalent to max-content as appropriate Per CSS-SIZING-3, the min-content block size should be equivalent to the max-content block size for some boxes. Honoring this gives more correct results, and avoids unnecessary work in many cases since the cached max-content size can be reused. --- Userland/Libraries/LibWeb/Layout/FormattingContext.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index 58bd823432..2ad2b0b58d 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -1146,8 +1146,13 @@ CSSPixels FormattingContext::calculate_max_content_width(Layout::Box const& box) return *cache.max_content_width; } +// https://www.w3.org/TR/css-sizing-3/#min-content-block-size CSSPixels FormattingContext::calculate_min_content_height(Layout::Box const& box, AvailableSize const& available_width) const { + // For block containers, tables, and inline boxes, this is equivalent to the max-content block size. + if (box.is_block_container() || box.is_table()) + return calculate_max_content_height(box, available_width); + if (box.has_intrinsic_height()) return *box.intrinsic_height();