WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
276681
contain: size breaks object-fit
https://bugs.webkit.org/show_bug.cgi?id=276681
Summary
contain: size breaks object-fit
Eric Portis
Reported
2024-07-16 13:43:52 PDT
Right now, in WebKit, applying contain:size to an element with object-fit:contain effectively disables object-fit:contain. The CSSWG has resolved that contain:size should only affect the size of the element's box, but not affect the natural aspect-ratio of its contents (which are used by object-fit):
https://github.com/w3c/csswg-drafts/issues/10116#issuecomment-2035803916
Use cases: - Using object-fit along with auto-sizes (this issue blocks
https://bugs.webkit.org/show_bug.cgi?id=253143
because of
https://html.spec.whatwg.org/multipage/rendering.html#img-contain-size
) - Making an img's box size completely determined from the "outside-in" without distorting it, e.g., in grids:
https://codepen.io/eeeps/pen/PorPgvy
While the spec has not been written yet, there are Web Platform Tests for this resolution, which WebKit alone fails:
https://wpt.fyi/results/css/css-images?label=master&product=safari%5Bstable%5D&product=safari%5Bexperimental%5D&product=firefox%5Bstable%5D&product=chrome%5Bstable%5D&aligned&q=object-fit-containsize%20or%20object-fit-containcontain
Attachments
[fast-cq]Patch
(3.98 KB, patch)
2025-01-22 12:32 PST
,
alan
no flags
Details
Formatted Diff
Diff
Patch
(4.00 KB, patch)
2025-01-23 05:50 PST
,
alan
no flags
Details
Formatted Diff
Diff
[fast-cq]Patch
(4.00 KB, patch)
2025-01-23 05:56 PST
,
alan
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2024-07-16 13:50:53 PDT
<
rdar://problem/131866042
>
alan
Comment 2
2025-01-22 12:32:58 PST
Created
attachment 473977
[details]
[fast-cq]Patch
Tim Nguyen (:ntim)
Comment 3
2025-01-22 22:45:04 PST
Comment on
attachment 473977
[details]
[fast-cq]Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=473977&action=review
> COMMIT_MESSAGE:1 > +Contain:size breaks object-fit
tiny nit: formatting of the CSS property name is a bit weird. Would be good to format like this: `contain: size` breaks `object-fit`
alan
Comment 4
2025-01-23 05:50:55 PST
Created
attachment 473985
[details]
Patch
alan
Comment 5
2025-01-23 05:56:38 PST
Created
attachment 473986
[details]
[fast-cq]Patch
EWS
Comment 6
2025-01-23 06:02:38 PST
Committed
289287@main
(0217089631af): <
https://commits.webkit.org/289287@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 473986
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug