Reorganize CSS cascading for higher shadow DOM scopes.
This reorganizes the CSS cascading for shadow DOM scopes above the
element's scope so that we do everything one scope at a time, rather
than dealing separately with UA shadow pseudo element styles and
::part() styles. I'm only aware of one case where this changes
currently-exposed behavior (the cascading of :host::part() selectors
relative to other selectors in the same scope), but it also changes the
implementation to be closer to the way the specifications describe
cascading so that it will extend better to additional features in the
future.
This changes the bucketing approach in RuleSet for a shadow
pseudo-element after ::part() by using the bucket for the innermost
pseudo-element rather than the part bucket. (We should perhaps have
similar changes for ::slotted() as well, but this does not make those.)
These changes are behind the (status:stable) CSSCascadeCorrectScope
flag, in case we need to disable them. Supporting this flag involves a
bit of code duplication: while MatchHigherScopeRules and
MatchPseudoPartRules probably could have been the same function, the
number and complexity of flag conditions probably would have made them
unreadable, so it seemed better to separate them.
This also fixes (without a flag) an interaction in
::slotted()::picker(select) by checking FollowsSlotted as for other
pseudo-elements. (::picker(select) has not yet shipped.) However, this
doesn't actually fix a test of this interaction,
https://crbug.com/366415131 is to follow up on this.
This also (again, without a flag) makes two changes to the bucketing
optimizations in RuleSet for unshipped features:
- bucket ::details-content, which was not previously done
- don't skip bucketing for ::picker(X) where X is not select; instead
rely on matching to fail later
Fixed: 1479329
Bug: 1469418, 356158098, 366415131
Change-Id: I148f8240dbaa20e33bb455c8b65732881767ca3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5851273
Reviewed-by: Daniel Cheng dcheng@chromium.org
Reviewed-by: Rune Lillesveen futhark@chromium.org
Commit-Queue: Daniel Cheng dcheng@chromium.org
Auto-Submit: David Baron dbaron@chromium.org
Cr-Commit-Position: refs/heads/main@{#1358283}