Re: [csswg-drafts] [css-values-4] How should atan2 behave with different length units? (#7482)

`atan2(1cm, 1mm)` have compatible units. As I noted in my initial issue, WebKit (the only available browser implementation) seems to perform unit conversion on these. It seems to treat all non-absolute length units the same as px (i.e., as if the unit is not specified at all). Feel free to play around with it here: https://codepen.io/devongovett/pen/GRxqNYj

This behavior seems inconsistent, so I am looking for clarification from the spec authors on the correct intent. Then, we can work on adding new Web Platform Tests to handle these cases.

> Regarding <percentage> in atan2() to replace a value that should match <angle>, I believe that [resolving the type of the function](https://drafts.csswg.org/css-values-4/#calc-type-checking) will fail

This part of the spec is about resolving the type of the _result_ of a math function, specifically `calc()`. For `atan2` specifically, it says:

> A and B can resolve to any `<number>`, `<dimension>`, or `<percentage>`, but must have the same type

I believe this means that percentages are valid in any use of `atan2`, even if the property doesn't support them. Same holds true for all units. `<dimension>` allows lengths, times, frequencies, etc., so even if the property where `atan2` is used only supports lengths, the arguments to `atan2` can accept times, frequencies, percentages, etc. This is weird, but it could work since only the ratio between the arguments is important, assuming it's possible to convert the units to match. Percentages are the odd case because in some cases, the percentage won't really be resolved against anything, whereas other units would.

-- 
GitHub Notification of comment by devongovett
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7482#issuecomment-1179771408 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Sunday, 10 July 2022 17:52:58 UTC