-
Notifications
You must be signed in to change notification settings - Fork 642
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
[css-flexbox] flexbox spec isn't interoperable w/ existing implementations, RE flex-basis
resolution for table wrapper box flex-items
#2604
Comments
Isn't this bypassed by https://www.w3.org/TR/CSS21/tables.html#model and https://drafts.csswg.org/css-tables-3/#ref-for-table-wrapper-box?
|
No, it's not bypassed by that. max-content sizing of a box (the table-wrapper box in this case) does not get to benefit from any information about the ancestors -- that's part of the principle of what max-content sizing represents. |
For a normal flex item (e.g. a block) that has
(The business about max-content size is a bit further down, in a case that we don't fall into for this block scenario -- see below.) In contrast, for a flex item that is a table-wrapper-box (the scenario I care about here): the item's
So we're effectively trying to resolve the size of a table-wrapper-box that has "width:max-content", and by definition, that max-content width isn't influenced by the containing block's size (and so the percent on the child can't resolve against it, for the benefit of computing the used flex basis). But in practice, all browsers that I've tested (besides Firefox Nightly from the past few days) do let the percent be resolved and let it influence the flex base size (and hence the actual flex item size) -- testcase: https://jsfiddle.net/x1te0pra/ (Both spec quotes here are from https://drafts.csswg.org/css-flexbox/#algo-main-item ) Suggestion: Maybe we need a special case for table wrapper boxes in section 9.2 step 3.E, where we treat |
I'm not convinced, since percentages on the table box are not relative to the table wrapper box, they are not cyclic percentages (assuming the table wrapper box's containing block has a definite width). Therefore I don't think the percentage should be treated as
Does the definition actually say this? Not sure if I'm looking at the wrong definition. I think your statement is almost always true, but not for table wrapper boxes. |
I'm looking at this definition:
https://drafts.csswg.org/css-sizing-3/#intrinsic-sizes So notably: the actual size of the containing block is unavailable, because it's determined in a hypothetical "if it's containing block was infinitely-sized in that axis" scenario. |
(Having said that - in practice, the spec's technique there isn't quite right for table wrapper boxes. If I follow the spec's hypothetical steps there -- floating the table-wrapper in an infinitely-sized [or just extremely-large] containing block -- I get the following, with the table itself being extremely large: |
It is, though. The table wrapper box is there mainly to hold the table and its caption together. Its sizing is determined by the size of those items rather than by any sizing properties set on it. The Flexbox spec says
“the flex longhands apply to the table box as follows ... and the table box were the flex item”. What the spec is trying to say is that the table box is what gets flexed by the flex properties, just like the table box is what gets sized by the sizing properties. We have to account for the captions somehow, though, so we're ignoring them and the table wrapper box, except insofar as the captions take up space. And as @Loirooriol says, per CSS2.1 the percentage resolves on the table exactly as if the wrapper box wasn't there.
Overall I think this issue is invalid--as in the spec says it should behave the way you want it to behave--but I'm not sure where you're getting confused or how to fix it.
|
Thanks for the response (and sorry for the long response time on my part). I think you're right that the spec basically covers this; I was perhaps reading too much into the first sentence of the paragraph you quoted ("the table wrapper box becomes the flex item"), and not reading enough into the last sentence ("layout as if...the table box were the flex item"). That last sentence is a bit hand-wavy, but in retrospect I guess it's a pretty strong requirement (and it's not what Firefox/Edge seem to do now, FWIW ( testcase here ) but it seems like a reasonable thing to do). So, bottom line, I think the direct answer to my original concern here is:
So I think we're OK here. Incidentally, https://bugzilla.mozilla.org/show_bug.cgi?id=1456224 is filed on bringing Firefox closer to what the spec requires on this point. |
I recently implemented the keyword
flex-basis:content
, and implemented the spec behavior on treating usedflex-basis:content
asmax-content
. (This includes treatingflex-basis:auto;[main-size-property]:auto
asmax-content
.)However, this creates a bit of a problem for an annoying edge-case -- table wrapper boxes as flex items.
Table wrapper boxes do not receive the author's specified
width/height
norflex-basis
value[1], so they always necessarily haveflex-basis:auto;[main-size-property]:auto
, which means they always have a used flex basis ofcontent
. This means (per the current spec) they should always resolve their flex base size to theirmax-content
size.But I've found that's problematic for scenarios like this:
Right now, Firefox 59/Edge/Chrome all render content like that ^^^ with the table being 300px wide. But with my attempt at implementing the current spec text, Firefox Nightly ends up resolving the flex base size by sizing the table-wrapper as
max-content
, and that means we can't resolve the 100% width on its child box (the table box) because by definition max-content sizing is independent of the surroundings; and so the100%
ends up getting treated asauto
and we end up collapsing the table to its actual content-size, which might be 0 instead of 300px, depending on what it actually contains. So, we end up with a flex base size of 0px (or whatever the content size is), rather than 300px. This is what really happened in Firefox Nightly with my changes, and it caused problems in a real website (a French flight booking site).The spec needs to say what should happen here -- should table-wrapper-box flex items really always get a flex base size of their max-content size? (which is what the spec calls for, but no official UA release implements, aside from current Firefox Nightly I think) Or should they do something subtler, e.g. maybe using the fit-content size in this scenario? (which, unlike max-content, is allowed to take the available space into consideration) Or should they do something else?
[1] The spec says that
order
andalign-self
apply to the table wrapper box, but "likewidth
andheight
, theflex
longhands apply to the table box..." (And then there's some special case about how table boxes should work with flex layout, but it seems to me that this special-case text is all post-flex-base-size resolution.)The text was updated successfully, but these errors were encountered: