Skip to content

Commit 0a4aca0

Browse files
authored
Limit checked selection styles to radio cards (#3367)
Small optimization. `:checked ~ *` is too broad a selector, causes unnecessary layouts in Firefox.
1 parent 700ff8b commit 0a4aca0

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎app/ui/styles/themes/selection.css‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,21 @@
1111
* requiring each individual component to implement styles for it
1212
*
1313
* This file is _not_ automatically generated
14+
*
15+
* The checked-sibling selector is deliberately scoped to `.ox-radio-card`
16+
* rather than `*`. A bare `*` on the right of `~` gets evaluated against every
17+
* element in the document, and Gecko then flags every parent as having
18+
* sibling-dependent children. Removing a child from such a parent restyles all
19+
* of its later siblings and their subtrees, so removing the top rows of a
20+
* virtualized list (audit log, on scroll) restyled every remaining row: ~20ms
21+
* per scroll step in Firefox, most of the main-thread time during a fling.
22+
* Stylo sets the flag whenever a sibling combinator is evaluated, matched or
23+
* not: https://github.com/servo/stylo/blob/11cc72d/selectors/matching.rs#L885-L889
24+
* and https://github.com/servo/stylo/blob/11cc72d/selectors/matching.rs#L43-L46
25+
* Gecko acts on it in RestyleManager::RestyleForRemove (layout/base/RestyleManager.cpp).
1426
*/
1527
.is-selected,
16-
:checked ~ * {
28+
:checked ~ .ox-radio-card {
1729
--content-default: var(--theme-accent-800);
1830
--content-secondary: var(--theme-accent-700);
1931
--content-tertiary: var(--theme-accent-700);

0 commit comments

Comments
 (0)