mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
The tricky part of :is() and :where() is that they can have combinators inside, so something like this is valid: foo:is(#bar > .baz) ~ taz The current invalidation logic is based on the assumption that you can represent a combinator as a (selector, offset) tuple, which are stored in the Dependency struct. This assumption breaks with :is() and :where(), so we need to make them be able to represent a combinator in an "inner" selector. For this purpose, we add a `parent` dependency. With it, when invalidating inside the `:is()` we can represent combinators inside as a stack. The basic idea is that, for the example above, when an id of "bar" is added or removed, we'd find a dependency like: Dependency { selector: #bar > .baz, offset: 1, // pointing to the `>` combinator parent: Some(Dependency { selector: foo:is(#bar > .baz) > taz, offset: 1, // Pointing to the `~` combinator. parent: None, }) } That way, we'd start matching at the element that changed, towards the right, and if we find an element that matches .baz, instead of invalidating that element, we'd look at the parent dependency, then double-check that the whole left-hand-side of the selector (foo:is(#bar > .baz)) actually changed, and then keep invalidating to the right using the parent dependency as usual. This patch only builds the data structure and keeps the code compiling, the actual invalidation work will come in a following patch. Differential Revision: https://phabricator.services.mozilla.com/D71421 |
||
---|---|---|
.. | ||
element | ||
media_queries.rs | ||
mod.rs | ||
stylesheets.rs |