Created attachment 460128 [details] Offline repro If we have: 1. div with display: inline-block, or 2. div in flexbox container that has a text with visually hidden element inside, this div's auto width is incorrect (unnecessarily small), causing the text to wrap with no reason. Repro: https://4kpsi4.csb.app/ Interactive repro: https://codesandbox.io/s/webkit-element-sizing-bug-4kpsi4 This can be reproduced both on macOS Monterey and iOS 15.
Created attachment 460130 [details] Test reduction Apparently the combination of out-of-flow block box + margin offset confuses the preferred with computation for shrink-to-fit content.
The margin is mistakenly included twice during line layout, first when the out-of-flow box is placed (static position) and later when the adjacent text content is taken care of.
Created attachment 460183 [details] Patch
Created attachment 460184 [details] Patch
Committed r295478 (251483@main): <https://commits.webkit.org/251483@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 460184 [details].
<rdar://problem/94935961>