Skip to content

Use native Stylo snapshots for ordinary DOM invalidation - #3737

Merged
ldm0 merged 1 commit into
mainfrom
refactor/native-snapshot-style-invalidation
Nov 25, 2026
Merged

ldm0 merged 1 commit into
mainfrom
refactor/native-snapshot-style-invalidation

Conversation

@ldm0

@ldm0 ldm0 commented Nov 25, 2026

Copy link
Copy Markdown
Member

Adopt Stylo's native snapshot invalidation for class, ID, data and ARIA attributes and element states in eligible connected documents. This includes focus and target changes with old-state snapshots.

  • Run the existing StateAndAttrInvalidationProcessor through ElementData::invalidate_style_if_needed. The host publishes the resulting hints to the demand-driven scheduler.
  • Preserve the first old values across each batch. An unstyled trigger can invalidate a cached sibling without acquiring persistent ElementData.
  • Record pruned hidden branches for subsequent CSSOM reads. Skip data and ARIA mutations with no dependency in the active cascade.
  • Keep the former and current parent subtrees when a mixed DOM batch makes the original selector relations unavailable.
  • Preserve the namespace of each attribute mutation. Structural mutations, Shadow DOM, relative selectors, nth-of-list dependencies, namespaced attributes, and selection changes with derived form validity still use their existing host paths.

Depends on lexmount/stylo#5. All Stylo workspace pins point at a93f106262e1bb48a923dbd717ed2713e75e8c4e.

Debug build comparison

Linux on 9fdbb2f226 with seven paired runs pinned to the same CPU. Timed rounds check the returned CSS values or layout widths.

Case Main Candidate
10,000 elements, sparse inherited color reads 45.5 ms 36.3 ms
10,000 elements, sparse descendant-selector reads 1066.0 ms 628.5 ms
10,000 elements, sparse reads below display:none 958.8 ms 16.5 ms
Attribute changes without a selector dependency 115.7 ms 105.8 ms
Mixed class and child-list mutations in realtime layout 125.4 ms 124.9 ms

Validation

  • cargo fmt --all
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • 666 focused style, layout and rendering tests passed.
  • cargo nextest run --no-fail-fast passed all 24,478 tests, with 20 skipped.

@ldm0
ldm0 marked this pull request as ready for review November 25, 2026 19:26
@ldm0
ldm0 merged commit a7c21e7 into main Nov 25, 2026
6 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant