Skip to content

Truly independent web browser

LibWeb: Reset the intrinsic sizes of boxes that lose a layout child

Aliaksandr Kalenik37172c40c499
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
index 030d5af261e..3fed5a512b6 100644
--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
@@ -5703,6 +5703,7 @@ impl LayoutNodeArena {
self.note_overflow_contained_boxes_may_move_with_subtree(child);
self.unlink_child(parent, child);
self.note_structural_change_at_and_above(parent);
+ self.reset_cached_intrinsic_sizes_of_self_and_ancestors(parent);
}
fn unlink_child(&self, parent: NodeSlotId, child: NodeSlotId) {
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/anonymous-table-removal-resizes-shrink-to-fit-container.txt b/Tests/LibWeb/Text/expected/layout-tree-update/anonymous-table-removal-resizes-shrink-to-fit-container.txt
new file mode 100644
index 00000000000..6cc4be0cd28
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/anonymous-table-removal-resizes-shrink-to-fit-container.txt
@@ -0,0 +1 @@
+width after removing the cell matches the remaining text: true
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/anonymous-table-removal-resizes-shrink-to-fit-container.html b/Tests/LibWeb/Text/input/layout-tree-update/anonymous-table-removal-resizes-shrink-to-fit-container.html
new file mode 100644
index 00000000000..3de2afbe7af
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/anonymous-table-removal-resizes-shrink-to-fit-container.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ .shrink-to-fit { position: absolute; }
+ #cell { display: table-cell; }
+</style>
+<div id="container" class="shrink-to-fit"><span><span id="cell">X</span>X</span></div>
+<div id="reference" class="shrink-to-fit"><span>X</span></div>
+<script>
+ asyncTest(done => {
+ window.onload = () => {
+ cell.remove();
+ requestAnimationFrame(() => requestAnimationFrame(() => {
+ const width = container.getBoundingClientRect().width;
+ const expected = reference.getBoundingClientRect().width;
+ println(`width after removing the cell matches the remaining text: ${width === expected}`);
+ done();
+ }));
+ };
+ });
+</script>