Navigation Menu

Skip to content
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-flex/TablesNG] Make flex honor table caption height #28363

Merged
merged 1 commit into from Apr 6, 2021

Conversation

chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Apr 3, 2021

Flexbox needs caption block size to compute table wrapper block size.
Table's css minimum-size specifies size of the grid, not the wrapper.
Wrapper's true block minimum size is css minimum-size + block size.

This patch exposes a method on TablesNG for flex to retrieve the caption
block size. (Thanks atotic!) Flex then adds the result to flex base size
when the flex base size derives from a specified block size or flex
basis.

Bug: 1181403
Change-Id: I61d7caf62708ae32850b89c444374e7a6c40d564
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2804711
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: Aleks Totic <atotic@chromium.org>
Commit-Queue: David Grogan <dgrogan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#869577}

Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-2804711 branch 3 times, most recently from 8727ba8 to a76d273 Compare April 5, 2021 21:56

<!-- Chrome versions [84..90] incorrectly give the flexbox a height of 80px and the table a height of 100px. overflow: hidden hides the table overflow, showing the red underneath, which exposes the bug. -->
<div style="display: flex; flex-direction: column; width: 100px; overflow: hidden;">
<div style="display: table; background: green; height: 80px;">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aethanyc, do you know why Firefox gives the table wrapper box a height of 30px instead of 100px? I thought the 80px here would be distributed to the table grid box, and combined with the 20px height from the caption, the final height would be 100px.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidsgrogan This test looks reasonable. So I think this is a Firefox bug.

When Firefox calculates flex item's base size, it doesn't reflow the flex item because base size can usually be determined by looking at flex-basis and preferred main size. However in this case, table-caption's height is unknown until it's being reflowed, resulting the entire table flex item's base size undetermined. So Firefox calculates its base size as if the table item has height:auto.

Later, we reflow the table to measure the table item height by ignoring its height, and get 30px as its content height.

Does blink reflow the table wrapper box to calculate the its flex base size? In this case the correct table item's base size is height:80px plus the caption's height.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, great info and great explanation, thanks. I was worried it was a chrome bug that the test was relying on.

Does blink reflow the table wrapper box to calculate the its flex base size?

Blink doesn't reflow the whole table wrapper box in this case (i.e. when the grid box has a preferred height in a column flexbox), it just reflows the captions and adds their resulting height to the preferred main size to get the flex item's base size. Which I think is the right thing to do.

Chrome Canary gets a related case wrong: it doesn't reflow the table wrapper box to get a minimum block size below which the column flexbox cannot shrink it. I believe there are no wpt tests that exercise that bug though :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it just reflows the captions and adds their resulting height to the preferred main size to get the flex item's base size. Which I think is the right thing to do.

Sounds reasonable to me. Thank you for the ping. I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1703401 for this test failure.

Chrome Canary gets a related case wrong: it doesn't reflow the table wrapper box to get a minimum block size below which the column flexbox cannot shrink it. I believe there are no wpt tests that exercise that bug though :(

Yeah, table as flex item is definitely tricky to deal with because of table wrapper box structure :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it just reflows the captions and adds their resulting height to the preferred main size to get the flex item's base size. Which I think is the right thing to do.

Sounds reasonable to me. Thank you for the ping. I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1703401 for this test failure.

I think I was wrong, actually. From the very last paragraph in https://drafts.csswg.org/css-flexbox/#flex-items :

The contents of any caption boxes contribute to the calculation of the table wrapper box’s min-content and max-content sizes.

So I think the caption heights are supposed to be ignored for the flex base size. But not sure. I don't understand the next sentence that starts with "However"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If caption heights are to be ignored for flex base size, then I think these tests are wrong; the spec calls for the table to be shorter than the height these tests call for.

css/css-flexbox/table-as-item-inflexible-in-column-2.html
css/css-flexbox/table-as-item-stretch-cross-size-3.html
css/css-flexbox/table-as-item-stretch-cross-size-5.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think the caption heights are supposed to be ignored for the flex base size.

I don't see the spec is explicitly calling for not including caption's height in the flex base size. My interpretation to the sentence "However, like width and height, the flex longhands apply to the table box ..." is:
flex-basis should apply to the inner table box like height does, but the spec doesn't explicit mention how to calculate the flex base size of the table wrapper box.

At least, having caption height included in the flex base size make the table behave consistent in both flex and block container. https://jsfiddle.net/aethanyc/vfqe4ok2/

Do you feel it's worth filing a spec issue for clarification?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the spec is explicitly calling for not including caption's height in the flex base size.

Agreed, there is nothing explicit. Just seems like a weird omission in the text. Like, if including caption's height in the flex base size was intended, I feel like THAT would be explicit.

My interpretation to the sentence "However, like width and height, the flex longhands apply to the table box ..." is:
flex-basis should apply to the inner table box like height does, but the spec doesn't explicit mention how to calculate the flex base size of the table wrapper box.

Oh, yeah, we are saying the same thing about spec not being explicit about caption heights + flex base size, maybe I just have a different interpretation of the implications of the omission :)

At least, having caption height included in the flex base size make the table behave consistent in both flex and block container. https://jsfiddle.net/aethanyc/vfqe4ok2/

Do you feel it's worth filing a spec issue for clarification?

Honestly, probably not. If FF and Blink both agree to add caption height to the flex base size (including for http://wpt.live/css/css-flexbox/table-as-item-stretch-cross-size-5.html where Chrome Canary and Firefox Nightly disagree today), then let's just run with that interpretation and I'll ignore my reservations about the omission we talked about above. It's probably more trouble than it's worth to get spec clarification; interop is most important and this vanishingly small use case is probably not worth our collective time to dig further into.

Does that make sense?

In any event, thanks a bunch for engaging here and adding a bunch of flex+caption tests that Chrome was failing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, make sense to me. Let's stick with our interpretation. The current tests should guarantee the interop.

In any event, thanks a bunch for engaging here and adding a bunch of flex+caption tests that Chrome was failing.

Thank you. It's nice to have this conversation!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, make sense to me. Let's stick with our interpretation. The current tests should guarantee the interop.

In any event, thanks a bunch for engaging here and adding a bunch of flex+caption tests that Chrome was failing.

Thank you. It's nice to have this conversation!

@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-2804711 branch 2 times, most recently from a479673 to 06c9f45 Compare April 6, 2021 04:52
Flexbox needs caption block size to compute table wrapper block size.
Table's css minimum-size specifies size of the grid, not the wrapper.
Wrapper's true block minimum size is css minimum-size + block size.

This patch exposes a method on TablesNG for flex to retrieve the caption
block size. (Thanks atotic!) Flex then adds the result to flex base size
when the flex base size derives from a specified block size or flex
basis.

Bug: 1181403
Change-Id: I61d7caf62708ae32850b89c444374e7a6c40d564
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2804711
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: Aleks Totic <atotic@chromium.org>
Commit-Queue: David Grogan <dgrogan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#869577}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants