-
Notifications
You must be signed in to change notification settings - Fork 711
[css-tables] Calc for table layout #94
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
+1 |
The Tables module is now receiving some love, so we'll see! I agree that there are some "trivial" calc()s that should be possible without making anything complicated, but because of that, they're also avoidable. It's easier to write |
I don't think this is reflected in the latest CSS Tables draft, but some investigations on this exact topic were conducted by yours truly. The sad conclusion is that there is probably no way to allow what you want in a way that would work continuously, as width:0% and width:0px have very different behaviors. Heck, even width:10% can have a different behavior than width:10% if specified on consecutive but otherwise perfectly identical column, tables are a complete mess. CSS Grids resolve width distribution in a way that makes it possible to seamlessly mix units, but CSS Tables don't. I feel no difficulty in supporting calc expression resolving to only one particular unit, but that might mislead authors in believing that calc is entirely supported. I do not entirely discard the idea of making calc work, but I suspect this cannot make the cut for our current level of the spec, because we would need to add a few new features which is against the spirit of the spec right now, which would add fluidity to the currently one-or-zero behavior of the width distribution. We have so many challenges on that topic already... |
Btw, just so you know, mixing units does not work even for one column. It just happens that since you only leave one column unconstrained, it takes the size remaining after you assign its width to the other columns. You can try changing the value as much as you can, it should not have any effect. If it does in some browser, let me know. |
Thanks for your responses :)
Supporting
The funny thing is that I discovered this issue as CSS Grid is not supported by browsers yet. So I was trying to mimic its behavior by custom element that uses Shadow DOM content distribution and Table Layout. What about forcing it by Currently, (in Chrome only) setting Forgive me, if lack of sleep made my fantasies to weird, but... |
This Chrome bug is being tracked in the spec:
I initially saw no reason to change the sizing behavior based on the table-layout mode, because this is not at all what that property is about. The fact Chrome switches to a completely different computation mode breaks a lot of things, but of course allows other things to work that cannot work in normal tables (though I never spotted this calc subtlety, thanks for mentioning it). Author feedback is always important, and given Chrome behavior is likely web-compatible, this thread is something we may consider while deciding how to resolve the previous issue. That being said, CSS Tables will probably not be fixed before CSS Grids is out, and no one would encourage you to rely on CSS Tables more than on a absolute requirement basis, their layout system is slow and buggy. I will make sure to mention this thread next time we do a breakout session / f2f topic on CSS Tables, but I would encourage further discussions to happen on [email protected], the official mailing list ;-) |
It was resolved in the CSSWG meeting today to move this to L4 of the Values and Units spec to require resolving a calc() that contains values of the same unit. |
Actually, I leave this open until the change is made to L4 of units and values |
…ble widths and heights to only mixed-input cases. #94
OK, I tightened this up in css-values-4 to only allow fallback to auto if the calc() expression mixes both percentages and lengths. The remaining question is about whether fixed table layout should require handling the mix, and if so if that's just for widths or also heights. (Given what fixed layout means, having it work for widths--or the inline size, rather--is perfectly reasonable.) |
Personally, I would prefer for them to be the same, adding additional confusion that you can mix %s with that of lengths only in |
For interoperability, and to reduce frictions in implementing the other proposed math functions, should we turn the "MAY" into "must"? This issue has also been discussed in the context of min/max(), and the situation seems worse there:
With calc() alone, the value remains a linear function (to the value the % is evaluated against), which means theoretically there should still exist a "correct" intrinsic table size that allows all cells to be sized correctly. UA may choose to do that according to the current spec. With other math functions introduced, the function is no longer linear and may not even have an inverse, which means the above is no longer possible. In such cases, UA must fall back. For interop, it would be better to specify what fallback should be taken. Turning "MAY" into "must" seems to be the easiest and most reasonable one to me. |
Turning the MAY into a MUST sounds reasonable to me. I don't think anyone want to start investigating this more deeply, especially since as noted multiple times the existence of a solution isn't guaranteed. There still remains the question of fixed layout where percentages can be resolved to pixels and handled as such without too much trouble for most of the algorithm. I would be open to specify that this case must work, and provide the details of how. |
The CSS Working Group just discussed
The full IRC log of that discussion<emilio> Topic: Calc for table layout<emilio> Github: https://github.com//issues/94 <emilio> xiaochengh: So the issue is what to do with percentages and calc <emilio> ... spec says a bunch of stuff may be treated as auto <fremy> "Given the complexities of width and height calculations on table cells and table elements, math expressions involving percentages for widths and heights on table columns, table column groups, table rows, table row groups, and table cells in both auto and fixed layout tables MAY be treated as if auto had been specified." <emilio> ... I'm proposing changing the MAY into MUST <emilio> ... it's pretty complicated if we don't treat it as auto <fremy> q+ <emilio> ... second reason is that this is creating friction when implementing min() / max() <emilio> ... calc() is complicated, but min() / max() make it a pretty hardly solvable problem <emilio> ... so I propose to make this a MUST <emilio> TabAtkins: this is what dbaron proposed back in the day <emilio> ... and we punted min and max because of that <emilio> heycam: implementation status? <emilio> fremy: all browsers match the spec <emilio> ... for normal table layout <emilio> ... the algorithm just doesn't make it possible <emilio> ... in fixed table layout there's one browser that supports percentages based on the size of the table <emilio> ... as to the question of whether we should remove the behavior for normal table layout is fine <emilio> ... for fixed layout it'd be nice to also remove it, but Chrome and Safari <emilio> ... do respect it so it'd be nice to remove that <emilio> ... or add to the spec that it is respected in fixed table layout and how, which should be straight-forward <heycam> emilio: there's also the question of whether we should in presence of min and max ... <heycam> ... Firefox uesd to treat calc(%) as auto <heycam> ... we no longer do that <heycam> ... but it raises the question of how min and max behave with only percentages <heycam> ... I guess that's fine to resolve? <heycam> TabAtkins: I don't want to special case min and max on type <heycam> ... that's awkward <heycam> ... having min and max work in some case if you have certain shapes of expression inside of it <heycam> emilio: I think given the way we behave, all browsers treat calc with percentages as a percentage, we should do the same for min and max <heycam> fremy: that sounds reasonable to me <heycam> .... if there is a sum of % and px, after you've computed, then you decide not to do anything, follow the MUST <heycam> ... if you have min(10%, 20%), the computed value will be 10%, so you don't have the problem <heycam> .... I would be in favour of that wording <heycam> emilio: what about calc(10% + 0)? <heycam> ... that's simplifies to 10% in all browsers <heycam> Rossen: yes we've resolved that previously <heycam> fremy: so what about fixed mode <heycam> ... I assume it's probably fine to apply this rule to both? <heycam> RESOLVED: Any math expression of a complex type is treated as auto. Simple typed things continue to work as today. <emilio> TabAtkins: https://github.com//issues/3482#issuecomment-451590359 <heycam> zoe: no objections |
Current progress: - Implementation finished - Test suite finished except for a minor serialization spec issue [1], which seems minor enough not to block the launch - The spec issue with table layout [2] is already resolved. In case of similar spec issues in other layout algorithms, I believe a similar approach (UA must treat the value as auto) can be adopted. Therefore, I believe there is no longer any issue blocking the shipping of the feature. [1] w3c/csswg-drafts#4372 [2] w3c/csswg-drafts#94 Bug: 825895 Change-Id: I0fe8e934d4429fa6ed1c3dd8847f70b1ba350e07 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1829471 Reviewed-by: Rune Lillesveen <[email protected]> Reviewed-by: Emil A Eklund <[email protected]> Commit-Queue: Xiaocheng Hu <[email protected]> Cr-Commit-Position: refs/heads/master@{#701148}
w3c/csswg-drafts#94 made a resolution that "Any math expression of a complex type is treated as auto. Simple typed things continue to work as today." This patch adds new tests and revises existing tests to reflect the resolution. Bug: 382725 Change-Id: I522799b51fdd4a7cfa66e137ae31c68aaf2dea73
I've made PR #4389 for the resolution above. PTAL, and thanks for that! |
w3c/csswg-drafts#94 made a resolution that "Any math expression of a complex type is treated as auto. Simple typed things continue to work as today." This patch adds new tests and revises existing tests to reflect the resolution. Bug: 382725 Change-Id: I522799b51fdd4a7cfa66e137ae31c68aaf2dea73
w3c/csswg-drafts#94 made a resolution that "Any math expression of a complex type is treated as auto. Simple typed things continue to work as today." This patch adds new tests and revises existing tests to reflect the resolution. Bug: 382725 Change-Id: I522799b51fdd4a7cfa66e137ae31c68aaf2dea73 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832619 Commit-Queue: Xiaocheng Hu <[email protected]> Reviewed-by: Aleks Totic <[email protected]> Cr-Commit-Position: refs/heads/master@{#701597}
w3c/csswg-drafts#94 made a resolution that "Any math expression of a complex type is treated as auto. Simple typed things continue to work as today." This patch adds new tests and revises existing tests to reflect the resolution. Bug: 382725 Change-Id: I522799b51fdd4a7cfa66e137ae31c68aaf2dea73 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832619 Commit-Queue: Xiaocheng Hu <[email protected]> Reviewed-by: Aleks Totic <[email protected]> Cr-Commit-Position: refs/heads/master@{#701597}
…calc() in table layout, a=testonly Automatic update from web-platform-tests Add/Revise WPT to reflect resolution of calc() in table layout w3c/csswg-drafts#94 made a resolution that "Any math expression of a complex type is treated as auto. Simple typed things continue to work as today." This patch adds new tests and revises existing tests to reflect the resolution. Bug: 382725 Change-Id: I522799b51fdd4a7cfa66e137ae31c68aaf2dea73 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832619 Commit-Queue: Xiaocheng Hu <[email protected]> Reviewed-by: Aleks Totic <[email protected]> Cr-Commit-Position: refs/heads/master@{#701597} -- wpt-commits: cda40b6ff20c841a6195e95387d09072db8fd6e3 wpt-pr: 19424
…calc() in table layout, a=testonly Automatic update from web-platform-tests Add/Revise WPT to reflect resolution of calc() in table layout w3c/csswg-drafts#94 made a resolution that "Any math expression of a complex type is treated as auto. Simple typed things continue to work as today." This patch adds new tests and revises existing tests to reflect the resolution. Bug: 382725 Change-Id: I522799b51fdd4a7cfa66e137ae31c68aaf2dea73 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832619 Commit-Queue: Xiaocheng Hu <[email protected]> Reviewed-by: Aleks Totic <[email protected]> Cr-Commit-Position: refs/heads/master@{#701597} -- wpt-commits: cda40b6ff20c841a6195e95387d09072db8fd6e3 wpt-pr: 19424
…calc() in table layout, a=testonly Automatic update from web-platform-tests Add/Revise WPT to reflect resolution of calc() in table layout w3c/csswg-drafts#94 made a resolution that "Any math expression of a complex type is treated as auto. Simple typed things continue to work as today." This patch adds new tests and revises existing tests to reflect the resolution. Bug: 382725 Change-Id: I522799b51fdd4a7cfa66e137ae31c68aaf2dea73 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832619 Commit-Queue: Xiaocheng Hu <xiaochenghchromium.org> Reviewed-by: Aleks Totic <atoticchromium.org> Cr-Commit-Position: refs/heads/master{#701597} -- wpt-commits: cda40b6ff20c841a6195e95387d09072db8fd6e3 wpt-pr: 19424 UltraBlame original commit: ffa86f64139eb8d73dbbe409e9bdc3846a0951c6
…calc() in table layout, a=testonly Automatic update from web-platform-tests Add/Revise WPT to reflect resolution of calc() in table layout w3c/csswg-drafts#94 made a resolution that "Any math expression of a complex type is treated as auto. Simple typed things continue to work as today." This patch adds new tests and revises existing tests to reflect the resolution. Bug: 382725 Change-Id: I522799b51fdd4a7cfa66e137ae31c68aaf2dea73 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832619 Commit-Queue: Xiaocheng Hu <xiaochenghchromium.org> Reviewed-by: Aleks Totic <atoticchromium.org> Cr-Commit-Position: refs/heads/master{#701597} -- wpt-commits: cda40b6ff20c841a6195e95387d09072db8fd6e3 wpt-pr: 19424 UltraBlame original commit: ffa86f64139eb8d73dbbe409e9bdc3846a0951c6
…calc() in table layout, a=testonly Automatic update from web-platform-tests Add/Revise WPT to reflect resolution of calc() in table layout w3c/csswg-drafts#94 made a resolution that "Any math expression of a complex type is treated as auto. Simple typed things continue to work as today." This patch adds new tests and revises existing tests to reflect the resolution. Bug: 382725 Change-Id: I522799b51fdd4a7cfa66e137ae31c68aaf2dea73 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832619 Commit-Queue: Xiaocheng Hu <xiaochenghchromium.org> Reviewed-by: Aleks Totic <atoticchromium.org> Cr-Commit-Position: refs/heads/master{#701597} -- wpt-commits: cda40b6ff20c841a6195e95387d09072db8fd6e3 wpt-pr: 19424 UltraBlame original commit: ffa86f64139eb8d73dbbe409e9bdc3846a0951c6
Seems like this was fixed, so closing out. Please open a new issue if we missed anything. :) |
…calc() in table layout, a=testonly Automatic update from web-platform-tests Add/Revise WPT to reflect resolution of calc() in table layout w3c/csswg-drafts#94 made a resolution that "Any math expression of a complex type is treated as auto. Simple typed things continue to work as today." This patch adds new tests and revises existing tests to reflect the resolution. Bug: 382725 Change-Id: I522799b51fdd4a7cfa66e137ae31c68aaf2dea73 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832619 Commit-Queue: Xiaocheng Hu <[email protected]> Reviewed-by: Aleks Totic <[email protected]> Cr-Commit-Position: refs/heads/master@{#701597} -- wpt-commits: cda40b6ff20c841a6195e95387d09072db8fd6e3 wpt-pr: 19424
Are there any plans to specify
calc
behavior for widths and heights in table layout?Implementations varies across browsers (http://jsbin.com/juqafi/1/edit?html,css,output)
I suspect the complexity of the math grows when it comes to mix unit (personally, I feel it's just a set of mathematical equations, to be solved in not more sophisticated way that sizing algorithm for Grid Layout).
However, I would say that expressions like:
calc(10% + 20%)
http://jsbin.com/juqafi/1/edit?html,css,outputcalc(100%/7)
https://bugzilla.mozilla.org/show_bug.cgi?id=957915Should be really easy to compute, resolve, and apply.
The text was updated successfully, but these errors were encountered: