Truly independent web browser
LibWeb: Don't lay out only boundaries around a replaced root
Andreas Klingd8010992cb57
diff --git a/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs b/Libraries/LibWeb/Rust/src/layout/partial_relayout.rsindex 3f7aa281ae5..68802211ab2 100644--- a/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs+++ b/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs@@ -292,7 +292,11 @@ impl LayoutNodeArena {) -> Option<Vec<PlannedBoundary>> {let pending_updates_escaped = std::mem::replace(&mut self.pending_updates_escape_partial_relayout, false)|| layout_tree_update_escaped_rebuild_roots;- if self.node_needs_layout_update(root) || pending_updates_escaped {+ // NB: A build can replace the root, which leaves nothing laid out around the boundaries, and no mark on the new box.+ if self.node_needs_layout_update(root)+ || pending_updates_escaped+ || !self.paintable_rows().paintable_row_is_populated(root)+ {return None;}self.collect_partial_relayout_roots(registered_root_slots, rebuilt_subtree_root_slots)diff --git a/Tests/LibWeb/Text/expected/document-child-beside-a-relaid-out-box.txt b/Tests/LibWeb/Text/expected/document-child-beside-a-relaid-out-box.txtnew file mode 100644index 00000000000..1b7a4496669--- /dev/null+++ b/Tests/LibWeb/Text/expected/document-child-beside-a-relaid-out-box.txt@@ -0,0 +1,3 @@+the root's scroll height is known: true+the target moved: 1+the tree matches a full rebuild: truediff --git a/Tests/LibWeb/Text/input/document-child-beside-a-relaid-out-box.html b/Tests/LibWeb/Text/input/document-child-beside-a-relaid-out-box.htmlnew file mode 100644index 00000000000..cb79c2ae6e7--- /dev/null+++ b/Tests/LibWeb/Text/input/document-child-beside-a-relaid-out-box.html@@ -0,0 +1,17 @@+<!DOCTYPE html>+<script src="include.js"></script>+<body>+<div id="target" style="position: absolute; width: 10px; height: 10px; overflow: hidden"></div>+<script>+ test(() => {+ document.body.offsetWidth;++ // A box that would lay out on its own is laid out in the update that also rebuilds the viewport's box.+ target.style.top = "1px";+ document.prepend(document.createComment("comment"));++ println(`the root's scroll height is known: ${document.documentElement.scrollHeight > 0}`);+ println(`the target moved: ${target.getBoundingClientRect().top}`);+ println(`the tree matches a full rebuild: ${internals.compareLayoutTreeWithFullRebuild().matches}`);+ });+</script>