Upon matching a selector, instead of returning a true/false answer, we should be able to return a Branched value depending on the Context. This would allow faster re-matching on context change.
With that, we should be able to build a rules tree (Cascade) where rules appears in an element's associated list not only if it matches, but if it may match in at least one context. Then, we can share rule trees between context and get faster style computing in new context (at the cost of needing to evaluate context on branched values even for the default cascade).
We may need a way to store context efficiently, specifically for selectors like :focus-within that may match a huge number of contexts...
Upon matching a selector, instead of returning a true/false answer, we should be able to return a Branched value depending on the Context. This would allow faster re-matching on context change.
With that, we should be able to build a rules tree (Cascade) where rules appears in an element's associated list not only if it matches, but if it may match in at least one context. Then, we can share rule trees between context and get faster style computing in new context (at the cost of needing to evaluate context on branched values even for the default cascade).
We may need a way to store context efficiently, specifically for selectors like
:focus-withinthat may match a huge number of contexts...