From 07a4d590dd5fbeee08c81336e5c324698d482423 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 20 Mar 2022 18:43:53 +0100 Subject: [PATCH] LibWeb: Layout browsing context parent before its children When updating layout inside a nested browsing context, try first to perform layout in the parent document (the nested browsing context's container's document). This ensures that nested browsing contexts have the right viewport dimensions in case the parent layout changes them somehow. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 3d67b113c9..a08584cf67 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -551,6 +551,11 @@ void Document::invalidate_layout() void Document::update_layout() { + // NOTE: If our parent document needs a relayout, we must do that *first*. + // This is necessary as the parent layout may cause our viewport to change. + if (browsing_context() && browsing_context()->container()) + browsing_context()->container()->document().update_layout(); + update_style(); if (!m_needs_layout && m_layout_root)