Files
ladybird/Tests/LibWeb/Text/input/css/insert-rule-keyframes-shadow-host-invalidation-counters.html
Andreas Kling 4e92765211 LibWeb: Narrow @keyframes insertRule() invalidation
Handle inline stylesheet @keyframes insertions without falling back to
broad owner invalidation. Recompute only elements whose computed
animation-name already references the inserted keyframes name.

Document-scoped insertions still walk the shadow-including tree so
existing shadow trees pick up inherited animations, and shadow-root
stylesheets fan out through the host root so :host combinators can
refresh host-side consumers as well. Also introduce the shared
ShadowRootStylesheetEffects analysis so later stylesheet mutation paths
can reuse the same per-scope escape classification.
2026-04-23 16:45:22 +02:00

43 lines
1.5 KiB
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<div id="host"></div>
<script>
function settleAndReset(triggerElement) {
getComputedStyle(triggerElement).animationName;
getComputedStyle(triggerElement).animationName;
internals.resetStyleInvalidationCounters();
}
function addBystanders(parent, count) {
for (let i = 0; i < count; ++i) {
const bystander = document.createElement("div");
bystander.textContent = `bystander ${i}`;
parent.appendChild(bystander);
}
}
test(() => {
const host = document.getElementById("host");
const shadowRoot = host.attachShadow({ mode: "open" });
const sheet = new CSSStyleSheet();
sheet.replaceSync(`
:host {
animation-name: fade;
animation-duration: 1s;
}
`);
shadowRoot.adoptedStyleSheets = [sheet];
addBystanders(document.body, 25);
settleAndReset(host);
sheet.insertRule("@keyframes fade { from { opacity: 0.25; } to { opacity: 0.25; } }", sheet.cssRules.length);
getComputedStyle(host).animationName;
const invalidations = internals.getStyleInvalidationCounters().styleInvalidations;
if (invalidations <= 1)
println(`PASS: bare :host keyframes insertRule only invalidates the host (${invalidations} invalidations)`);
else
println(`FAIL: bare :host keyframes insertRule only invalidates the host (${invalidations} invalidations)`);
});
</script>