Bug 246451

Summary: Layout of nested grid with padding and aspect ratio fails
Product: WebKit Reporter: Johannes Odland <johannes.odland>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: bfulgham, karlcow, simon.fraser, webkit-bug-importer, webkit-layout-noreply, zalan
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari 16   
Hardware: Mac (Apple Silicon)   
OS: macOS 12   
Attachments:
Description Flags
Screenshot in Safari
none
Screenshot in Chrome none

Description Johannes Odland 2022-10-13 04:02:01 PDT
Created attachment 462956 [details]
Screenshot in Safari

Element in grid container with aspect-ratio, padding and align-content: end is placed outside grid if grid container is nested in another grid container.

I have replicated the bug in the following code pen: https://codepen.io/johannesodland/pen/xxjMgzr

```html
  <section>
    <div class="hero">
      <h2>Title</h2>
    </div>
  </section>

```

```css
:root {
  --_padding: 15px;
}

section {
  display: grid;
}

.hero {
  display: grid;
  background-color: silver;
  aspect-ratio: 16 / 9;
  padding: var(--_padding);
  align-content: end;
  justify-items: start;
}

h2 {
  margin: 0;
  padding: var(--_padding);
  background: mediumorchid;
}

```

Expected result: h2 is rendered inside padding at the bottom of the containing grid element.
This is correct in Chrome and Firefox.

Actual result: h2 is rendered 2 x padding below where it is expected, 1 x padding outside containing grid.


The bug also happens if the grid is inside a flex container, but not if its in a flow container.
Comment 1 Johannes Odland 2022-10-13 04:02:33 PDT
Created attachment 462957 [details]
Screenshot in Chrome
Comment 2 Karl Dubost 2022-10-13 19:03:44 PDT
Johannes, Thanks for the report.
Can you reproduce in STP 155?
https://developer.apple.com/safari/technology-preview/

It is working for me in STP 155.
Comment 3 Johannes Odland 2022-10-13 22:24:43 PDT
It works fine in TP 155. My bad, I should have checked there first. 

Do you know when the next release is due?
Comment 4 Radar WebKit Bug Importer 2022-10-20 04:02:20 PDT
<rdar://problem/101376382>