Skip to content

Always expect deg in CSS calc NaN unit tests#38825

Closed
CanadaHonk wants to merge 1 commit intoweb-platform-tests:masterfrom
CanadaHonk:patch-2
Closed

Always expect deg in CSS calc NaN unit tests#38825
CanadaHonk wants to merge 1 commit intoweb-platform-tests:masterfrom
CanadaHonk:patch-2

Conversation

@CanadaHonk
Copy link
Copy Markdown
Contributor

@CanadaHonk CanadaHonk commented Mar 6, 2023

According to the spec: https://www.w3.org/TR/css-values-3/#compat

When serializing computed values [CSSOM], compatible units (those related by a static multiplicative factor, like the 96:1 factor between px and in, or the computed font-size factor between em and px) are converted into a single canonical unit.

But in the tests for NaN with units (L17-19), it is checked to be the same as the unit given, not the canonical unit (deg)? Safari would now pass, and Chrome would fail.

Solves #38821. This might be better as a downstream (Gecko) change, please let me know which would be best. (https://phabricator.services.mozilla.com/D171658)

@CanadaHonk CanadaHonk changed the title Always expect deg in CSS calc NaN unit tests (#38821) Always expect deg in CSS calc NaN unit tests Mar 6, 2023
@CanadaHonk
Copy link
Copy Markdown
Contributor Author

Think this is correct now, closing.

@CanadaHonk CanadaHonk closed this Mar 6, 2023
@dbaron
Copy link
Copy Markdown
Member

dbaron commented Mar 6, 2023

Yes, these tests are testing serialization of specified values, not serialization of computed values, so the units should be preserved as specified. The canonicalization of units happens at value computation time.

@CanadaHonk
Copy link
Copy Markdown
Contributor Author

Sorry for the confusion, thanks for the clarification. Might add some dedicated new tests in a Gecko patch later as most (2/3) vendors don't do this yet.

@CanadaHonk
Copy link
Copy Markdown
Contributor Author

@dbaron
Copy link
Copy Markdown
Member

dbaron commented Mar 6, 2023

From a very quick look at the spec, it looks like those steps are referenced both from parsing rules and computed value rules. In other words, they affect both specified values and computed values.

I think this makes sense because, due to other simplifications, they can affect specified and computed values differently. For example, I think (based on executing the spec in my head, and just doing some bits from memory!) font-size: calc(3em + 12pt + 5px) should be transformed by the calc simplification rules into font-size: calc(3em + 21px) as a specified value, but as a computed value it will depend on the inherited font size (for example, if the inherited font size is 16px then it will be simplified into font-size: 69px).

@tabatkins
Copy link
Copy Markdown
Contributor

Right, math functions eagerly simplify/canonicalize to the extent possible, given the value stage they're at. So a unit in calc() is always turned into the canonical unit if possible.

And for these tests in particular, Step 2 of the serialization algo is explicit about how to serialize infinite and NaN values - always produce a string that looks like calc(NaN * 1unit), where "unit" is the canonical unit for the type. So this PR is correct - all of them should be calc(NaN * 1deg).

@tabatkins tabatkins reopened this Mar 6, 2023
@CanadaHonk
Copy link
Copy Markdown
Contributor Author

I will probably leave this changes for Gecko patch (https://phabricator.services.mozilla.com/D171658) and for the bot to upstream if that sounds good.

@tabatkins tabatkins enabled auto-merge (squash) March 6, 2023 18:24
@tabatkins tabatkins disabled auto-merge March 6, 2023 18:24
@tabatkins
Copy link
Copy Markdown
Contributor

Okay, I'll leave merging to you.

@CanadaHonk
Copy link
Copy Markdown
Contributor Author

Closing in favor of completing in Gecko downstream.

@CanadaHonk CanadaHonk closed this Mar 6, 2023
moz-wptsync-bot pushed a commit that referenced this pull request Mar 7, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see #38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1820407
gecko-commit: 64d14248fe9046e5cbc58931abf366b3e62d43da
gecko-reviewers: emilio
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Mar 7, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see web-platform-tests/wpt#38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658
moz-wptsync-bot pushed a commit that referenced this pull request Mar 7, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see #38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1820407
gecko-commit: 64d14248fe9046e5cbc58931abf366b3e62d43da
gecko-reviewers: emilio
marcoscaceres pushed a commit that referenced this pull request Mar 28, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see #38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1820407
gecko-commit: 64d14248fe9046e5cbc58931abf366b3e62d43da
gecko-reviewers: emilio
cookiecrook pushed a commit to cookiecrook/wpt that referenced this pull request Apr 8, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see web-platform-tests#38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1820407
gecko-commit: 64d14248fe9046e5cbc58931abf366b3e62d43da
gecko-reviewers: emilio
aosmond pushed a commit to aosmond/gecko that referenced this pull request May 18, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see web-platform-tests/wpt#38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658
Loirooriol pushed a commit to Loirooriol/servo that referenced this pull request Nov 3, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see web-platform-tests/wpt#38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658
Loirooriol pushed a commit to Loirooriol/servo that referenced this pull request Nov 3, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see web-platform-tests/wpt#38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658
Loirooriol pushed a commit to Loirooriol/servo that referenced this pull request Nov 3, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see web-platform-tests/wpt#38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658
Loirooriol pushed a commit to Loirooriol/servo that referenced this pull request Nov 5, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see web-platform-tests/wpt#38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658
Loirooriol pushed a commit to Loirooriol/servo that referenced this pull request Nov 5, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see web-platform-tests/wpt#38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658
mrobinson pushed a commit to servo/servo that referenced this pull request Nov 6, 2023
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see web-platform-tests/wpt#38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants