Closed Bug 1748339 Opened 4 years ago Closed 2 years ago

content-based 'flex-basis' produces a width of 0, in case where descendant with aspect ratio and resolvable percent height should prop it up

Categories

(Core :: Layout: Flexbox, defect)

defect

Tracking

()

VERIFIED FIXED
132 Branch
Webcompat Priority P3
Tracking Status
firefox132 --- verified
firefox133 --- verified

People

(Reporter: dholbert, Assigned: TYLin)

References

(Blocks 1 open bug)

Details

(Keywords: webcompat:platform-bug)

Attachments

(4 files)

[Filing this for https://github.com/webcompat/web-bugs/issues/97271 aka https://webcompat.com/issues/97271 ]

STR:

  1. Load attached testcase.

EXPECTED RESULTS:
You should see nested square borders with a solid-lime rectangle in the middle.

ACTUAL RESULTS:
No lime is visible; that rectangle is 0-width, as you can see from the collapsed black and orange borders.

This is apparently causing webcompat pain on reddit, as detailed in the webcompat.com report.

Firefox Nightly gives ACTUAL RESULTS.
Chrome gives EXPECTED RESULTS, which I think is correct here.

Attached file testcase 1
Attached file reference case 1

Notes:

  • We render the reference case correctly (i.e. we give EXPECTED RESULTS there). Its markup only differs from the testcase in that it uses a definite padding: 30px instead of padding: 10%. I think these two declarations are equivalent and are both definite, since the percent padding can be trivially resolved against the definite width:300px of the parent. Hence, I think the testcase and reference case can be expected to render the same, and the fact that they don't is indicative of a Firefox bug.

  • I have an explicit flex-basis:content in both attachments, but that's technically unnecessary - I just put it there for robustness. If you put some other non-content-dependent flex-basis there, e.g. flex-basis:0 or flex-basis:20px, then Firefox and Chrome agree on the rendering (and use the provided flex-basis value as the flex item's width).

I think this might be bug 1231059 that we wrongly use the block-size to resolve the percentage padding in order to compute the box-sizing:border-box adjustment in [1] or [2]. The evidence is that If you set height:300px to <body> in the testcase 1, it renders like the reference case.

If we want to fix this, it might be worth investigating bug 1363918 first.

[1] https://searchfox.org/mozilla-central/rev/253ae246f642fe9619597f44de3b087f94e45a2d/layout/base/nsLayoutUtils.cpp#4401-4413
[2] https://searchfox.org/mozilla-central/rev/253ae246f642fe9619597f44de3b087f94e45a2d/layout/base/nsLayoutUtils.cpp#4442-4458

See Also: → 1231059
Webcompat Priority: --- → ?
Webcompat Priority: ? → P3

I'm pretty sure https://webcompat.com/issues/105402 is a version of this bug, too.
Here's ksenia's reduced data-URI testcase from there:

data:text/html,<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><style>.photogallery-wrapper {height: 0;padding-top: 56.25%;position: relative;overflow: hidden;}.photogallery-swiper {position: absolute;top: 0;left: 0;width: 100%;height: 100%;background: rgb(0, 0, 0) none repeat scroll 0% 0%;}.swiper-wrapper {position: relative;width: 100%;height: 100%;display: flex;}.swiper-slide {width: 100%;height: 100%;position: relative;display: flex;justify-content: center;}.swiper-slide picture {height: 100%;display: flex;align-items: center;}.swiper-slide img {max-height: 100%;width: 100%;display: block;}</style></head><body><div class="photogallery-wrapper"><div class="photogallery-swiper"><div class="swiper-wrapper"><div class="swiper-slide"><picture><img data-src="/cropgd/160x232/dl/img/2022/06/04/1654304456887_larepubblica.jpeg"alt="Prima pagina de %E2%80%9Cla Repubblica%E2%80%9D"src="https://www.rainews.it/cropgd/160x232/dl/img/2022/06/04/1654304456887_larepubblica.jpeg"></picture></div></div></div></div></body></html>

As in comment 3: if I edit this data-URI testcase to use a pixel-valued padding on .photogallery-wrapper (instead of padding-top: 56.25%;), I end up with expected results. And similarly, if I add a pixel-valued height to that element, we seem to resolve descendant-percentages against that height instead of against the size of the padding box. (We should use the padding-box as the containing block for abspos descendants, per https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block )

I'll post a further-reduced version of ksenia's testcase as an attachment.

Attached file testcase 2

Here's my further-reduced version of ksenia's testcase.

Firefox renders no lime here.

"Expected results" are for lime to be visible, and for the lime area (and its teal border) to occupy approximately half of its pink-bordered parent box's width.

No longer blocks: 1835341
Blocks: 1835341
No longer blocks: 1891072
Depends on: 1909761

The two testcases are adapted from Daniel Holbert's testcase 1 and 2 in the bug.
Both are fixed by bug 1909761.

Assignee: nobody → aethanyc
Status: NEW → ASSIGNED
Pushed by aethanyc@gmail.com: https://hg.mozilla.org/integration/autoland/rev/ec726d591b2f Add two WPTs where the descendant has aspect-ratio and percentage height. r=dholbert
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/47943 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 132 Branch
Upstream PR merged by moz-wptsync-bot
Upstream PR merged by moz-wptsync-bot

Reproducible on a 2024-09-01 Nightly build on Windows 10.
Issue is verified as fixed on Firefox 132.0b2 and Firefox Nightly 133.0a1 on Windows 10, Ubuntu 22, macOS 14.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: