diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index d1de0c83a2..c18bbf13ac 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -377,12 +377,11 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain OwnPtr independent_formatting_context; if (!box.is_replaced_box() && box.has_children()) { - if (box.children_are_inline()) { - layout_inline_children(verify_cast(box), layout_mode, box_state.available_inner_space_or_constraints_from(available_space)); + if (auto independent_formatting_context = create_independent_formatting_context_if_needed(m_state, box)) { + independent_formatting_context->run(box, layout_mode, box_state.available_inner_space_or_constraints_from(available_space)); } else { - independent_formatting_context = create_independent_formatting_context_if_needed(m_state, box); - if (independent_formatting_context) - independent_formatting_context->run(box, layout_mode, box_state.available_inner_space_or_constraints_from(available_space)); + if (box.children_are_inline()) + layout_inline_children(verify_cast(box), layout_mode, box_state.available_inner_space_or_constraints_from(available_space)); else layout_block_level_children(verify_cast(box), layout_mode, box_state.available_inner_space_or_constraints_from(available_space)); } diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index edf2f8d1b1..a85121caf1 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -155,7 +155,8 @@ OwnPtr FormattingContext::create_independent_formatting_conte } VERIFY(is_block_formatting_context()); - VERIFY(!child_box.children_are_inline()); + if (child_box.children_are_inline()) + return {}; // The child box is a block container that doesn't create its own BFC. // It will be formatted by this BFC.