mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +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.
36 lines
1.0 KiB
HTML
36 lines
1.0 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<table>
|
|
<colgroup>
|
|
<col class="selected">
|
|
<col>
|
|
</colgroup>
|
|
<tr>
|
|
<td>first</td>
|
|
<td>second</td>
|
|
</tr>
|
|
</table>
|
|
<script>
|
|
function settleAndReset() {
|
|
getComputedStyle(document.body).color;
|
|
getComputedStyle(document.body).color;
|
|
internals.resetStyleInvalidationCounters();
|
|
}
|
|
|
|
function printInvalidationCount(label) {
|
|
println(`${label}: ${internals.getStyleInvalidationCounters().styleInvalidations}`);
|
|
}
|
|
|
|
test(() => {
|
|
settleAndReset();
|
|
|
|
const style = document.createElement("style");
|
|
style.textContent = "col.selected || * { color: rgb(255, 0, 0); }";
|
|
document.head.appendChild(style);
|
|
printInvalidationCount("column trailing-universal add invalidations");
|
|
// Selector matching for || is still incomplete, so remove the rule
|
|
// before any later style flush can hit that unrelated TODO path.
|
|
style.remove();
|
|
});
|
|
</script>
|