From 8a87f4fa207da2ec40665e6125bffd2a6f7425e2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 9 Nov 2022 15:11:21 +0100 Subject: [PATCH] LibWeb: Try to compute height for abspos elements before inside layout This can resolve height early in some cases, notably this kind of setup: position: absolute; top: 0px; bottom: 0px; By resolving height before inside layout, descendants of the abspos element can resolve automatic and relative vertical lengths against it. This makes the Discord UI occupy the whole window instead of looking "shrink-to-fit". --- Userland/Libraries/LibWeb/Layout/FormattingContext.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index 621c244ead..3d89ab74b7 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -936,6 +936,12 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box, Ava auto specified_width = box.computed_values().width().resolved(box, width_of_containing_block_as_length).resolved(box); compute_width_for_absolutely_positioned_element(box, available_space); + + // NOTE: We compute height before *and* after doing inside layout. + // This is done so that inside layout can resolve percentage heights. + // In a situation like + compute_height_for_absolutely_positioned_element(box, available_space); + auto independent_formatting_context = layout_inside(box, LayoutMode::Normal, box_state.available_inner_space_or_constraints_from(available_space)); compute_height_for_absolutely_positioned_element(box, available_space);