From 40bd2cb611af64eaa7b39c70e28ddc4741e118d5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 12 Feb 2022 00:57:45 +0100 Subject: [PATCH] LibWeb: Move initial containing block setup out of BFC BFC currently has a number of architectural issues due to it being responsible for setting the dimensions of the BFC root. This patch moves the logic for setting up the ICB from BFC to Document. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 5 +++++ Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 0369b42a3c..fc49ffa2e0 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -405,6 +405,8 @@ void Document::update_layout() if (!browsing_context()) return; + auto viewport_rect = browsing_context()->viewport_rect(); + update_style(); if (!m_layout_root) { @@ -413,6 +415,9 @@ void Document::update_layout() } Layout::BlockFormattingContext root_formatting_context(*m_layout_root, nullptr); + m_layout_root->build_stacking_context_tree(); + m_layout_root->set_content_size(viewport_rect.size().to_type()); + root_formatting_context.run(*m_layout_root, Layout::LayoutMode::Default); m_layout_root->set_needs_display(); diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index fb7f8c4275..edf3427e88 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -532,10 +532,6 @@ void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_m auto viewport_rect = root().browsing_context().viewport_rect(); auto& icb = verify_cast(root()); - icb.build_stacking_context_tree(); - - icb.set_content_width(viewport_rect.width()); - icb.set_content_height(viewport_rect.height()); VERIFY(!icb.children_are_inline()); layout_block_level_children(root(), layout_mode);