diff --git a/layout/reftests/scoped-style/reftest.list b/layout/reftests/scoped-style/reftest.list index 9ca6548c26a..6e80adfcd77 100644 --- a/layout/reftests/scoped-style/reftest.list +++ b/layout/reftests/scoped-style/reftest.list @@ -49,3 +49,6 @@ HTTP(..) == scoped-style-font-face.html scoped-style-font-face-ref.html == scoped-style-keyframes.html scoped-style-keyframes-ref.html pref(layout.css.supports-rule.enabled,true) == scoped-style-supports.html scoped-style-supports-ref.html +== scoped-style-pseudo-001.html scoped-style-pseudo-001-ref.html +== scoped-style-pseudo-002.html scoped-style-pseudo-002-ref.html +== scoped-style-pseudo-003.html scoped-style-pseudo-003-ref.html diff --git a/layout/reftests/scoped-style/scoped-style-pseudo-001-ref.html b/layout/reftests/scoped-style/scoped-style-pseudo-001-ref.html new file mode 100644 index 00000000000..3f763ef4bee --- /dev/null +++ b/layout/reftests/scoped-style/scoped-style-pseudo-001-ref.html @@ -0,0 +1,6 @@ + + +

First

+

Second

+

Third

+ diff --git a/layout/reftests/scoped-style/scoped-style-pseudo-001.html b/layout/reftests/scoped-style/scoped-style-pseudo-001.html new file mode 100644 index 00000000000..1eea542d4c9 --- /dev/null +++ b/layout/reftests/scoped-style/scoped-style-pseudo-001.html @@ -0,0 +1,11 @@ + + +

First

+

+ + Second +

+

Third

+ diff --git a/layout/reftests/scoped-style/scoped-style-pseudo-002-ref.html b/layout/reftests/scoped-style/scoped-style-pseudo-002-ref.html new file mode 100644 index 00000000000..c6cd0178f2b --- /dev/null +++ b/layout/reftests/scoped-style/scoped-style-pseudo-002-ref.html @@ -0,0 +1,8 @@ + + +

First

+

+

Second
+

+

Third

+ diff --git a/layout/reftests/scoped-style/scoped-style-pseudo-002.html b/layout/reftests/scoped-style/scoped-style-pseudo-002.html new file mode 100644 index 00000000000..409d792ce98 --- /dev/null +++ b/layout/reftests/scoped-style/scoped-style-pseudo-002.html @@ -0,0 +1,16 @@ + + +

First

+

+ +

+ + Second +
+

+

Third

+ diff --git a/layout/reftests/scoped-style/scoped-style-pseudo-003-ref.html b/layout/reftests/scoped-style/scoped-style-pseudo-003-ref.html new file mode 100644 index 00000000000..04371a8efed --- /dev/null +++ b/layout/reftests/scoped-style/scoped-style-pseudo-003-ref.html @@ -0,0 +1,6 @@ + + +

First

+

Second

+

Third

+ diff --git a/layout/reftests/scoped-style/scoped-style-pseudo-003.html b/layout/reftests/scoped-style/scoped-style-pseudo-003.html new file mode 100644 index 00000000000..d24b9402d7f --- /dev/null +++ b/layout/reftests/scoped-style/scoped-style-pseudo-003.html @@ -0,0 +1,11 @@ + + +

First

+

+ + Second +

+

Third

+ diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 1883e68825f..be6f4fcbedd 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -2030,7 +2030,18 @@ static bool SelectorMatches(Element* aElement, break; case nsCSSPseudoClasses::ePseudoClass_scope: - if (aTreeMatchContext.HasSpecifiedScope()) { + if (aTreeMatchContext.mForScopedStyle) { + if (aTreeMatchContext.mCurrentStyleScope) { + // If mCurrentStyleScope is null, aElement must be the style + // scope root. This is because the PopStyleScopeForSelectorMatching + // call in SelectorMatchesTree sets mCurrentStyleScope to null + // as soon as we visit the style scope element, and we won't + // progress further up the tree after this call to + // SelectorMatches. Thus if mCurrentStyleScope is still set, + // we know the selector does not match. + return false; + } + } else if (aTreeMatchContext.HasSpecifiedScope()) { if (!aTreeMatchContext.IsScopeElement(aElement)) { return false; } diff --git a/layout/style/nsRuleProcessorData.h b/layout/style/nsRuleProcessorData.h index 368f0d58ccb..c6b138a07a3 100644 --- a/layout/style/nsRuleProcessorData.h +++ b/layout/style/nsRuleProcessorData.h @@ -159,8 +159,8 @@ struct NS_STACK_CLASS TreeMatchContext { bool PopStyleScopeForSelectorMatching(mozilla::dom::Element* aElement) { - NS_ASSERTION(mForScopedStyle, "only call PopScopeForSelectorMatching when " - "mForScopedStyle is true"); + NS_ASSERTION(mForScopedStyle, "only call PopStyleScopeForSelectorMatching " + "when mForScopedStyle is true"); if (!mCurrentStyleScope) { return false;