diff options
author | Andreas Kling <kling@serenityos.org> | 2022-02-12 00:57:45 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-12 22:30:50 +0100 |
commit | 40bd2cb611af64eaa7b39c70e28ddc4741e118d5 (patch) | |
tree | 04a3df6dd90fa6c7a65950d7abebf74ad0bc451a /Userland/Libraries | |
parent | 8b8a1449c4376b8ae17f1493ee69a65a982f045d (diff) | |
download | serenity-40bd2cb611af64eaa7b39c70e28ddc4741e118d5.zip |
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.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Document.cpp | 5 | ||||
-rw-r--r-- | 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<float>()); + 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<Layout::InitialContainingBlock>(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); |