Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: abba71dc926a5e7579e8acd3dfdb5393b5567b3a
      
https://github.com/WebKit/WebKit/commit/abba71dc926a5e7579e8acd3dfdb5393b5567b3a
  Author: Alan Baradlay <[email protected]>
  Date:   2026-07-28 (Tue, 28 Jul 2026)

  Changed paths:
    M Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp
    M Source/WebCore/layout/formattingContexts/flex/FlexLayoutState.h
    M Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp
    M Source/WebCore/layout/integration/flex/FlexIntegrationUtils.h
    M Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp
    M Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h

  Log Message:
  -----------
  [cleanup] Compute the flex container's block-size definiteness up front
https://bugs.webkit.org/show_bug.cgi?id=320420

Reviewed by Antti Koivisto.

Whether a percentage in the flex container's block axis resolves to a length is 
a property of the container: a
flex item's containing block is the flex container, and the percentage walk 
never leaves it. The answer has to be
the one from before the items were flexed, because the algorithm installs 
overriding sizes on them as it goes, so
it was cached -- but it was cached lazily, by whichever query happened to come 
first, from two sites that gated
the same slot differently, with the only reset inside the per-item loop of 
computeFlexBaseAndHypotheticalMainSizes.

Ask the container instead, once, in FlexLayout::layout before the formatting 
context runs. hasDefiniteLogicalHeight
is exactly the question -- it is availableLogicalHeightForPercentageComputation 
as a bool -- and that is what a
flex item's percentage resolves against once the cases below are excluded. 
FlexLayoutState now holds a plain bool
seeded at construction: no setter, no reset, and nothing writes it during 
layout.

Two kinds of flex item resolve by a route the container cannot answer for, and 
they still ask the renderer.
isFlexBoxBlockSizeDefiniteForFlexItem returns nullopt for them: an orthogonal 
item resolves its percentage block
size against the container's inline size, and a widget substitutes its own 
intrinsic height for a percentage that
did not resolve, so it can be definite where the container is not.

Answering from the container also has to take over the one thing 
computePercentageLogicalHeight does besides
answer: with UpdatePercentageHeightDescendants::Yes it registers the item as a 
percent-height descendant of its
containing block, which is what dirties the item when the container is resized. 
That containing block is the flex
container -- the percentage walk cannot leave it, the same reason the container 
can answer at all -- so the
registration happens here instead.

That drops three latent problems. The formatting context's cross-size query 
gated on mainAxisIsInlineAxis while
the integration layer's gated on !isOrthogonal, so a column-flow orthogonal 
item wrote the slot from a value
derived from the container's inline size and a later query read it back as the 
container's block size. An item
whose percent resolution was suspended stored false, which then stood for every 
other item. And once past the
base-size loop nothing reset the slot, so the answer for the whole rest of the 
layout came from whichever item
happened to lay out first and happened to have a percent-height descendant.

* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::FlexFormattingContext::computeFlexBaseAndHypotheticalMainSizes):
(WebCore::FlexFormattingContext::flexItemCrossSizeIsDefinite):
* Source/WebCore/layout/formattingContexts/flex/FlexLayoutState.h:
(WebCore::FlexLayoutState::FlexLayoutState):
(WebCore::FlexLayoutState::isFlexBoxBlockSizeDefinite const):
(WebCore::FlexLayoutState::isFlexBoxBlockSizeIndefinite const): Deleted.
(WebCore::FlexLayoutState::setFlexBoxBlockSizeIsDefinite): Deleted.
(WebCore::FlexLayoutState::resetFlexBoxBlockSizeDefiniteness): Deleted.
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp:
(WebCore::LayoutIntegration::FlexIntegrationUtils::isFlexBoxBlockSizeDefiniteForFlexItem
 const):
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.h:
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
(WebCore::LayoutIntegration::FlexLayout::layout):
(WebCore::LayoutIntegration::FlexLayout::isFlexBoxBlockSizeDefiniteForFlexItem 
const):
(WebCore::LayoutIntegration::FlexLayout::canResolvePercentAgainstContainerBlockSize):
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h:
(WebCore::LayoutIntegration::FlexLayout::isInLayout const):
(WebCore::LayoutIntegration::FlexLayout::isFlexBoxBlockSizeDefinite const): 
Deleted.
(WebCore::LayoutIntegration::FlexLayout::isFlexBoxBlockSizeIndefinite const): 
Deleted.
(WebCore::LayoutIntegration::FlexLayout::setFlexBoxBlockSizeIsDefinite): 
Deleted.

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



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

Reply via email to