Re: [csswg-drafts] [media-queries][css-sizing] Support <number> (and therefore calc) as a <ratio> (#3757)

The CSS Working Group just discussed `Aspect Ratios`, and agreed to the following:

* `RESOLVED: change <integer> to <number> in the aspect-ratio`
* `RESOLVED: allow <number> and <number>/<number> both for <aspect-ratio>`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: Aspect Ratios<br>
&lt;fremy> ScribeNick: fremy<br>
&lt;astearns> github: https://github.com/w3c/csswg-drafts/issues/3757<br>
&lt;fremy> AmeliaBR: currently for the aspect-ratio media query we define a ratio type (integer slash integer)<br>
&lt;fremy> AmeliaBR: we are thinking about using the same type for the aspect-ratio property<br>
&lt;fremy> AmeliaBR: I think we should support decimal in addition to the fraction<br>
&lt;fremy> AmeliaBR: so &lt;int>/&lt;int> or &lt;number><br>
&lt;heycam> q+<br>
&lt;fremy> jensimmons: I can see how this looks like a fraction, but I don't think of it this way<br>
&lt;chris> its a rational number, not a fraction<br>
&lt;fremy> jensimmons: interested people can look at the history of aspect ratio in the film industry<br>
&lt;fremy> jensimmons: there is both 16/9 or 16:9 or 1.77<br>
&lt;fremy> jensimmons: I don't see us wanting to have 1.77:1<br>
&lt;fremy> jensimmons: that is confusing<br>
&lt;fremy> myles_: is it bad that when you actually divide these numbers you get non-round numbers?<br>
&lt;TabAtkins> q+<br>
&lt;chris> https://www.mathsisfun.com/rational-numbers.html<br>
&lt;fremy> AmeliaBR: yes, this is why we prefer the "fraction-looking" expression<br>
&lt;fremy> myles_: so we don't want to convert to a number, right?<br>
&lt;fremy> jensimmons: no, we would keep the other representation<br>
&lt;chris> q+<br>
&lt;fantasai> myles: I don't want to have a 1px gap because of people's mental rounding errors<br>
&lt;astearns> ack heycam<br>
&lt;fremy> AmeliaBR: but when authors have numbers they computed themselves in some other way, we don't want to force them to use a fraction<br>
&lt;fremy> heycam: so, if you want to use css variables, you would want to use calc() right?<br>
&lt;fremy> myles_: native api often expose numerator and denominator as distinct in those cases<br>
&lt;fremy> chris: come on folks, are we really discussing this?<br>
&lt;astearns> q?<br>
&lt;fremy> chris: this is a rational number, we can allow that and other forms of numbers, this is very common outside of css<br>
&lt;astearns> ack TabAtkins<br>
&lt;chris> The ancient greek mathematician Pythagoras believed that all numbers were rational, but one of his students Hippasus proved (using geometry, it is thought) that you could not write the square root of 2 as a fraction, and so it was irrational.<br>
&lt;chris> q-<br>
&lt;fremy> TabAtkins: I think I agree that accepting all numbers is reasonable, for the calc() cases<br>
&lt;leaverou> q+<br>
&lt;chris> But followers of Pythagoras could not accept the existence of irrational numbers, and it is said that Hippasus was drowned at sea as a punishment from the gods<br>
&lt;fremy> TabAtkins: but I don't think we need to add just plain &lt;number> because it's ambiguous<br>
&lt;AmeliaBR> q?<br>
&lt;jensimmons> q+<br>
&lt;dbaron> Tab's proposal (do just change &lt;integer>/&lt;integer> to &lt;number>/&lt;number>) sounds good to me<br>
&lt;astearns> ack leaverou<br>
&lt;florian> q?<br>
&lt;fremy> leaverou: I don't understand why there is an ambiguity?<br>
&lt;fremy> leaverou: can't we do both? why do we want to pick one?<br>
&lt;fremy> TabAtkins: ok, there is no ambiguity, but it makes the syntax more complex, I appreciate consistent things<br>
&lt;TabAtkins> s/it's ambiguous/it's nice to have a single consistent syntax pattern/<br>
&lt;fremy> TabAtkins: but you are are, it's not ambiguous<br>
&lt;fremy> AmeliaBR: well we will get questions anyway, some will wonder why you have to write 1.5/1 instead of just 1.5 but ok that's doable<br>
&lt;astearns> ack jensimmons<br>
&lt;fremy> jensimmons: calc() and variables, can someone explain how that would work now and with the proposals?<br>
&lt;leaverou> s/I don't understand why there is an ambiguity?/I don't understand why we can't do both. There is no syntactical ambiguity./<br>
&lt;fremy> TabAtkins: today, if you use calc, it would get weird results, because we only allow integers, so they would be rounded<br>
&lt;fremy> TabAtkins: so it works in theory, but it's not very practical<br>
&lt;fremy> TabAtkins: the proposal would allow to have any number, so you can compute using a ratio of two variables<br>
&lt;AmeliaBR> s/well we will/we can wait until we have more authors using this, and then see if/<br>
&lt;fremy> jensimmons: that sounds reasonable, but there is a very common case with just a number, I don't see why not adding that as well<br>
&lt;fremy> astearns: and that seems common, so I'd plus on that<br>
&lt;florian> q?<br>
&lt;fremy> TabAtkins: I would prefer not to add syntax when it doesn't add much, but if there is strong demand for this, I could get convinced<br>
&lt;fremy> astearns: so, can we resolve to change &lt;int> to &lt;number> for aspect ratio values?<br>
&lt;fremy> RESOLVED: change &lt;integer> to &lt;number> in the aspect-ratio<br>
&lt;fremy> TabAtkins: for the second part, what do implementers think?<br>
&lt;fremy> dbaron: I think that I cross-multiplied to avoid rounding, but I'm not sure<br>
&lt;fremy> dbaron: I considered it because otherwise it's a bit scary if people might try an equality and rounding is risky then<br>
&lt;chris> people comparing two floats for equality need to learn why that is never a good idea<br>
&lt;fremy> dbaron: but code has been rewritten since then anyway<br>
&lt;fremy> dbaron: so I don't know<br>
&lt;fremy> myles_: is that relevant though?<br>
&lt;fremy> TabAtkins: maybe not, but I was curious<br>
&lt;myles_> s/is that relevant though?//<br>
&lt;fremy> astearns: I think we should try to keep the syntax simple, and revisit if we get requests<br>
&lt;emilio> https://searchfox.org/mozilla-central/rev/153172de0c5bfca31ef861bd8fc0995f44cada6a/servo/components/style/media_queries/media_feature_expression.rs#31<br>
&lt;fremy> hober: but priority of consituency indicates that we should favor allowing to drop the slash one<br>
&lt;fremy> astearns: also, looking at the example emilio pasted in irc, the slash one looks dumb, so I changed my mind a bit<br>
&lt;fremy> jensimmons: also, I don't buy the complexity of having two syntaxes<br>
&lt;emilio> s/emilio/AmeliaBR :)<br>
&lt;myles_> &lt;number> | &lt;number> / &lt;number><br>
&lt;fremy> astearns: ok, so let's try to resolve to allow &lt;number> and &lt;number>/&lt;number> both<br>
&lt;AmeliaBR> s/AmeliaBR/flackr/<br>
&lt;fremy> dbaron: well, that constraints syntax a bit, but I'm fine with it<br>
&lt;dbaron> s/constraints/constrains/<br>
&lt;jensimmons> this is really good. And it’s good to do it now.<br>
&lt;fremy> RESOLVED: allow &lt;number> and &lt;number>/&lt;number> both for &lt;aspect-ratio><br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3757#issuecomment-499625710 using your GitHub account

Received on Thursday, 6 June 2019 19:03:20 UTC