Support complex selectors in :not()
Until now we've only supported a single compound selector as an argument to :not(). This CL adds support for complex selectors, based on the recent work on :is() and :where(). Parsing ------- Note that unlike :is() and :where(), :not() does not use the forgiving selector list behavior, but instead fails parsing the normal way. CSSSelectorParser now has both ConsumeNestedSelectorList and ConsumeForgivingNestedSelectorList for the two behaviors. Our ShadowDOMv0-disabling logic should apply to complex :not() as well, but for backwards compatibility, we need to allow it whenever :not() _doesn't_ have a complex argument. The TreatAsNonComplexArgumentToNot() was added to detect this, which replaces the previous function CSSParserSelector::IsSimple. (When v0 is removed, we can remove this mess as well). Invalidation ------------ There was a bug in ExtractInvalidationSetFeaturesFromSelectorList: we're supposed to ignore any extracted features inside a :not(). For example, for ".a :not(.b)", we should not add ".b" to the invalidation set for ".a". In ExtractInvalidationSetFeaturesFrom- SelectorList there was code that attempted to block the inner features from "crossing" the :not()-boundary, but it incorrectly used the *outer* pseudo-type. In other words, when considering ":not(.b)", the pseudo-type would be kUnknown, since we are not (yet) inside the :not(). Instead what we need to do is check the pseudo-type of of the currently held simple selector. Now that we "block" inner features correctly at the :not() boundary, the check in ExtractInvalidationSetFeaturesFromCompound is not needed anymore. This in turns means we can remove several PseudoType params, which is nice. Matching -------- Now traverses a CSSSelectorList and uses MatchSelector. Beyond that it just works. Bug: 1139865 Change-Id: Iea5513445e54303ba0685cffc3b52dabc115b7f1 I2S: https://groups.google.com/a/chromium.org/g/blink-dev/c/0alTkXvDCL8/m/-ClOGvOJBAAJ Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2507549 Reviewed-by:Rune Lillesveen <futhark@chromium.org> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/master@{#823161}
Loading
Please register or sign in to comment