From fd68be29ab22deac5bce73c1a3caa9a9ef631185 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 8 Jul 2022 21:13:32 +0200 Subject: [PATCH] LibWeb: Make BFC always drive IFC Instead of allowing FormattingContext to instantiate an IFC for anything that has inline children, move this logic to BFC. This is fine, since only BFC deals with blocks having inline children anyway. --- .../LibWeb/Layout/BlockFormattingContext.cpp | 14 +++++++++----- .../Libraries/LibWeb/Layout/FormattingContext.cpp | 4 +--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index c07742bcdb..c84220ce51 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -432,11 +432,15 @@ void BlockFormattingContext::layout_block_level_children(BlockContainer const& b OwnPtr independent_formatting_context; if (child_box.can_have_children()) { - independent_formatting_context = create_independent_formatting_context_if_needed(m_state, child_box); - if (independent_formatting_context) - independent_formatting_context->run(child_box, layout_mode); - else - layout_block_level_children(verify_cast(child_box), layout_mode); + if (child_box.children_are_inline()) { + layout_inline_children(verify_cast(child_box), layout_mode); + } else { + independent_formatting_context = create_independent_formatting_context_if_needed(m_state, child_box); + if (independent_formatting_context) + independent_formatting_context->run(child_box, layout_mode); + else + layout_block_level_children(verify_cast(child_box), layout_mode); + } } compute_height(child_box, m_state); diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index afae391bbe..85c3fc474b 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -109,8 +108,7 @@ OwnPtr FormattingContext::create_independent_formatting_conte return make(state, verify_cast(child_box), this); VERIFY(is_block_formatting_context()); - if (child_box.children_are_inline()) - return make(state, verify_cast(child_box), static_cast(*this)); + VERIFY(!child_box.children_are_inline()); // The child box is a block container that doesn't create its own BFC. // It will be formatted by this BFC.