From 050e70cc7e8f1a8b4c4b0c79966cb76c151c8174 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 22 Jul 2022 16:36:17 +0200 Subject: [PATCH] LibWeb: Position abspos children of flex container after parent layout If we wait until after the parent context has laid out the flex container, abspos children are able to use the final results of the parent sizing the flex container. This makes `height:auto` work on abspos children of a flex container. --- Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp | 3 +++ Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index adbe120da0..a1b9652ccc 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -136,7 +136,10 @@ void FlexFormattingContext::run(Box const& run_box, LayoutMode layout_mode) // part of the spec, and simply covering up the fact that our inside layout currently // mutates the height of BFC roots. copy_dimensions_from_flex_items_to_boxes(); +} +void FlexFormattingContext::parent_context_did_dimension_child_root_box() +{ flex_container().for_each_child_of_type([&](Layout::Box& box) { if (box.is_absolutely_positioned()) layout_absolutely_positioned_element(box); diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h index ceb9f44346..b02929f34d 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h @@ -164,6 +164,8 @@ private: [[nodiscard]] float calculate_fit_content_main_size(FlexItem const&) const; [[nodiscard]] float calculate_fit_content_cross_size(FlexItem const&) const; + virtual void parent_context_did_dimension_child_root_box() override; + CSS::FlexBasisData used_flex_basis_for_item(FlexItem const&) const; LayoutState::UsedValues& m_flex_container_state;