Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 645e8793d617aefc0fa2431c7a53fe9464c526eb
      
https://github.com/WebKit/WebKit/commit/645e8793d617aefc0fa2431c7a53fe9464c526eb
  Author: Alan Baradlay <[email protected]>
  Date:   2026-05-13 (Wed, 13 May 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-cross-size-001-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-cross-size-001-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-cross-size-001.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-nested-001-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-nested-001-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-nested-001.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-nested-002-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-nested-002-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-nested-002.html
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/RenderBox.cpp
    M Source/WebCore/rendering/RenderBox.h
    M Source/WebCore/rendering/RenderFlexibleBox.cpp

  Log Message:
  -----------
  [Flex] position: absolute parent breaks flex child aspect-ratios
https://bugs.webkit.org/show_bug.cgi?id=264043

Reviewed by Antti Koivisto.

  <div style="height: 200px; position: relative">
    <div style="display: flex; position: absolute; top: 0; bottom: 0">
      <img src="1x1-green.png">
    </div>
  </div>

The image should be 200x200 (stretched to the flex container's height, then
width from 1:1 aspect ratio). Instead it was 1x200 - the image used its
intrinsic width because the flex algorithm didn't recognize the container's
height as definite.

hasDefiniteCrossSizeForFlexItem only recognized fixed heights and resolvable
percentages. It missed the out-of-flow case where height is auto but both
block-axis insets are specified - CSS Sizing 3 section 3.2.1 says this makes
the size "fully constrained" and therefore definite.

The fix adds hasFullyConstrainedLogicalHeight() on RenderBox and uses it in
hasDefiniteCrossSizeForFlexItem and innerCrossSizeForFlexItem. However, it
must be guarded: in nested flex layouts, the containing block may be a flex
item that hasn't been stretched yet (height is 0). The guard
canResolveFullyConstrainedLogicalHeight() checks that the containing block's
height is currently definite (via hasDefiniteLogicalHeight, which respects
flex phase flags through canUseFlexItemForPercentageResolution).

Also extracts the inline lambda in 
availableLogicalHeightForPercentageComputation
to use the shared hasFullyConstrainedLogicalHeight() helper.

* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::hasFullyConstrainedLogicalHeight):
* Source/WebCore/rendering/RenderBox.h:
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::availableLogicalHeightForPercentageComputation):
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
(WebCore::canResolveFullyConstrainedLogicalHeight):
(WebCore::RenderFlexibleBox::hasDefiniteCrossSizeForFlexItem):
(WebCore::RenderFlexibleBox::innerCrossSizeForFlexItem):
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-cross-size-001{,-ref,-expected}.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-nested-001{,-ref,-expected}.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-abspos-inset-nested-002{,-ref,-expected}.html:
 Added.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Canonical link: https://commits.webkit.org/313213@main



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

Reply via email to