mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
When matching ::part(), only consider shadow trees whose host lies in the same style scope as the rule. Use MatchContext::rule_shadow_root, which is already set when collecting ::part() rules, as that scope. For cross-scope rules, accept a candidate shadow root only if its host's containing_shadow_root() matches the rule's shadow root: the rule's scope is the document when rule_shadow_root is null, or that shadow root when the rule comes from its stylesheet. The one exception is :host::part(): the rule and the part live in the same shadow root, so its host is outside the rule's scope and the comparison would never pass. Allow the check to be skipped for this case by setting MatchContext::for_host_part_matching when the compound selector contains :host (directly or inside :is(), which is how CSS nesting resolves &::part() inside a :host rule). Run that :host pre-scan only when rule_shadow_root is set. Document rules never use the same-shadow-root exception; scanning would otherwise set for_host_part_matching whenever :host appears in the compound and break cross-scope ::part() matching (e.g. multiple-scopes). Previously the engine walked all ancestor shadow roots without this cross-scope check.
75 KiB
75 KiB