Closed Bug 1387905 Opened 2 years ago Closed 2 years ago

stylo: Algorithm for specificity is different causes devtools test to fail

Categories

(Core :: CSS Parsing and Computation, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: xidorn, Assigned: xidorn)

References

Details

Attachments

(2 files)

devtools/server/tests/mochitest/test_css-logic-specificity.html fails because stylo and gecko use different algorithm to calculate specificity.

It seems the difference is that, in Gecko, each level of specificity uses 8bits [1], while in Stylo, each level uses 10bits [2].

I guess we can probably change Gecko's behavior (as well as devtools') in this case.


[1] https://searchfox.org/mozilla-central/rev/b52285fffc13f36eca6b47de735d4e4403b3859e/layout/style/StyleRule.cpp#487-542
[2] https://searchfox.org/mozilla-central/rev/b52285fffc13f36eca6b47de735d4e4403b3859e/servo/components/selectors/builder.rs#232-249
Blocks: stylo-devtools-tests
No longer blocks: stylo-mochitest
Priority: -- → P2
Priority: P2 → P3
Assignee: nobody → xidorn+moz
Comment on attachment 8904094 [details]
Bug 1387905 part 1 - Count pseudo-element into specificity.

https://reviewboard.mozilla.org/r/175850/#review180832
Attachment #8904094 - Flags: review?(cam) → review+
Comment on attachment 8904095 [details]
Bug 1387905 part 2 - Use 10bit for specificity in Gecko as well.

https://reviewboard.mozilla.org/r/175852/#review180836

::: devtools/server/tests/mochitest/test_css-logic-specificity.html:39
(Diff revision 1)
> -      {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: "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}

FWIW it might be nicer to write these constant values in the test in hex, then it would be easier to confirm by eye that they make sense.
Attachment #8904095 - Flags: review?(cam) → review+
Comment on attachment 8904095 [details]
Bug 1387905 part 2 - Use 10bit for specificity in Gecko as well.

https://reviewboard.mozilla.org/r/175852/#review180836

> FWIW it might be nicer to write these constant values in the test in hex, then it would be easier to confirm by eye that they make sense.

Previously, probably yes it would be more readable in hex, but now it may not be that case... If we can use some base32 representation, that would be readable again :)
Pushed by xquan@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1e97d7f09985
part 1 - Count pseudo-element into specificity. r=heycam
https://hg.mozilla.org/integration/autoland/rev/dc82b0cabd21
part 2 - Use 10bit for specificity in Gecko as well. r=heycam
You need to log in before you can comment on or make changes to this bug.