Open Bug 1953879 Opened 1 month ago Updated 27 days ago

For flex items that are replaced elements (e.g. img, canvas) with percent width and auto height, Firefox shrinks them to be smaller than their specified width, but other browsers don't

Categories

(Core :: Layout: Flexbox, defect)

defect

Tracking

()

People

(Reporter: dholbert, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: webcompat:platform-bug)

Attachments

(2 files)

Attached file testcase 1

[might be a dupe, not sure]

STR:

  1. Load attached testcase.

EXPECTED RESULTS:
Two large purple squares, each one having 2x width of the orange box.

ACTUAL RESULTS:
Two small purple squares, both shrunk to fit inside the orange box.

This is the root cause of webcompat site-report bug 1953077, affecting nintendo.com.

Chromium/WebKit give EXPECTED RESULTS; Firefox 138.0a1 (2025-03-10) gives ACTUAL RESULTS.

It looks like we're treating the percent-width on the canvas element as permission to lower the automatic minimum width to 0, whereas Chrome and WebKit are resolving that percent width against the size of the container and are using it as a specified-size-suggestion (to reduce the automatic minimum width to that amount). Or something along those lines...

Summary: Flex items with aspect-ratio and percent width are smaller in Firefox than in other browsers → For flex items that are replaced elements (e.g. img, canvas) with percent width and auto height, Firefox shrinks them to be smaller than their specified width, but other browsers don't

Here's a testcase that compares replaced element flex items (<canvas> in this case) to a regular div with an aspect-ratio, with a large specified height to give us a large "transferred size suggestion" in both cases.

Chrome renders both of these the same, with the flex item at its specified percent width.
Firefox renders the top half with the canvas flex items squished to fit (as with the previous testcase), whereas we match Chrome on the bottom half (with the div flex items).

See Also: → 1956674
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: