diff options
author | Moonchild <moonchild@palemoon.org> | 2023-02-21 22:56:39 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2023-02-21 22:56:39 +0000 |
commit | f2ef28d09c65269029ee1ac5c65524a89423008a (patch) | |
tree | d9297e5ab1696bb50348971594b47a083c9b110f /layout | |
parent | b9f3a03a5fc9e96448b4856bd1f3ce4e799daedb (diff) | |
parent | e0226ccae6493e9e79631c31dee5755863a98c44 (diff) | |
download | uxp-f2ef28d09c65269029ee1ac5c65524a89423008a.tar.gz |
Merge pull request 'Improve :host and :host-context matching' (#2120) from FranklinDM/UXP-contrib:work_css-host-matching-fixes into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2120
Diffstat (limited to 'layout')
-rw-r--r-- | layout/style/nsCSSParser.cpp | 5 | ||||
-rw-r--r-- | layout/style/nsCSSPseudoClasses.cpp | 7 | ||||
-rw-r--r-- | layout/style/nsCSSPseudoClasses.h | 1 | ||||
-rw-r--r-- | layout/style/nsCSSRuleProcessor.cpp | 14 |
4 files changed, 21 insertions, 6 deletions
diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index c81de2d9f6..63a9bc0514 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -6547,6 +6547,11 @@ CSSParserImpl::ParsePseudoClassWithSelectorListArg(nsCSSSelector& aSelector, return eSelectorParsingStatus_Error; // our caller calls SkipUntil(')') } + if (nsCSSPseudoClasses::HasSingleSelectorArg(aType) && + slist->mNext) { + return eSelectorParsingStatus_Error; // our caller calls SkipUntil(')') + } + for (nsCSSSelectorList *l = slist; l; l = l->mNext) { nsCSSSelector *s = l->mSelectors; if (s == nullptr) { diff --git a/layout/style/nsCSSPseudoClasses.cpp b/layout/style/nsCSSPseudoClasses.cpp index a174525b1c..928326e399 100644 --- a/layout/style/nsCSSPseudoClasses.cpp +++ b/layout/style/nsCSSPseudoClasses.cpp @@ -102,6 +102,13 @@ nsCSSPseudoClasses::HasNthPairArg(Type aType) aType == Type::nthLastOfType; } +bool +nsCSSPseudoClasses::HasSingleSelectorArg(Type aType) +{ + return aType == Type::host || + aType == Type::hostContext; +} + void nsCSSPseudoClasses::PseudoTypeToString(Type aType, nsAString& aString) { diff --git a/layout/style/nsCSSPseudoClasses.h b/layout/style/nsCSSPseudoClasses.h index 4a4bbe188c..76fcef3f78 100644 --- a/layout/style/nsCSSPseudoClasses.h +++ b/layout/style/nsCSSPseudoClasses.h @@ -58,6 +58,7 @@ public: static Type GetPseudoType(nsIAtom* aAtom, EnabledState aEnabledState); static bool HasStringArg(Type aType); static bool HasNthPairArg(Type aType); + static bool HasSingleSelectorArg(Type aType); static bool HasForgivingSelectorListArg(Type aType) { return aType == Type::is || aType == Type::matches || diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 37d72a6037..909bfb0e81 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -1939,17 +1939,19 @@ static bool SelectorMatches(Element* aElement, // selector. // We match automatically if GetParent() and GetShadowRoot() have - // the same result. Without special casing this ahead of all other - // selector matching, it fails. Have not determined the cause. - - if (aElement->GetParent() == aElement->GetShadowRoot()) { + // the same result iff our selector list is empty. Without special + // casing this ahead of all other selector matching, it fails. + // Have not determined the cause. + if (!pseudoClass->u.mSelectorList && + aElement->GetParent() == aElement->GetShadowRoot()) { break; } // Match if any selector in the argument list matches. - + // FIXME: What this effectively does is bypass the "featureless" + // selector check under SelectorMatches. NodeMatchContext nodeContext(EventStates(), - nsCSSRuleProcessor::IsLink(aElement)); + aNodeMatchContext.mIsRelevantLink); if (SelectorListMatches(aElement, pseudoClass, nodeContext, |