Issue #1592 - Part 4: Walk ::slotted()-containing rules for slottables

- Check against all selector parts and not the leftmost selector only for ::slotted()
- Walk rules for ::slotted() regardless if the shadow root is opened/closed
- Ensure that ::slotted() rules are walked in the right order
- Fix ::slotted inheritance from topmost shadow root
This commit is contained in:
FranklinDM 2023-03-18 12:43:51 +08:00 committed by roytam1
commit 518c41fd7a
3 changed files with 104 additions and 47 deletions

View file

@ -371,6 +371,9 @@ struct MOZ_STACK_CLASS TreeMatchContext {
// match.
bool mOnlyMatchHostPseudo;
// Restrict matching to selectors that contain a :slotted() pseudo-class.
bool mRestrictToSlottedPseudo;
// Root of scoped stylesheet (set and unset by the supplier of the
// scoped stylesheet).
nsIContent* mScopedRoot;
@ -403,6 +406,9 @@ struct MOZ_STACK_CLASS TreeMatchContext {
// for an HTML5 scoped style sheet.
bool mForScopedStyle;
// Whether we're currently in the topmost scope for shadow DOM.
bool mIsTopmostScope;
enum MatchVisited {
eNeverMatchVisited,
eMatchVisitedDefault
@ -429,6 +435,7 @@ struct MOZ_STACK_CLASS TreeMatchContext {
, mVisitedHandling(aVisitedHandling)
, mDocument(aDocument)
, mOnlyMatchHostPseudo(false)
, mRestrictToSlottedPseudo(false)
, mScopedRoot(nullptr)
, mIsHTMLDocument(aDocument->IsHTMLDocument())
, mCompatMode(aDocument->GetCompatibilityMode())
@ -436,6 +443,7 @@ struct MOZ_STACK_CLASS TreeMatchContext {
, mSkippingParentDisplayBasedStyleFixup(false)
, mForScopedStyle(false)
, mCurrentStyleScope(nullptr)
, mIsTopmostScope(false)
{
if (aMatchVisited != eNeverMatchVisited) {
nsILoadContext* loadContext = mDocument->GetLoadContext();