Bug 233032 - Percentage size inside a fit-content parent in quirk mode
Summary: Percentage size inside a fit-content parent in quirk mode
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2021-11-12 01:11 PST by cathiechen
Modified: 2024-07-25 09:03 PDT (History)
2 users (show)

See Also:


Attachments
Test Case (157 bytes, text/html)
2024-07-25 09:03 PDT, Ahmad Saleem
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description cathiechen 2021-11-12 01:11:51 PST
We found the behavior of the following case is different in browsers.
The img and div size is 1x1 in Chrome.
While the img and div size is 1xA in Safari and FireFox, where A is the screen height.

Test case:
```
<div style="width:fit-content;height:fit-content;">
    <img style="width: 100%; height: 100%" src="https://w3c-test.org/images/green-1x1.png"/>
</div>
```
Or open https://output.jsbin.com/nodecov/quiet


We have discussed this in https://bugs.chromium.org/p/chromium/issues/detail?id=1268427

According to https://quirks.spec.whatwg.org/#the-percentage-height-calculation-quirk
The containing block is DIV.
Then according to https://www.w3.org/TR/CSS22/visudet.html#the-height-property
> If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned, the used height is calculated as if 'auto' was specified.

So the height of IMG is “Behaving as auto” (https://drafts.csswg.org/css-sizing-3/#behave-auto)
So the IMG size should be 1x1, so as to DIV's.

WDYT? Do we need a consistent here?
Comment 1 Radar WebKit Bug Importer 2021-11-19 01:12:20 PST
<rdar://problem/85591164>
Comment 2 Ahmad Saleem 2024-07-25 09:03:24 PDT
Created attachment 471965 [details]
Test Case