Truly independent web browser
LibWeb: Skip the link bookkeeping for elements a walk does not test
Andreas Klinge901d72f4fd9
diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rsindex 475c1ce738d..ebf6fd2e1e9 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs@@ -3799,6 +3799,15 @@ impl<'a> Follower<'a> {)}),};+ // NB: Most elements of a walk are tested against no link, and only pass the level's on to their children.+ if candidates.is_empty() && across.is_empty() {+ if !continuing.links.is_empty()+ && let first_child @ Some(_) = tree.first_element_child(current)+ {+ self.walk_siblings(first_child, continuing, Links::new());+ }+ continue;+ }let mut added = Links::new();let mut next_across = Links::new();let mut matched: SmallVec<[Step; 8]> = SmallVec::new();diff --git a/Tests/LibWeb/Text/expected/css/combinator-invalidation-reaches-keys-that-arrive-late.txt b/Tests/LibWeb/Text/expected/css/combinator-invalidation-reaches-keys-that-arrive-late.txtnew file mode 100644index 00000000000..fb73e3f67cf--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/combinator-invalidation-reaches-keys-that-arrive-late.txt@@ -0,0 +1,70 @@+No element carries a key, ancestor off+ byClass: rgb(0, 0, 0)+ byId: rgb(0, 0, 0)+ byAttribute: rgb(0, 0, 0)+ byChild: rgb(0, 0, 0)+ byWhere: rgb(0, 0, 0)+ inserted: not connected+ together: rgb(0, 0, 0)+ next: rgb(0, 0, 0)+ later: rgb(0, 0, 0)+No element carries a key, ancestor on+ byClass: rgb(0, 0, 0)+ byId: rgb(0, 0, 0)+ byAttribute: rgb(0, 0, 0)+ byChild: rgb(0, 0, 0)+ byWhere: rgb(0, 0, 0)+ inserted: not connected+ together: rgb(0, 0, 0)+ next: rgb(0, 0, 0)+ later: rgb(0, 0, 0)+No element carries a key, ancestor off again+ byClass: rgb(0, 0, 0)+ byId: rgb(0, 0, 0)+ byAttribute: rgb(0, 0, 0)+ byChild: rgb(0, 0, 0)+ byWhere: rgb(0, 0, 0)+ inserted: not connected+ together: rgb(0, 0, 0)+ next: rgb(0, 0, 0)+ later: rgb(0, 0, 0)+The keys arrived, ancestor off+ byClass: rgb(0, 0, 0)+ byId: rgb(0, 0, 0)+ byAttribute: rgb(0, 0, 0)+ byChild: rgb(0, 0, 0)+ byWhere: rgb(0, 0, 0)+ inserted: rgb(0, 0, 0)+ together: rgb(0, 0, 0)+ next: rgb(0, 0, 0)+ later: rgb(0, 0, 0)+The keys arrived, ancestor on+ byClass: rgb(0, 128, 0)+ byId: rgb(0, 128, 0)+ byAttribute: rgb(0, 128, 0)+ byChild: rgb(0, 128, 0)+ byWhere: rgb(0, 128, 0)+ inserted: rgb(0, 128, 0)+ together: rgb(0, 0, 0)+ next: rgb(0, 128, 0)+ later: rgb(0, 128, 0)+The keys arrived, ancestor off again+ byClass: rgb(0, 0, 0)+ byId: rgb(0, 0, 0)+ byAttribute: rgb(0, 0, 0)+ byChild: rgb(0, 0, 0)+ byWhere: rgb(0, 0, 0)+ inserted: rgb(0, 0, 0)+ together: rgb(0, 0, 0)+ next: rgb(0, 0, 0)+ later: rgb(0, 0, 0)+A key arrived together with the change of the ancestor+ byClass: rgb(0, 128, 0)+ byId: rgb(0, 128, 0)+ byAttribute: rgb(0, 128, 0)+ byChild: rgb(0, 128, 0)+ byWhere: rgb(0, 128, 0)+ inserted: rgb(0, 128, 0)+ together: rgb(0, 128, 0)+ next: rgb(0, 128, 0)+ later: rgb(0, 128, 0)diff --git a/Tests/LibWeb/Text/input/css/combinator-invalidation-reaches-keys-that-arrive-late.html b/Tests/LibWeb/Text/input/css/combinator-invalidation-reaches-keys-that-arrive-late.htmlnew file mode 100644index 00000000000..2bc61675b84--- /dev/null+++ b/Tests/LibWeb/Text/input/css/combinator-invalidation-reaches-keys-that-arrive-late.html@@ -0,0 +1,62 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ div {+ color: rgb(0, 0, 0);+ }+ .on .late-class,+ .on #late-id,+ .on [data-late],+ .on > .late-child,+ .on :where(.late-where),+ .on .late-inserted,+ .on .late-together,+ .on + .late-next,+ .on ~ .late-later {+ color: rgb(0, 128, 0);+ }+</style>+<div id="ancestor"><div></div><div></div><div></div><div></div><div></div><div></div></div>+<div></div>+<div></div>+<script>+ test(() => {+ const ancestor = document.getElementById("ancestor");+ const [byClass, byId, byAttribute, byChild, byWhere, together] = ancestor.children;+ const next = ancestor.nextElementSibling;+ const later = next.nextElementSibling;+ const inserted = document.createElement("div");+ const elements = { byClass, byId, byAttribute, byChild, byWhere, inserted, together, next, later };++ const report = step => {+ println(step);+ for (const [name, element] of Object.entries(elements))+ println(` ${name}: ${element.isConnected ? getComputedStyle(element).color : "not connected"}`);+ };++ report("No element carries a key, ancestor off");+ ancestor.classList.add("on");+ report("No element carries a key, ancestor on");+ ancestor.classList.remove("on");+ report("No element carries a key, ancestor off again");++ byClass.className = "late-class";+ byId.id = "late-id";+ byAttribute.setAttribute("data-late", "");+ byChild.className = "late-child";+ byWhere.className = "late-where";+ inserted.className = "late-inserted";+ ancestor.appendChild(inserted);+ next.className = "late-next";+ later.className = "late-later";+ report("The keys arrived, ancestor off");+ ancestor.classList.add("on");+ report("The keys arrived, ancestor on");+ ancestor.classList.remove("on");+ report("The keys arrived, ancestor off again");++ together.className = "late-together";+ ancestor.classList.add("on");+ report("A key arrived together with the change of the ancestor");+ });+</script>