Bug 1387905 part 1 - Count pseudo-element into specificity. r=heycam
authorXidorn Quan <me@upsuper.org>
Mon, 04 Sep 2017 12:05:56 +1000
changeset 378712 1e97d7f09985052a697a0a2eb39676dc4a6b875f
parent 378711 5e4c2725acf24257f81091625832806b4a8cef06
child 378713 dc82b0cabd216cb6901731ea28e6784ab40040f7
push id32439
push userarchaeopteryx@coole-files.de
push dateMon, 04 Sep 2017 09:11:52 +0000
treeherdermozilla-central@cef1935ebd9b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1387905
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1387905 part 1 - Count pseudo-element into specificity. r=heycam MozReview-Commit-ID: IWlINaYAhql
devtools/server/tests/mochitest/test_css-logic-specificity.html
layout/style/StyleRule.cpp
--- 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;
   }