From f0ac687823325540db3b3c330bb550b2de414aca Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 24 Sep 2022 13:53:23 +0200 Subject: [PATCH] LibWeb: Remove awkward BFC::compute_theoretical_height() function This was used by FFC to estimate the height of flex items after performing layout inside them. Now that we have automatic_content_height(), we no longer need this awkward API and we can fold it into BFC's own height calculation. --- .../LibWeb/Layout/BlockFormattingContext.cpp | 11 ++++------- .../Libraries/LibWeb/Layout/BlockFormattingContext.h | 1 - 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index 616241e004..9c717308c2 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -321,8 +321,10 @@ void BlockFormattingContext::compute_width_for_block_level_replaced_element_in_n m_state.get_mutable(box).set_content_width(compute_width_for_replaced_element(m_state, box)); } -float BlockFormattingContext::compute_theoretical_height(LayoutState const& state, Box const& box) +void BlockFormattingContext::compute_height(Box const& box, LayoutState& state) { + resolve_vertical_box_model_metrics(box, *box.containing_block(), state); + auto const& computed_values = box.computed_values(); auto containing_block_height = CSS::Length::make_px(containing_block_height_for(box, state)); @@ -344,13 +346,8 @@ float BlockFormattingContext::compute_theoretical_height(LayoutState const& stat auto specified_min_height = computed_values.min_height().resolved(box, containing_block_height).resolved(box); if (!specified_min_height.is_auto()) height = max(height, specified_min_height.to_px(box)); - return height; -} -void BlockFormattingContext::compute_height(Box const& box, LayoutState& state) -{ - resolve_vertical_box_model_metrics(box, *box.containing_block(), state); - state.get_mutable(box).set_content_height(compute_theoretical_height(state, box)); + state.get_mutable(box).set_content_height(height); } void BlockFormattingContext::layout_inline_children(BlockContainer const& block_container, LayoutMode layout_mode) diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.h b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.h index d8559c166e..4d4b827ad0 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.h +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.h @@ -30,7 +30,6 @@ public: auto const& left_side_floats() const { return m_left_floats; } auto const& right_side_floats() const { return m_right_floats; } - static float compute_theoretical_height(LayoutState const&, Box const&); void compute_width(Box const&, LayoutMode = LayoutMode::Normal); // https://www.w3.org/TR/css-display/#block-formatting-context-root