mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
Introduce a small set of counters on Document that track the work done while processing :has() invalidation: how often the upward walk runs, how many elements it visits, how often matches_has_pseudo_class() is invoked, how well the per-pass result cache performs, and how many elements transition from clean to needs-style-update. Expose the counters through internals so tests can assert precise bounds on the invalidation work triggered by a mutation, which regular reference tests cannot express. Add a css-has-invalidation test suite that covers subject-position, non-subject-position, sibling-combinator, and no-:has() cases. The baseline tests share a helper script so later coverage can reuse the same counter-printing path. The counters are test-only observation; they do not affect style computation itself.
23 lines
692 B
HTML
23 lines
692 B
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<script src="_helpers.js"></script>
|
|
<style>
|
|
.anchor .descendant { color: red; }
|
|
</style>
|
|
<div class="anchor">
|
|
<div>
|
|
<span id="target">target</span>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
test(() => {
|
|
getComputedStyle(document.getElementById("target")).color;
|
|
internals.resetStyleInvalidationCounters();
|
|
|
|
// No :has() in any stylesheet: walk must not run, no matches should happen.
|
|
document.getElementById("target").classList.add("descendant");
|
|
getComputedStyle(document.getElementById("target")).color;
|
|
printCounters("after add .descendant (no :has() in sheet)");
|
|
});
|
|
</script>
|