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

devongovett has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values-4] How should atan2 behave with different length units? ==
The spec says that `atan2` accepts two calculations, which must have the same _type_. However, the type is defined as only "length" for length values, and does not include the unit. In fact, the unit seems to be completely ignored.

For example, the following are equivalent despite having completely different units.

```css
rotate: atan2(90px, 90px);
rotate: atan2(90px, 90vw);
```

In the WebKit implementation, however, the following are _not_ equivalent. Presumably there is some unit conversion happening due to the units being compatible, but not sure if this is correct.

```css
rotate: atan2(90px, 10px);
rotate: atan2(90px, 10in);
```

Further, when a calculation results in incompatible units, it's unclear what the behavior should be. For example:

```css
rotate: atan2(90px, 10px + 10vw);
```

In WebKit, the second term seems to be ignored and result in the same value as `rotate: atan2(90px, 10px)`. This seems like a bug, but I'm not sure what to expect here. Should `10vw` be computed and converted into px? What if the terms were reversed? Should `10px` be converted to `vw` then? Should the units be ignored, resulting in `atan2(90, 20)`? The spec doesn't say in which unit `atan2` should be computed.

My question: what should the behavior be when the units of the arguments are different, but the types are the same? What should happen if a calculation cannot be simplified to a single number?

Perhaps a better question: why does this function accept units at all? Why not only allow calculations that resolve to a `<number>` similar to some of the other math functions? Since the units aren't actually used, it just seems confusing.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7482 using your GitHub account


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

Received on Saturday, 9 July 2022 22:51:00 UTC