Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1d5202c6846d83eb29b4d2eac06a844045fae55b
      
https://github.com/WebKit/WebKit/commit/1d5202c6846d83eb29b4d2eac06a844045fae55b
  Author: Alan Baradlay <[email protected]>
  Date:   2026-04-17 (Fri, 17 Apr 2026)

  Changed paths:
    M LayoutTests/TestExpectations
    M LayoutTests/css3/flexbox/flexitem.html
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-011-expected.txt
    M Source/WebCore/rendering/RenderBox.cpp

  Log Message:
  -----------
  [Flex] Fix 
imported/w3c/web-platform-tests/css/css-flexbox/flex-minimum-height-flex-items-023.html
https://bugs.webkit.org/show_bug.cgi?id=312488

Reviewed by Antti Koivisto.

Given:

  <div style="display: flex; flex-direction: column; width: 100px; height: 0">
      <img src="300x150.png" style="min-height: min-content; height: 100px">
  </div>

The image should be 50px tall. Here's why:

1. Column flex with height: 0px. The item has flex-shrink: 1, so the
   flex algorithm tries to shrink it from 100px toward 0px.
2. 'min-height: min-content' sets a floor: "don't shrink me below
   what my content needs at least."
3. The image is 300x150 (2:1 ratio). The flex container stretches
   it to 100px wide (cross-axis stretch). At 100px wide, the 2:1
   ratio gives a minimum content height of 50px.
4. The flex algorithm stops shrinking at 50px.

Instead the image was 100px tall - it couldn't shrink at all.

When computing the min-content height for the image, WebKit calls
computeSizingKeywordLogicalContentHeightUsingGeneric. This function
has a special case for images with a fixed CSS width - it uses that
width with the aspect ratio to derive the height. But the image has
width:auto (the 100px comes from a flex cross-axis override, not
from CSS). The function fell back to the intrinsic height (150px),
making the content-based min = min(100, 150) = 100 - the same as
the specified height, so no shrinking happened.

The fix checks for a flex cross-axis overriding width when the CSS
width is auto. In a column flex container, the cross axis is the
width, so the override (100px) is the right value to send through
the aspect ratio: 100 / 2 = 50px.

* LayoutTests/TestExpectations:
* LayoutTests/css3/flexbox/flexitem.html:
  Progression -now we match Blink and Firefox.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-011-expected.txt:
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::computeSizingKeywordLogicalContentHeightUsingGeneric 
const):

Canonical link: https://commits.webkit.org/311443@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to