summaryrefslogtreecommitdiff
path: root/layout/style/nsCSSRuleProcessor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'layout/style/nsCSSRuleProcessor.cpp')
-rw-r--r--layout/style/nsCSSRuleProcessor.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp
index f49b9d3258..15838f411e 100644
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1622,7 +1622,8 @@ StateSelectorMatches(Element* aElement,
static bool AnySelectorInArgListMatches(Element* aElement,
nsPseudoClassList* aList,
NodeMatchContext& aNodeMatchContext,
- TreeMatchContext& aTreeMatchContext);
+ TreeMatchContext& aTreeMatchContext,
+ bool aIsForgiving = false);
static bool
StateSelectorMatches(Element* aElement,
@@ -1886,7 +1887,21 @@ static bool SelectorMatches(Element* aElement,
}
break;
+ case CSSPseudoClassType::is:
+ case CSSPseudoClassType::matches:
case CSSPseudoClassType::any:
+ case CSSPseudoClassType::where:
+ {
+ if (!AnySelectorInArgListMatches(aElement, pseudoClass,
+ aNodeMatchContext,
+ aTreeMatchContext,
+ true)) {
+ return false;
+ }
+ }
+ break;
+
+ case CSSPseudoClassType::mozAny:
{
if (!AnySelectorInArgListMatches(aElement, pseudoClass,
aNodeMatchContext,
@@ -2355,11 +2370,17 @@ static bool SelectorMatches(Element* aElement,
static bool AnySelectorInArgListMatches(Element* aElement,
nsPseudoClassList* aList,
NodeMatchContext& aNodeMatchContext,
- TreeMatchContext& aTreeMatchContext)
+ TreeMatchContext& aTreeMatchContext,
+ bool aIsForgiving)
{
nsCSSSelectorList *l;
for (l = aList->u.mSelectors; l; l = l->mNext) {
nsCSSSelector *s = l->mSelectors;
+ if (s == nullptr) {
+ MOZ_ASSERT(aIsForgiving,
+ "unexpected empty selector in unforgiving selector list");
+ return false;
+ }
MOZ_ASSERT(!s->mNext && !s->IsPseudoElement(),
"parser failed");
if (SelectorMatches(
@@ -3494,12 +3515,10 @@ AddSelector(RuleCascadeData* aCascade,
}
}
- // Recur through any :-moz-any or :host-context selectors
+ // Recur through any pseudo-class that has a selector list argument.
for (nsPseudoClassList* pseudoClass = negation->mPseudoClassList;
pseudoClass; pseudoClass = pseudoClass->mNext) {
- if (pseudoClass->mType == CSSPseudoClassType::any ||
- pseudoClass->mType == CSSPseudoClassType::host ||
- pseudoClass->mType == CSSPseudoClassType::hostContext) {
+ if (nsCSSPseudoClasses::HasSelectorListArg(pseudoClass->mType)) {
for (nsCSSSelectorList *l = pseudoClass->u.mSelectors; l; l = l->mNext) {
nsCSSSelector *s = l->mSelectors;
if (!AddSelector(aCascade, aSelectorInTopLevel, s,