Skip to content

Index style rules by their rightmost simple selector#4163

Draft
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:css-rule-indexing
Draft

Index style rules by their rightmost simple selector#4163
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:css-rule-indexing

Conversation

@vogella

@vogella vogella commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

computeStyle tested every selector alternative of every rule against every element, the main cost of a theme swap. A new RuleIndex buckets each alternative by the id, class, or element type its rightmost compound requires (universal, attribute-only and pseudo-only alternatives go into a remainder bucket consulted for every element), and the matcher now runs only on the candidates an element can possibly match, in unchanged cascade order. Styling results are identical: match positions are preserved, and the new RuleIndexTest locks the invariant that the index never drops an alternative the matcher would accept, checked over a stylesheet covering every selector shape.

Measured with a workbench theme-swap benchmark (20 editors, about 4000 widgets, 10 swap rounds per direction), engine applyStyles time fell from 196.6 to 155.6 microseconds per call and from 3.34 to 2.65 seconds per swap, about 21 percent less styling work per theme change, with identical call counts confirming unchanged behavior.

Part of #3980.

computeStyle tested every selector alternative of every rule against
every element. RuleIndex buckets each alternative by the id, class, or
element type its rightmost compound requires; alternatives without such
a key (universal, attribute-only or pseudo-only compounds) go into a
remainder bucket consulted for every element. A lookup gathers the
buckets the element satisfies and hands the candidates to the matcher
in cascade order, so match positions and cascade results are unchanged.
RuleIndexTest locks the completeness invariant: over a stylesheet
covering every selector shape, the index never drops an alternative the
matcher would accept.
vogella added a commit to vogella/eclipse.platform.ui that referenced this pull request Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Test Results

   858 files  + 3     858 suites  +3   50m 8s ⏱️ -1s
 8 106 tests + 4   7 863 ✅ + 4  243 💤 ±0  0 ❌ ±0 
20 220 runs  +12  19 566 ✅ +12  654 💤 ±0  0 ❌ ±0 

Results for commit d7e0de4. ± Comparison against base commit 68e20f6.

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