You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-sizing-4] How to handle 0 in aspect-ratio #5557
I just noticed that the spec was changed to allow a lot more values. In particular, 0 is now valid for aspect-ratio, but the spec doesn't say how to handle that. I assume it behaves as "auto" but still gets computed as specified?
There is a comment about n/0 and 0/n for aspect-ratio in media query: #3757. And yes, it'd be great to address more about how to handle 0/n and n/0 in the spec.
It doesn't say how to handle it because there's nothing special to do with it - it acts exactly like you'd expect, similar to values close to it. That is, 0/x acts similar to 0.000000001/x, and same for x/0. Nothing wrong with zeros or infinities here; they're the same as very-small nonzero values or very-large finite values.
Why did you not make it compute to auto?
They don't compute to auto because it would violate our 'no open ranges' restriction (giving a substantially different behavior between 0 and .000000000001, potentially exposing UA-specific rounding). Also, there's no reason to, since the behavior at 0 has a simple, clean definition as the limit behavior of it approaching zero.
(Also, I don't recall this entire change being discussed in the WG?)
It's just a side-effect of us changing ratios from <integer> to <number>, which we did discuss. I'd have to dig up the issue, but it was definitely discussed in a f2f as well. When it was <integer> we could disallow zero, but as soon as you allow numbers, you have to allow zero because of no-open-ranges.
Activity
cbiesinger commentedon Sep 29, 2020
Why did you not make it compute to auto? (Also, I don't recall this entire change being discussed in the WG?)
cbiesinger commentedon Sep 29, 2020
@BorisChiou @bfgeek @tabatkins @fantasai
BorisChiou commentedon Sep 29, 2020
There is a comment about n/0 and 0/n for aspect-ratio in media query: #3757. And yes, it'd be great to address more about how to handle 0/n and n/0 in the spec.
tabatkins commentedon Sep 29, 2020
It doesn't say how to handle it because there's nothing special to do with it - it acts exactly like you'd expect, similar to values close to it. That is,
0/xacts similar to0.000000001/x, and same forx/0. Nothing wrong with zeros or infinities here; they're the same as very-small nonzero values or very-large finite values.They don't compute to auto because it would violate our 'no open ranges' restriction (giving a substantially different behavior between
0and.000000000001, potentially exposing UA-specific rounding). Also, there's no reason to, since the behavior at 0 has a simple, clean definition as the limit behavior of it approaching zero.It's just a side-effect of us changing ratios from
<integer>to<number>, which we did discuss. I'd have to dig up the issue, but it was definitely discussed in a f2f as well. When it was<integer>we could disallow zero, but as soon as you allow numbers, you have to allow zero because of no-open-ranges.tabatkins commentedon Sep 29, 2020
(See #4954 for some other discussion on this, including in particular why we defined
0/0the way we did.)[AspectRatio] Update the parsing of aspect-ratio
fantasai commentedon Oct 9, 2020
Reopened #4954 since as @cbiesinger points out, this wasn't resolved by the WG and the resolution isn't obvious.
fantasai commentedon Nov 3, 2020
RESOLVED: Treat aspect ratio of 0 or infinity as auto on Thursday 22 October 2020
fantasai commentedon Nov 5, 2020
Minutes: https://lists.w3.org/Archives/Public/www-style/2020Nov/0003.html
fantasai commentedon Nov 5, 2020
wpt: css/css-sizing/aspect-ratio/zero-or-infinity-*
tabatkins commentedon Nov 9, 2020
Fixed in 84a573d