Open cdoublev opened 1 month ago
Worth noting that we interpolate ratios in a way that only makes sense for non-negative ratios.
For example, the intermediate ratio between two ratios is their geometric mean, which is defined for non-negative numbers.
But I guess we could say that ratios can only be interpolated if they have the same sign (and aren't degenerate), then if both are negative we interpolate the absolute values and multiply the result by -1.
Alternatively, I guess <ratio>
could be a generic pair of numbers and interpolate them independently, and then restrict aspect-ratio
to non-negative ratios, and set the current interpolation behavior as the interpolation type of the property.
I'm not sure it's worth doing, though.
<ratio>
does not allow negative<number>
s:<number [0,∞]> [ / <number [0,∞]> ]?
.(1) Media Queries defines range features that are false in the negative range*, with an example showing that
aspect-ratio > -1
evaluates totrue
instead ofunknown
, 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>
, totrue
. Instead of defining this quirk, the syntax should reflect that negative values are valid in this context, imo.(2) This would require defining
<mf-value>
with... | <number> [/ <number]?
instead of... | <ratio>
. An alternative could be to define theaspect-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 expert 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: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 thanInfinity
, the result of1 / 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 tofalse
,f > -3
totrue
, andf > -1
tofalse
? I suspect that this concept expects related features to always have non-negative values, so for anyn < 0
,f > n
is alwaystrue
, no matter the value off
.