1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:17:34 +00:00

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.
This commit is contained in:
Andreas Kling 2022-07-22 21:58:59 +02:00
parent 689cbdf6b6
commit 16c173de43

View file

@ -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<Layout::InitialContainingBlock&>(*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<Layout::InitialContainingBlock&>(*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();