LibWeb: Narrow stylesheet add/remove invalidation

Avoid broad document invalidation when adding or removing ordinary
document-owned or shadow-owned stylesheets. Reuse the targeted
StyleSheetInvalidation path for style rules, including shadow-host
escapes, pseudo-element-only selectors, and trailing-universal cases.

Keep the broad path for sheet contents whose effects are not captured
by selector invalidation alone, including @property, @font-face,
@font-feature-values, @keyframes, imported sheets, and top-level @layer
blocks. Broad-path shadow-root sheets still reach host-side consumers
through their active-scope effects.
This commit is contained in:
Andreas Kling
2026-04-22 22:37:41 +02:00
committed by Andreas Kling
parent cfa75e6eb4
commit 928a5247ff
Notes: github-actions[bot] 2026-04-23 14:49:29 +00:00
44 changed files with 909 additions and 78 deletions

View File

@@ -0,0 +1,27 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<div id="host"></div>
<script>
test(() => {
const host = document.getElementById("host");
const shadowRoot = host.attachShadow({ mode: "open" });
const target = document.createElement("div");
target.className = "foo";
shadowRoot.appendChild(target);
const nonTarget = document.createElement("div");
nonTarget.className = "bar";
shadowRoot.appendChild(nonTarget);
println(`before target: ${getComputedStyle(target).color}`);
println(`before non-target: ${getComputedStyle(nonTarget).color}`);
const style = document.createElement("style");
style.textContent = ".foo { color: rgb(255, 0, 0); }";
shadowRoot.appendChild(style);
println(`after target: ${getComputedStyle(target).color}`);
println(`after non-target: ${getComputedStyle(nonTarget).color}`);
});
</script>