mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
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.
44 lines
1.6 KiB
HTML
44 lines
1.6 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<style id="style-sheet">
|
|
#target {
|
|
animation-name: fade;
|
|
animation-duration: 1s;
|
|
}
|
|
</style>
|
|
<div id="target">target</div>
|
|
<div>bystander 1</div>
|
|
<div>bystander 2</div>
|
|
<div>bystander 3</div>
|
|
<script>
|
|
function settleAndReset(triggerElement) {
|
|
// Force style resolution before we observe counters so the inserted
|
|
// @keyframes rule is the only thing contributing to the measurement.
|
|
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 + 4}`;
|
|
parent.appendChild(bystander);
|
|
}
|
|
}
|
|
|
|
test(() => {
|
|
const target = document.getElementById("target");
|
|
addBystanders(document.body, 25);
|
|
const sheet = document.getElementById("style-sheet").sheet;
|
|
settleAndReset(target);
|
|
sheet.insertRule("@keyframes fade { from { opacity: 0; } to { opacity: 1; } }", sheet.cssRules.length);
|
|
getComputedStyle(target).animationName;
|
|
const invalidations = internals.getStyleInvalidationCounters().styleInvalidations;
|
|
if (invalidations <= 1)
|
|
println(`PASS: keyframes insertRule only invalidates animation users (${invalidations} invalidations)`);
|
|
else
|
|
println(`FAIL: keyframes insertRule only invalidates animation users (${invalidations} invalidations)`);
|
|
});
|
|
</script>
|