Truly independent web browser
LibWeb: Don't detach an out-of-flow table-internal box in place
Andreas Kling85b44012b5b4
diff --git a/Libraries/LibWeb/Rust/src/layout/box_removal.rs b/Libraries/LibWeb/Rust/src/layout/box_removal.rsindex e4ebe206603..421ffeaf20f 100644--- a/Libraries/LibWeb/Rust/src/layout/box_removal.rs+++ b/Libraries/LibWeb/Rust/src/layout/box_removal.rs@@ -163,6 +163,15 @@ impl LayoutNodeArena {return false;}+ // An out-of-flow box with an authored table-internal display is a table child to the table fixup, which gave it+ // anonymous parents that go with it.+ if self.node_style_if_live(child).is_some_and(|style| {+ let display = style.display_before_box_type_transformation();+ style.is_absolutely_positioned() && (display.is_internal_table() || display.is_table_caption())+ }) {+ return false;+ }+// OPTIMIZATION: Absolutely positioned boxes do not participate in their DOM parent's inline or block formatting// structure, even when they are attached to an ancestor containing block. Removing them cannot// disturb anonymous wrappers or sibling box levels.diff --git a/Tests/LibWeb/Text/expected/css/absolutely-positioned-table-internal-box-removed.txt b/Tests/LibWeb/Text/expected/css/absolutely-positioned-table-internal-box-removed.txtnew file mode 100644index 00000000000..3d25f2ebea0--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/absolutely-positioned-table-internal-box-removed.txt@@ -0,0 +1,5 @@+table-caption removed: the tree matches a full rebuild: true+table-row removed: the tree matches a full rebuild: true+table-cell removed: the tree matches a full rebuild: true+table-row-group removed: the tree matches a full rebuild: true+table-column removed: the tree matches a full rebuild: truediff --git a/Tests/LibWeb/Text/input/css/absolutely-positioned-table-internal-box-removed.html b/Tests/LibWeb/Text/input/css/absolutely-positioned-table-internal-box-removed.htmlnew file mode 100644index 00000000000..e106b45c896--- /dev/null+++ b/Tests/LibWeb/Text/input/css/absolutely-positioned-table-internal-box-removed.html@@ -0,0 +1,17 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<body>+<script>+ test(() => {+ for (const display of ["table-caption", "table-row", "table-cell", "table-row-group", "table-column"]) {+ const target = document.createElement("div");+ target.style.position = "absolute";+ target.style.display = display;+ target.textContent = "text";+ document.body.append(target);+ document.body.offsetWidth;+ target.remove();+ println(`${display} removed: the tree matches a full rebuild: ${internals.compareLayoutTreeWithFullRebuild().matches}`);+ }+ });+</script>