Bug 233032

Summary: Percentage size inside a fit-content parent in quirk mode
Product: WebKit Reporter: cathiechen <cathiechen>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ahmad.saleem792, webkit-bug-importer
Priority: P2 Keywords: BrowserCompat, InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Test Case none

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