Skip to content

Truly independent web browser

LibWeb: Reset a table box rebuilt inside the wrapper it kept

sideshowbarker9fcaeda951ed
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
index a30421ce5a1..56f8614c324 100644
--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
@@ -5934,6 +5934,12 @@ fn generate_missing_parents(host: &mut TreeBuilderHost<'_>, root: LayoutNode) ->
let wrapper_slot = wrapper.slot();
host.move_child(table_root, wrapper_slot, NodeSlotId::INVALID);
host.attach_child(parent, wrapper, nearest_sibling);
+ } else {
+ // A table box built again inside the wrapper it kept comes with its element's own style, so it gives up the
+ // properties the wrapper holds, just as it does when the wrapper is made.
+ let host_calls = host.host_calls();
+ host.arena_mut()
+ .reset_table_box_style_used_by_wrapper(host_calls, table_root);
}
}
table_roots_to_wrap
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/abspos-table-rebuilt-with-a-sibling-inserted.txt b/Tests/LibWeb/Text/expected/layout-tree-update/abspos-table-rebuilt-with-a-sibling-inserted.txt
new file mode 100644
index 00000000000..fb820aad1d9
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/abspos-table-rebuilt-with-a-sibling-inserted.txt
@@ -0,0 +1,2 @@
+table stays where it's positioned: true
+content after the table takes no space from it: true
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/abspos-table-rebuilt-with-a-sibling-inserted.html b/Tests/LibWeb/Text/input/layout-tree-update/abspos-table-rebuilt-with-a-sibling-inserted.html
new file mode 100644
index 00000000000..f2b20b3cae9
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/abspos-table-rebuilt-with-a-sibling-inserted.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ #table {
+ position: absolute;
+ top: 100px;
+ display: table;
+ }
+</style>
+<div id="table"></div>
+<pre id="after">after</pre>
+<script>
+ test(() => {
+ document.body.offsetHeight;
+ // The table gets content of its own, and a box goes in after it, in the same update.
+ table.append("x");
+ after.before(document.createElement("div"));
+ const tableTop = table.getBoundingClientRect().top;
+ println(`table stays where it's positioned: ${tableTop === 100}`);
+ println(`content after the table takes no space from it: ${after.getBoundingClientRect().top < tableTop}`);
+ });
+</script>