Bug 1387905 part 2 - Use 10bit for specificity in Gecko as well. r=heycam

MozReview-Commit-ID: G5qq0FY0HQ8

--HG--
extra : rebase_source : 2572ad7845c4275d0f0a580204697e6ee87a4a5f
This commit is contained in:
Xidorn Quan 2017-09-04 12:07:24 +10:00
parent 441c9db551
commit 372bd402fb
4 changed files with 21 additions and 22 deletions

View File

@ -1119,9 +1119,9 @@ CssSelector.prototype = {
if (this.elementStyle) {
// We can't ask specificity from DOMUtils as element styles don't provide
// CSSStyleRule interface DOMUtils expect. However, specificity of element
// style is constant, 1,0,0,0 or 0x01000000, just return the constant
// style is constant, 1,0,0,0 or 0x40000000, just return the constant
// directly. @see http://www.w3.org/TR/CSS2/cascade.html#specificity
return 0x01000000;
return 0x40000000;
}
if (this._specificity) {

View File

@ -34,7 +34,6 @@ support-files =
[test_css-logic.html]
[test_css-logic-media-queries.html]
[test_css-logic-specificity.html]
fail-if = stylo # bug 1387905
[test_css-properties.html]
[test_Debugger.Source.prototype.introductionScript.html]
[test_Debugger.Source.prototype.introductionType.html]

View File

@ -25,18 +25,18 @@ Test that css-logic calculates CSS specificity properly
{text: "LI", expected: 1},
{text: "UL LI", expected: 2},
{text: "UL OL + LI", expected: 3},
{text: "H1 + [REL=\"up\"]", expected: 257},
{text: "UL OL LI.red", expected: 259},
{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: "H1 + [REL=\"up\"]", expected: 1025},
{text: "UL OL LI.red", expected: 1027},
{text: "LI.red.level", expected: 2049},
{text: ".red .level", expected: 2048},
{text: "#x34y", expected: 1048576},
{text: "#s12:not(FOO)", expected: 1048577},
{text: "body#home div#warning p.message", expected: 2098179},
{text: "* body#home div#warning p.message", expected: 2098179},
{text: "#footer :not(nav) li", expected: 1048578},
{text: "bar:nth-child(n)", expected: 1025},
{text: "li::-moz-list-number", expected: 2},
{text: "a:hover", expected: 257}
{text: "a:hover", expected: 1025}
];
function createDocument() {
@ -75,8 +75,8 @@ Test that css-logic calculates CSS specificity properly
info("Testing specificity of element.style");
let colorProp = cssLogic.getPropertyInfo("background");
is(colorProp.matchedSelectors[0].specificity, 0x01000000,
"Element styles have specificity of 0x01000000 (16777216).");
is(colorProp.matchedSelectors[0].specificity, 0x40000000,
"Element styles have specificity of 0x40000000 (1073741824).");
SimpleTest.finish();
};

View File

@ -504,14 +504,14 @@ int32_t nsCSSSelector::CalcWeightWithoutNegations() const
"after them, specificity calculation must be updated");
if (IsPseudoElement()) {
weight += 0x000001;
weight += 1;
}
if (nullptr != mCasedTag) {
weight += 0x000001;
weight += 1;
}
nsAtomList* list = mIDList;
while (nullptr != list) {
weight += 0x010000;
weight += 1 << 20;
list = list->mNext;
}
list = mClassList;
@ -523,7 +523,7 @@ int32_t nsCSSSelector::CalcWeightWithoutNegations() const
}
#endif
while (nullptr != list) {
weight += 0x000100;
weight += 1 << 10;
list = list->mNext;
}
// FIXME (bug 561154): This is incorrect for :-moz-any(), which isn't
@ -533,12 +533,12 @@ int32_t nsCSSSelector::CalcWeightWithoutNegations() const
// highest-specificity options first).
nsPseudoClassList *plist = mPseudoClassList;
while (nullptr != plist) {
weight += 0x000100;
weight += 1 << 10;
plist = plist->mNext;
}
nsAttrSelector* attr = mAttrList;
while (nullptr != attr) {
weight += 0x000100;
weight += 1 << 10;
attr = attr->mNext;
}
return weight;