From 88aef1f5fa95b15d709aefbc815443c4f81f7101 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 3 Jun 2014 11:38:38 -0400 Subject: [PATCH] Bug 1016063. Don't include the fake classnames XUL tree pseudo-elements have when calculating style rule specificity. r=heycam --- layout/style/StyleRule.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp index c62c93486fe0..ab69b798c126 100644 --- a/layout/style/StyleRule.cpp +++ b/layout/style/StyleRule.cpp @@ -473,10 +473,19 @@ int32_t nsCSSSelector::CalcWeightWithoutNegations() const { int32_t weight = 0; - MOZ_ASSERT(!IsPseudoElement() || - mPseudoType >= nsCSSPseudoElements::ePseudo_PseudoElementCount || - (!mIDList && !mClassList && !mAttrList), - "if pseudo-elements can have ID, class or attribute selectors " +#ifdef MOZ_XUL + MOZ_ASSERT(!(IsPseudoElement() && + PseudoType() != nsCSSPseudoElements::ePseudo_XULTree && + mClassList), + "If non-XUL-tree pseudo-elements can have class selectors " + "after them, specificity calculation must be updated"); +#else + MOZ_ASSERT(!(IsPseudoElement() && mClassList), + "If pseudo-elements can have class selectors " + "after them, specificity calculation must be updated"); +#endif + MOZ_ASSERT(!(IsPseudoElement() && (mIDList || mAttrList)), + "If pseudo-elements can have id or attribute selectors " "after them, specificity calculation must be updated"); if (nullptr != mCasedTag) { @@ -488,6 +497,13 @@ int32_t nsCSSSelector::CalcWeightWithoutNegations() const list = list->mNext; } list = mClassList; +#ifdef MOZ_XUL + // XUL tree pseudo-elements abuse mClassList to store some private + // data; ignore that. + if (PseudoType() == nsCSSPseudoElements::ePseudo_XULTree) { + list = nullptr; + } +#endif while (nullptr != list) { weight += 0x000100; list = list->mNext;