mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
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.
39 lines
1.5 KiB
HTML
39 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<div id="target">target</div>
|
|
<script>
|
|
function settleAndReset(triggerElement) {
|
|
getComputedStyle(triggerElement).fontVariantAlternates;
|
|
getComputedStyle(triggerElement).fontVariantAlternates;
|
|
internals.resetStyleInvalidationCounters();
|
|
}
|
|
|
|
function verifyFontFeatureValuesMutationSchedulesFullRestyle(label) {
|
|
const invalidations = internals.getStyleInvalidationCounters().fullStyleInvalidations;
|
|
if (invalidations >= 1)
|
|
println(`PASS: ${label} (${invalidations} full invalidations)`);
|
|
else
|
|
println(`FAIL: ${label} (${invalidations} full invalidations)`);
|
|
}
|
|
|
|
test(() => {
|
|
const target = document.getElementById("target");
|
|
target.style.fontFamily = "TestFont";
|
|
target.style.fontVariantAlternates = "styleset(fancy)";
|
|
settleAndReset(target);
|
|
|
|
const style = document.createElement("style");
|
|
style.textContent = "@font-feature-values TestFont { @styleset { fancy: 1; } }";
|
|
document.head.appendChild(style);
|
|
|
|
getComputedStyle(target).fontVariantAlternates;
|
|
verifyFontFeatureValuesMutationSchedulesFullRestyle("@font-feature-values stylesheet add schedules full restyle");
|
|
|
|
settleAndReset(target);
|
|
style.remove();
|
|
|
|
getComputedStyle(target).fontVariantAlternates;
|
|
verifyFontFeatureValuesMutationSchedulesFullRestyle("@font-feature-values stylesheet remove schedules full restyle");
|
|
});
|
|
</script>
|