From 3145f92bc0ef778acc5188b0e77218e34e384369 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 21 Jul 2022 16:16:12 +0200 Subject: [PATCH] LibWeb: Count flex item's *outer* size towards container intrinsic size This isn't in the spec, but it's visually obvious that we need to count item margin boxes towards the main intrinsic size of the flex container. --- Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index 432152e99c..5f313a23e0 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -1425,6 +1425,10 @@ float FlexFormattingContext::calculate_intrinsic_main_size_of_flex_container(Lay auto result = flex_item->flex_base_size + product; // FIXME: Clamp result to min/max main size + // NOTE: The spec doesn't mention anything about the *outer* size here, but if we don't add the margin box, + // flex items with non-zero padding/border/margin in the main axis end up overflowing the container. + result = flex_item->add_main_margin_box_sizes(result); + sum += result; }