From 16c173de4375f1002f76ed6b3d1e5a150bd18863 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 22 Jul 2022 21:58:59 +0200 Subject: [PATCH] LibWeb: Destroy ICB formatting context before committing used values Absolutely positioned boxes are handled by the BFC destructor, so we need to make sure the ICB BFC is destroyed if we want these boxes to get laid out. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index b53c5a7605..d6aa84af5c 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -616,17 +616,20 @@ void Document::update_layout() Layout::LayoutState layout_state; layout_state.used_values_per_layout_node.resize(layout_node_count()); - Layout::BlockFormattingContext root_formatting_context(layout_state, *m_layout_root, nullptr); - auto& icb = static_cast(*m_layout_root); - auto& icb_state = layout_state.get_mutable(icb); - icb_state.set_content_width(viewport_rect.width()); - icb_state.set_content_height(viewport_rect.height()); + { + Layout::BlockFormattingContext root_formatting_context(layout_state, *m_layout_root, nullptr); - icb.set_has_definite_width(true); - icb.set_has_definite_height(true); + auto& icb = static_cast(*m_layout_root); + auto& icb_state = layout_state.get_mutable(icb); + icb.set_has_definite_width(true); + icb.set_has_definite_height(true); + icb_state.set_content_width(viewport_rect.width()); + icb_state.set_content_height(viewport_rect.height()); + + root_formatting_context.run(*m_layout_root, Layout::LayoutMode::Normal); + } - root_formatting_context.run(*m_layout_root, Layout::LayoutMode::Normal); layout_state.commit(); browsing_context()->set_needs_display();