Bug 1387905 part 1 - Count pseudo-element into specificity. r?heycam
MozReview-Commit-ID: IWlINaYAhql
--- a/devtools/server/tests/mochitest/test_css-logic-specificity.html
+++ b/devtools/server/tests/mochitest/test_css-logic-specificity.html
@@ -30,17 +30,17 @@ Test that css-logic calculates CSS speci
{text: "LI.red.level", expected: 513},
{text: ".red .level", expected: 512},
{text: "#x34y", expected: 65536},
{text: "#s12:not(FOO)", expected: 65537},
{text: "body#home div#warning p.message", expected: 131331},
{text: "* body#home div#warning p.message", expected: 131331},
{text: "#footer :not(nav) li", expected: 65538},
{text: "bar:nth-child(n)", expected: 257},
- {text: "li::-moz-list-number", expected: 1},
+ {text: "li::-moz-list-number", expected: 2},
{text: "a:hover", expected: 257}
];
function createDocument() {
let text = TEST_DATA.map(i=>i.text).join(",");
text = '<style type="text/css">' + text + " {color:red;}</style>";
// eslint-disable-next-line no-unsanitized/property
document.body.innerHTML = text;
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -498,16 +498,19 @@ int32_t nsCSSSelector::CalcWeightWithout
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 (IsPseudoElement()) {
+ weight += 0x000001;
+ }
if (nullptr != mCasedTag) {
weight += 0x000001;
}
nsAtomList* list = mIDList;
while (nullptr != list) {
weight += 0x010000;
list = list->mNext;
}