Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 2178fce816b64e41bc8b3127e91febb928d46b9e
https://github.com/WebKit/WebKit/commit/2178fce816b64e41bc8b3127e91febb928d46b9e
Author: Alan Baradlay <[email protected]>
Date: 2026-07-27 (Mon, 27 Jul 2026)
Changed paths:
M Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.cpp
M Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.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
M Source/WebCore/rendering/RenderBlock.cpp
M Source/WebCore/rendering/RenderBlock.h
M Source/WebCore/rendering/RenderBlockFlow.cpp
M Source/WebCore/rendering/RenderBox.cpp
M Source/WebCore/rendering/RenderFlexibleBox.cpp
M Source/WebCore/rendering/RenderFlexibleBox.h
Log Message:
-----------
[cleanup] Move flex item list, painting, hit-testing and margin trimming off
RenderFlexibleBox
https://bugs.webkit.org/show_bug.cgi?id=320317
Reviewed by Antti Koivisto.
RenderFlexibleBox held two pieces of per-layout flex state: the ordered flex
item list and the
margin-trim item sets. Both are produced and consumed by the flex algorithm --
the setters for the
margin-trim sets were already only called from FlexIntegrationUtils, and the
item list only exists
between prepareFlexItemsAndMargins and the post-layout queries -- so move both
to FlexLayout, and
with them the functions that walk them.
Folding prepareFlexItemsAndMargins into layout() while there: it builds the
item list, which is now
FlexLayout's own member, and the only reason it was a separate step was that
layoutBlock had to
snapshot the items' rects between building the list and running the algorithm.
The snapshot and the
repaint it feeds stay on RenderFlexibleBox: repainting is the renderer's job
and it has to be
sequenced against the scrollbar reconciliation, which can move the items after
the flex algorithm is
done. Both walk the in-flow children directly, since the item list is built
inside layout() now --
the same shape RenderDeprecatedFlexibleBox uses, where the snapshot and the
repaint each re-walk the
children.
RenderBlock overrides have to stay on the renderer, so paintChildren,
hitTestChildren,
allowedLayoutOverflow and isChildEligibleForMarginTrim become one-line
forwarders, the same shape
RenderBlockFlow::hitTestInlineChildren already has for the inline formatting
context.
allowedLayoutOverflow keeps the RenderBox::allowedLayoutOverflow() call, which
only the derived
class can make, and passes the result to FlexLayout to widen; the two
content-alignment overflow
values it reads move along with it.
This needs RenderBlock::paintChild to be public: FlexLayout::paint walks the
item list itself and
paints each item through it, the way LineLayout::hitTest calls the public
per-child entry points
rather than reusing the container's child-iteration helpers.
Also move the container queries that were thin proxies to FlexFormattingUtils.
willStretchItem and
hasStretchedFlexItemWithAspectRatio move their bodies there; isMultiline and
isHorizontalFlow are
deleted outright, with their handful of callers in RenderBlock, RenderBlockFlow
and RenderBox
calling the utils directly (RenderFlexibleBox itself already did).
hasStretchedFlexItemWithAspectRatio
keeps walking the children rather than the collected item list: it runs from
layout invalidation,
before the container has necessarily laid out.
Finally, resetAutoMarginsAndLogicalTopInCrossAxis,
dirtyPercentHeightDescendantsWithinFlexItem and
flexItemHasPercentHeightDescendants had FlexIntegrationUtils as their only
caller and mutate or
query flex items, so they move there.
No change in behaviour.
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.cpp:
(WebCore::FlexFormattingUtils::willStretchFlexItem):
(WebCore::FlexFormattingUtils::hasStretchedFlexItemWithAspectRatio):
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.h:
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp:
(WebCore::LayoutIntegration::FlexIntegrationUtils::resetAutoMarginsAndLogicalTopInCrossAxis):
(WebCore::LayoutIntegration::FlexIntegrationUtils::dirtyPercentHeightDescendantsWithinFlexItem):
(WebCore::LayoutIntegration::FlexIntegrationUtils::flexItemHasPercentHeightDescendants):
(WebCore::LayoutIntegration::FlexIntegrationUtils::addItemAtFlexLineStart):
(WebCore::LayoutIntegration::FlexIntegrationUtils::addItemAtFlexLineEnd):
(WebCore::LayoutIntegration::FlexIntegrationUtils::addItemOnFirstFlexLine):
(WebCore::LayoutIntegration::FlexIntegrationUtils::addItemOnLastFlexLine):
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.h:
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
(WebCore::LayoutIntegration::FlexLayout::initializeMarginTrimState):
(WebCore::LayoutIntegration::FlexLayout::isFlexItemEligibleForMarginTrim):
(WebCore::LayoutIntegration::FlexLayout::prepareFlexItemsAndMargins):
(WebCore::LayoutIntegration::FlexLayout::adjustAllowedLayoutOverflow):
(WebCore::LayoutIntegration::FlexLayout::paint):
(WebCore::LayoutIntegration::FlexLayout::hitTest):
(WebCore::LayoutIntegration::FlexLayout::collectFlexItems):
(WebCore::LayoutIntegration::FlexLayout::layout):
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h:
* Source/WebCore/rendering/RenderBlock.cpp:
* Source/WebCore/rendering/RenderBlock.h:
* Source/WebCore/rendering/RenderBlockFlow.cpp:
* Source/WebCore/rendering/RenderBox.cpp:
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::layoutBlock):
(WebCore::RenderFlexibleBox::hitTestChildren):
(WebCore::RenderFlexibleBox::paintChildren):
(WebCore::RenderFlexibleBox::willStretchItem):
(WebCore::RenderFlexibleBox::flexItemBorderBoxRects):
(WebCore::RenderFlexibleBox::repaintFlexItemsDuringLayoutIfMoved):
(WebCore::RenderFlexibleBox::allowedLayoutOverflow):
(WebCore::RenderFlexibleBox::isChildEligibleForMarginTrim):
(WebCore::RenderFlexibleBox::hasStretchedFlexItemWithAspectRatio): Deleted.
(WebCore::RenderFlexibleBox::isHorizontalFlow): Deleted.
(WebCore::RenderFlexibleBox::isMultiline): Deleted.
(WebCore::RenderFlexibleBox::initializeMarginTrimState): Deleted.
(WebCore::RenderFlexibleBox::prepareFlexItemsAndMargins): Deleted.
(WebCore::RenderFlexibleBox::appendFlexItemBorderBoxRects): Deleted.
(WebCore::RenderFlexibleBox::resetAutoMarginsAndLogicalTopInCrossAxis): Deleted.
(WebCore::RenderFlexibleBox::dirtyPercentHeightDescendantsWithinFlexItem):
Deleted.
(WebCore::RenderFlexibleBox::flexItemHasPercentHeightDescendants): Deleted.
* Source/WebCore/rendering/RenderFlexibleBox.h:
Canonical link: https://commits.webkit.org/317974@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications