perf(renderer): drop group-has-[:focus-visible] rules that restyle whole subtrees (#36098)

Fixes #34312. Takes over naufaldi/orca#1 by @naufaldi, with the main.css part dropped because #34932 already covers it.

- SshTargetCard and the reasoning chevron now use the scoped `[[class~='group/x']:has(:focus-visible)_&]` shape. Tailwind's `group-has-*` compiles to a non-subject `:has()` whose subject is `*`, and that rule made Blink restyle whole subtrees on every mutation. This change is the entire measured win: 19.4 → 1.6 ms, 12.5 → 3.6 ms and 8.0 → 2.4 ms per mutation.
- rich-markdown-editor.css drops a redundant `:has()` on the TOC header, as defence in depth.
- Adds a guard, check-has-restyle-scope.mjs. It compiles the renderer's Tailwind CSS, adds plain stylesheets and the listed vendor stylesheets, and fails on any non-subject `:has()` whose subject has no class, id or attribute. Three pdf.js rules are baselined after being measured as harmless. It runs in lint, check:changed and PR CI in about 1.5 s.

Co-authored-by: Naufaldi <naufaldi.rafif@gmail.com>
This commit is contained in:
Neil
2026-10-29 14:31:45 -07:00
committed by GitHub
co-authored by Naufaldi
parent 2da0aaae61
commit 19f6c10c3f
9 changed files with 343 additions and 3 deletions
+4
View File
@@ -376,6 +376,10 @@ jobs:
if: needs.code_paths.outputs.static_analysis == 'true'
run: node config/scripts/check-reliability-gates.mjs
- name: Check compiled CSS :has() restyle scope
if: needs.code_paths.outputs.static_analysis == 'true'
run: node config/scripts/check-has-restyle-scope.mjs
- name: Enforce dead design-system classes
if: needs.code_paths.outputs.static_analysis == 'true'
run: node node_modules/oxlint/bin/oxlint --config config/oxlint-dead-classes.json src/renderer