-
Notifications
You must be signed in to change notification settings - Fork 708
[css-values-4] Should physical units in specified values in calc() collapse into px unit when serialized? #3741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As far as I can tell, the spec is very explicit and intentional about all these units getting merged and converted to pixels. I don't have a strong opinion on the matter, but it looks we decided on this explicitly. So I guess the question is: is it time to file bugs on browsers so that implementations get aligned with the spec, or is this something implementations don't want to align on after all (in which case we need to change the spec)? |
@frivoal Note that this is testing specified value, not computed. None of these should be combined at specified-value time, per spec; the units should just get sorted. (Except for the example with two different |
You are probably correct. But, as edited, the spec is difficult to figure out regarding this particular matter. Even after careful and methodical re-reading, it is difficult to be sure.
Firefox 68 is the only browser that reliably sorts terms by their units in alphabetical order. One question. Let's say we have |
Edge does it this way, except for percentages being in the wrong sorted order and no support for But they seem to be the odd ones out in not simplifying units at serialization. Show full EdgeHTML 18.17763 results for Gerard's test
Is this a typo, @TalbotG ? Regardless of when in the process simplification happens, I would expect the same rules for all absolute length units. And that's what I'm seeing in my testing. Edge, Chrome, Firefox all treat cm and mm units using the same rules. For Chrome and Firefox, that means that the units are left alone during serialization if and only if they are the only unit used in the calc, but are simplified to px if there is more than one absolute unit in the expression — although Chrome adds brackets in for every operation, so it also depends on the order if there are any relative units.
And I'm not confident that we have a web compat argument for any of them. For simple serialization, as an author I'd expect minimum modifications — whitespace normalization and maybe sorting. Even doing something like collapsing My test as a Codepen if anyone wants to play around with other values. It prints to the console the specified value, the serialized value read back, and the computed value (using a property that returns the regular computed value from |
FWIW, Gecko only normalizes absolute lengths, the rest of the units are left untouched. Relevant code is here: And this particular behavior was changed here: https://bugzilla.mozilla.org/show_bug.cgi?id=1396692 (see the first comment for "old engine behavior" and "old behavior of new engine" in comparison to what's implemented now). |
No typo. I was referring to what was happening in the (original) 4 sub-tests test page. I have edited my original message a bit. I removed the link to MS-Edge 18 results since MS-Edge 44 is now being used (instead of MS-Edge 18) to check all the tests in wpt repository.
Indeed, this appears to be what is happening. And that is not what the specification tried to state for serialization of terms in calc() specified values. I still very much believe that the specification should be made more clear or clarified somehow. Maybe with more examples. And with clearer statements. The spec should explicitly state that mixed absolute units should not be resolved into px unit when serializing specified values... |
I have modified considerably |
I fixed Blink's sort order for getComputedStyle result, the bug is still open for specified values. |
We all agree. This is one particular behavior that Chrome software developers should fix. |
The simplification and serialization rules are now clear about what happens here.
|
calc-serialization-002.html (at least) needs updating here |
The spec § 10.13. Serialization and editor's draft § 10.13. Serialization are contradicting because still saying: " Reopening. I just want the spec to be updated here... |
The issue doesn't need to be reopened to ask for republication. |
Re-opening to expand the example that confused Gérard, we should discuss both |
Also, we should clarify the answer @TalbotG’s question at web-platform-tests/wpt#38245 -
|
IIRC we used to remove zero terms of a sum and undid it. In general, removing 0px is not fully sound because it turns a length-percentage mix into just percentages, which can behave differently in tables IIRC. In this particular case avoiding the 0px would be feasible, but it raises the question of what should remain if all the terms are zero. E.g., should |
The answer is "what the simplification algorithm tells you to preserve". For a sum, it combines terms with the same unit, but doesn't touch different-unit values. If canonicalization converts them all to the canonical unit (px, here), they'll combine, otherwise they'll all stick around. |
coming from
https://www.w3.org/TR/css-values-4/#compat
Now this 6 sub-tests test page:
http://www.gtalbot.org/BrowserBugsSection/CSS3Values/calc-serialization-specified-values-789.html
(please ignore the pass or fail verdict for the 6 sub-tests)
I created this issue because no browser does what the current version of the spec explains.
In the 1st sub-test, 3 tested browsers will combine the terms
1in + 1pc
into112px
. Isn't such combination going to confuse or disorient or irritate web authors?In the 6th sub-test, 3 tested browsers will convert the term
25.4mm
to96px
. Same question.In the 2nd sub-test, all 4 tested browsers will not convert the term
25.4q
to24px
. (MS-Edge 18, Safari 77 Preview and Epiphany 3.31.90 Technological Preview do not supportq
unit.)In the 3rd sub-test, all 4 tested browsers will not convert the term
1.27cm
to48px
.MS-Edge 18 just like Safari 77 Preview and Epiphany 3.31.90 Technological Preview do not support
q
unit.Finally, I have read
https://lists.w3.org/Archives/Public/www-style/2016Mar/0331.html
https://lists.w3.org/Archives/Public/www-style/2016Mar/0422.html
and
https://lists.w3.org/Archives/Public/www-style/2016Apr/0093.html
The text was updated successfully, but these errors were encountered: