summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-01-23 17:24:56 +0100
committerAndreas Kling <kling@serenityos.org>2023-01-24 11:44:03 +0100
commit4e06e86438136323f6de6dbac1a0a363fe35ef8b (patch)
treee7b5c2904caaa7f04d55e927d0040507affde914
parentaa19c4a34028532a5e3f8453e3368fc0888dca23 (diff)
downloadserenity-4e06e86438136323f6de6dbac1a0a363fe35ef8b.zip
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.
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.cpp5
1 files changed, 5 insertions, 0 deletions
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();