Bug 265276
| Summary: | Support CSS math functions on flexible lengths | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Roman Komarov <kizmarh> |
| Component: | CSS | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | karlcow, ntim, sam, simon.fraser, webkit-bug-importer, zalan |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari Technology Preview | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Roman Komarov
To reproduce, go to https://codepen.io/kizu/pen/RwvyyOg or try using `calc(1fr)` in `grid-template-columns`.
The `calc(1fr)` is treated as invalid, but it should be valid, as per specs (see it for the `<flex>` type):
https://drafts.csswg.org/css-values-4/#calc-type-checking
and as clarified by the spec editors:
https://github.com/w3c/csswg-drafts/issues/6989
> Definitely a bug; `fr` units should be math'able just fine. That note is, indeed, just observing that `fr` is not a `<length>` so `calc(1px + 1fr)` is invalid, but `calc(1fr / 3)` should be just fine.
Curiously, no other browser did fix this yet. Chromium has a bug open from 2019: https://bugs.chromium.org/p/chromium/issues/detail?id=993136&q=calc%20fr&can=2 and I did not find one for Firefox, so I did open it: https://bugzilla.mozilla.org/show_bug.cgi?id=1866236
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Roman Komarov
I did open a PR adding WPT tests for this: https://github.com/web-platform-tests/wpt/pull/43322
Radar WebKit Bug Importer
<rdar://problem/118975697>
Tim Nguyen (:ntim)
Sam, is this easy to do with the calc() rewrite you did?
Sam Weinig
I can't speak to why the initial codepen doesn't seem to work as the text in the codepen suggests it should (its not 50%) but calc() and fr units is fully supported. (I just don't understand the grid syntax at all so don't know if its correct.
The WPT test added for this, https://wpt.fyi/results/css/css-grid/grid-definition/grid-support-flexible-lengths-001.html?label=experimental&label=master&aligned, seems to be passing in Safari.
Roman Komarov
The current WPT tests do not cover the case I mentioned — my wpt PR with the tests for this is still unmerged: https://github.com/web-platform-tests/wpt/pull/43322