[csswg-drafts] [mediaqueries] Define `aspect-ratio` with `<number> [/ <number]?` instead of `<ratio>` (#10906)

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

== [mediaqueries] Define `aspect-ratio` with `<number> [/ <number]?` instead of `<ratio>` ==
[`<ratio>`](https://drafts.csswg.org/css-values-4/#ratio-value) does not allow negative `<number>`s: `<number [0,∞]> [ / <number [0,∞]> ]?`.

(1) Media Queries defines range features that are [false in the negative range](https://drafts.csswg.org/mediaqueries-5/#false-in-the-negative-range)*, with an example showing that `aspect-ratio = -1` evaluates to `true` instead of `unknown`, which current versions of Chrome and FF (at least) do not do.

`true` seems largely reasonable. The problem is to evaluate something matching `<general-enclosed>`, ie. `<any-value>`, to `true`. Instead of defining this quirk, the syntax should reflect that negative values are valid in this context, imo.

(2) I understand that this would require defining [`<mf-value>`](https://drafts.csswg.org/mediaqueries-5/#typedef-mf-value) with `... | <number> [/ <number]?`, which might be less "desirable" than  `... | <ratio>`. An alternative could be to define the `aspect-ratio` property with `<ratio [0,∞]>`.

`<ratio>` is only used to declare `*-aspect-ratio` property/features in CSS, but negative ratios seem to be valid when used to measure other values, like sound compression, and more generally, in mathematics. Since I am not an export in both fields, I might be wrong.

The spec example actually uses `resolution = -300dpi`, whereas `<resolution>` accepts negative values and I do not see how/where a negative resolution value could make sense.

However, restricting `<resolution>` to non-negative values was proposed in #1196, which was closed with this comment:

  > I don't think the definition of the unit should have anything to say about negative values. That should be handled in the definition of the properties (and descriptors) that accept resolution values.

My point is that this might be true for `<ratio>` but not for `<resolution>`.

(3) The result of a math function should be clamped to the closest range boundary (if any), therefore `aspect-ratio > 1 / calc(-1)` should presumably be evaluated to false (`aspect-ratio` is not greater than `Infinity`, the result of `1 / 0`), which might be unexpected.

---

\* In the definition of *false in the negative range*, about when querying whether the feature is greater or equal to a negative value, *"if the relationship is true"* is rather confusing to me: assuming `f`eature is `-2`, `f < -1` should evaluate to `false`, `f > -3` to `true`, and `f > -1` to `false`? I suspect that this concept expects related features to always have non-negative values, so for any `n < 0`, `f > n` is always `true`, not matter the value of `f`.

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


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

Received on Tuesday, 17 September 2024 13:43:16 UTC