Open Bug 1888262 Opened 1 year ago Updated 8 months ago

Flex Items containing image or canvas do not scale width properly when image size is set with % units

Categories

(Core :: Layout: Flexbox, defect)

defect

Tracking

()

People

(Reporter: bdyer733, Unassigned)

References

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0

Steps to reproduce:

Created a flex div with a fixed height, added a div inside of it then added an image inside of it with height set to 100%. width:max-content/fit-content does not change the results. In some situations height:inherit works but not in others( I don't have a simplified version for this )

Actual results:

The flex item div's width was computed as the natural width of the image instead of the calculated width.

Expected results:

The flex-item div size should match the image's final size.

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Flexbox' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Layout: Flexbox
Product: Firefox → Core

Adjust the reporter's testcase so that it is easier to see the bug.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
See Also: → 1735589
Version: Firefox 124 → Trunk

Unfortunately, bug 1926015 doesn't address this bug.

In Testcase 1, the flex item has a stretched height, which should affect its intrinsic inline size if it has descendants with an aspect ratio. My intuition for the fix is that we can move the cross-size pre-stretch to a position before creating ReflowInput. This way, the flex base size will take the stretched cross-size (height) into consideration when we create ReflowInput to compute various sizes for the item.

(In reply to Ting-Yu Lin [:TYLin] (PST, UTC-8) from comment #2)

Created attachment 9394339 [details]
Testcase 1 (add red border to the flex item)

FWIW, I see that Firefox 133, Safari 18.1.1, and Chrome 131 on macOS 15.1.1 all render Testcase 1's red border differently.

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

Attachment

General

Creator:
Created:
Updated:
Size: