mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
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:
committed by
Andreas Kling
parent
cfa75e6eb4
commit
928a5247ff
Notes:
github-actions[bot]
2026-04-23 14:49:29 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/928a5247ff3 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/9049
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<div id="target">target</div>
|
||||
<script>
|
||||
function settleAndReset(triggerElement) {
|
||||
getComputedStyle(triggerElement).color;
|
||||
getComputedStyle(triggerElement).color;
|
||||
internals.resetStyleInvalidationCounters();
|
||||
}
|
||||
|
||||
function verifyLayerMutationSchedulesFullRestyle(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");
|
||||
settleAndReset(target);
|
||||
|
||||
const layerOrderStyle = document.createElement("style");
|
||||
layerOrderStyle.textContent = "@layer B, A;";
|
||||
document.head.appendChild(layerOrderStyle);
|
||||
|
||||
getComputedStyle(target).color;
|
||||
verifyLayerMutationSchedulesFullRestyle("layer-only stylesheet add schedules full restyle");
|
||||
|
||||
settleAndReset(target);
|
||||
layerOrderStyle.remove();
|
||||
|
||||
getComputedStyle(target).color;
|
||||
verifyLayerMutationSchedulesFullRestyle("layer-only stylesheet remove schedules full restyle");
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user