From a6505f6e6d8be7dc0136c7293f6da39ed98e27cb Mon Sep 17 00:00:00 2001 From: MacDue Date: Sun, 7 Aug 2022 20:22:55 +0100 Subject: [PATCH] LibWeb: Allow % height of a % height parent in block-formatted elements With this you can start to see Francine's face in the CSS oil painting (https://diana-adrianne.com/purecss-francine/) --- .../LibWeb/Layout/BlockFormattingContext.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index ccb386533f..6c3cd57536 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -311,33 +311,24 @@ void BlockFormattingContext::compute_width_for_block_level_replaced_element_in_n float BlockFormattingContext::compute_theoretical_height(LayoutState const& state, Box const& box) { auto const& computed_values = box.computed_values(); - auto const& containing_block = *box.containing_block(); auto containing_block_height = CSS::Length::make_px(containing_block_height_for(box, state)); - auto is_absolute = [](Optional const& length_percentage) { - return length_percentage.has_value() && length_percentage->is_length() && length_percentage->length().is_absolute(); - }; - // Then work out what the height is, based on box type and CSS properties. float height = 0; if (is(box)) { height = compute_height_for_replaced_element(state, verify_cast(box)); } else { - if (box.computed_values().height().is_auto() - || (computed_values.height().is_percentage() && !is_absolute(containing_block.computed_values().height()))) { + if (box.computed_values().height().is_auto()) height = compute_auto_height_for_block_level_element(state, box); - } else { + else height = computed_values.height().resolved(box, containing_block_height).to_px(box); - } } auto specified_max_height = computed_values.max_height().resolved(box, containing_block_height).resolved(box); - if (!specified_max_height.is_auto() - && !(computed_values.max_height().is_percentage() && !is_absolute(containing_block.computed_values().height()))) + if (!specified_max_height.is_auto()) height = min(height, specified_max_height.to_px(box)); auto specified_min_height = computed_values.min_height().resolved(box, containing_block_height).resolved(box); - if (!specified_min_height.is_auto() - && !(computed_values.min_height().is_percentage() && !is_absolute(containing_block.computed_values().height()))) + if (!specified_min_height.is_auto()) height = max(height, specified_min_height.to_px(box)); return height; }