Truly independent web browser
LibWeb: Widen a layout tree mark that no longer keeps the box
Andreas Klingb10be0860e38
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rsindex bdd93922bd0..99e63c23518 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs@@ -83,9 +83,9 @@ impl LayoutTreeUpdateMarks {node.text_index().is_none() && self.get(node) & CHILD_NEEDS != 0}- /// Fold one mark into the node's, answering whether its own bit changed. That answer is what- /// tells the mark site it has a transition to widen from. Once a reason that forbids reuse- /// arrives, a later one cannot narrow it back.+ /// Fold one mark into the node's, answering whether its own bit changed, or the box it marked for a narrower rebuild+ /// no longer stays. That answer is what tells the mark site it has a transition to widen from. Once a reason that+ /// forbids reuse arrives, a later one cannot narrow it back.pub(crate) fn merge(&mut self, node: StyleNodeID, value: bool, reuse_reason: u8) -> bool {let reuse_reason = reuse_reason & layout_tree_update_reuse_reason::ALL;let mut changed = false;@@ -94,6 +94,7 @@ impl LayoutTreeUpdateMarks {let rest = marks & !(NEEDS | layout_tree_update_reuse_reason::ALL);if (marks & NEEDS != 0) == value {let merged = if reuse_reason == 0 || reasons == 0 {+ changed = value && reasons != 0;0} else {reasons | reuse_reason@@ -733,8 +734,10 @@ mod tests {marks.reuse_reasons(element),CHILD_LIST_INSERTION | PSEUDO_ELEMENT_CHANGE);- assert!(!marks.merge(element, true, 0));+ // NB: The box the marks kept goes now, which what the mark site widens from has to hear of.+ assert!(marks.merge(element, true, 0));assert_eq!(marks.reuse_reasons(element), 0);+ assert!(!marks.merge(element, true, 0));assert!(!marks.merge(element, true, CHILD_LIST_INSERTION));assert_eq!(marks.reuse_reasons(element), 0);assert!(marks.needs(element));diff --git a/Tests/LibWeb/Text/expected/css/table-display-change-as-a-child-is-reinserted.txt b/Tests/LibWeb/Text/expected/css/table-display-change-as-a-child-is-reinserted.txtnew file mode 100644index 00000000000..f712dd08200--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/table-display-change-as-a-child-is-reinserted.txt@@ -0,0 +1,2 @@+before: table+after: block, truediff --git a/Tests/LibWeb/Text/input/css/table-display-change-as-a-child-is-reinserted.html b/Tests/LibWeb/Text/input/css/table-display-change-as-a-child-is-reinserted.htmlnew file mode 100644index 00000000000..3973129d006--- /dev/null+++ b/Tests/LibWeb/Text/input/css/table-display-change-as-a-child-is-reinserted.html@@ -0,0 +1,39 @@+<!DOCTYPE html>+<style>+ @media (prefers-color-scheme: dark) {+ :nth-child(2n+1) { display: block; background-color: rgb(0, 1, 0); margin-right: 7px; }+ }+</style>+<script src="../include.js"></script>+<body>+<div id="first"></div>+<div id="deep"><div><a><h1></h1></a></div></div>+<option></option>+<script>+ asyncTest(async done => {+ const frame = () => new Promise(resolve => requestAnimationFrame(resolve));+ const moved = document.createElement("table");+ document.querySelector("h1").append(moved);+ const table = document.createElement("table");+ const child = document.createElement("summary");+ table.append(child);+ first.after(table);+ internals.setPreferredColorScheme("light");+ await frame();+ await frame();+ println(`before: ${getComputedStyle(table).display}`);+ document.body.moveBefore(moved, table);+ await frame();+ // The reinserted child asks only to build the children of the table again, and the display change to replace+ // the table's box, whose wrapper goes with it.+ internals.setPreferredColorScheme("dark");+ const next = child.nextSibling;+ child.remove();+ table.insertBefore(child, next);+ await frame();+ await frame();+ println(`after: ${getComputedStyle(table).display}, ${table.offsetWidth > 0}`);+ internals.setPreferredColorScheme("auto");+ done();+ });+</script>