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

  Changed paths:
    M LayoutTests/TestExpectations
    M Source/WebCore/rendering/RenderBox.cpp

  Log Message:
  -----------
  Aspect-ratio automatic minimum should not override flex/grid stretch on the 
cross axis
https://bugs.webkit.org/show_bug.cgi?id=313375

Reviewed by Antti Koivisto.

CSS Sizing 4 says the automatic minimum in the ratio-dependent axis of a box
with aspect-ratio is its min-content size.
(the axis whose size is derived from the other axis through the aspect ratio)
But for a stretched flex/grid item, the cross size is determined by the 
container, not the
aspect ratio. The stretch determines the cross size - the aspect ratio
should not fight it.

  <div style="display: flex; width: 0px; height: 100px;">
    <div style="aspect-ratio: 1/2;">
      <div style="width: 100px;"></div>
    </div>
  </div>

The flex item gets width: 100px (from content) and is stretched to
height: 100px. But the aspect-ratio automatic minimum computes
min-height: 200px (width 100 with ratio 1:2), overriding the stretch.

Before: 100x200 (aspect-ratio min-height overrides stretch)
After:  100x100 (stretch wins on the cross axis)

The fix adds a hasStretchedLogicalHeight/Width guard to the automatic
minimum computation. When the containing flex/grid will stretch the
item, the automatic minimum from aspect-ratio is skipped on that axis.

Also refactored the verbose single-line conditions into
shouldComputeAutomaticMinimumFromAspectRatio lambdas with early returns.

* LayoutTests/TestExpectations:
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::constrainLogicalWidthByMinMax const):
(WebCore::RenderBox::constrainLogicalHeightByMinMax const):

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



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

Reply via email to