Bug 225015 - Block sizing is miscalculated for elements with a preferred aspect-ratio when padding is applied, and content can overflow.
Summary: Block sizing is miscalculated for elements with a preferred aspect-ratio when...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Blocker
Assignee: Rob Buis
URL:
Keywords: InRadar
Depends on:
Blocks: 47738
  Show dependency treegraph
 
Reported: 2021-04-24 08:15 PDT by Jen Simmons
Modified: 2021-04-28 18:00 PDT (History)
17 users (show)

See Also:


Attachments
Patch (2.11 KB, patch)
2021-04-24 10:54 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (2.68 KB, patch)
2021-04-25 02:11 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (2.45 KB, patch)
2021-04-25 03:43 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (5.86 KB, patch)
2021-04-25 11:05 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (5.77 KB, patch)
2021-04-28 10:03 PDT, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jen Simmons 2021-04-24 08:15:49 PDT
When `aspect-ratio` is applied to a box with content, the box should prevent overflow by growing to be tall enough to fit the content, plus space for whatever margins or padding are involved. 

From the spec: 
>In order to avoid unintentional overflow, the automatic minimum size in the ratio-dependent axis of a box with a preferred aspect ratio that is neither a replaced element nor a scroll container is its min-content size clamped from above by its maximum size.
https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum

This works in the WebKit implementation, unless there is padding applied to the box. It looks like the padding is being subtracted from the height, instead of added, or something similarly weird.

Example: https://labs.jensimmons.com/2021/aspect-ratio/04-bug.html
Comment 1 Rob Buis 2021-04-24 10:54:51 PDT
Created attachment 426984 [details]
Patch
Comment 2 Rob Buis 2021-04-25 02:11:24 PDT
Created attachment 426997 [details]
Patch
Comment 3 Rob Buis 2021-04-25 03:43:16 PDT
Created attachment 427000 [details]
Patch
Comment 4 Rob Buis 2021-04-25 11:05:06 PDT
Created attachment 427006 [details]
Patch
Comment 5 EWS Watchlist 2021-04-25 11:06:16 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 6 Rob Buis 2021-04-28 10:03:54 PDT
Created attachment 427273 [details]
Patch
Comment 7 Radar WebKit Bug Importer 2021-04-28 11:42:20 PDT
<rdar://problem/77276415>
Comment 8 Rob Buis 2021-04-28 11:53:35 PDT
To be clear, the first patches had a WPT test included that I developed. Today I discovered that there is already a very similar WPT test available, so the latest patch imports that one.
Comment 9 Darin Adler 2021-04-28 12:05:36 PDT
Comment on attachment 427273 [details]
Patch

Looks OK.

But there are multiple code changes and only one test case. Seems like we need more test cases. When I see branches in code I assume each needs a different test, so this seems to require at *least* 3 tests, but maybe more if we want to cover not changing the cases we don’t want to.
Comment 10 EWS 2021-04-28 18:00:35 PDT
Committed r276745 (237145@main): <https://commits.webkit.org/237145@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 427273 [details].