Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a018777818d96e2c5afc5e1967f001f5bd621a98
      
https://github.com/WebKit/WebKit/commit/a018777818d96e2c5afc5e1967f001f5bd621a98
  Author: Alan Baradlay <[email protected]>
  Date:   2026-10-02 (Fri, 02 Oct 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-flex-basis-on-row-expected.txt
    M Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp

  Log Message:
  -----------
  [Flex] A flex item's base size ignores the space available to it when its 
main size is fit-content
https://bugs.webkit.org/show_bug.cgi?id=324669
<rdar://problem/187932371>

Reviewed by Antti Koivisto.

    <!-- the item's max-content width is 600px, min-content 400px -->
    <div style="display: flex; width: 500px">
      <div style="width: calc-size(fit-content, size + 12px); flex-basis: 
calc-size(auto, size + 4px)">…</div>
    </div>

fit-content is 500px here, the space the flex container has for the item, so 
the width property is
512px and the flex base size 516px. It was 616px, because the base size came 
from the item's
max-content contribution, where fit-content can only answer max-content.

Flexbox 9.2 step E asks for the item to be sized into the available space with 
its used flex basis in
place of its main size, which is what the block axis does by laying the item 
out. The inline axis reads
the item's max-content contribution instead, so a main size whose used value 
depends on that space -
fit-content, stretch, or a percentage - came out too large. A plain auto main 
size makes the used flex
basis `content`, which the contribution answers correctly, so that keeps its 
path.

* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::Layout::FlexFormattingContext::flexBaseSizeForFlexItem):
(WebCore::FlexFormattingContext::flexBaseSizeForFlexItem):
Sizes the item into the available space when its main size needs that space to 
resolve, and lets the
flex basis's calculation run over that. The block axis already lays the item 
out, so this is the
inline axis only.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-flex-basis-on-row-expected.txt:

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



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

Reply via email to