Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9a673f3622a5675f068b3bb54efa3fe058907f3c
https://github.com/WebKit/WebKit/commit/9a673f3622a5675f068b3bb54efa3fe058907f3c
Author: Alan Baradlay <[email protected]>
Date: 2026-07-22 (Wed, 22 Jul 2026)
Changed paths:
M Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp
M Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.h
M Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.cpp
M Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.h
Log Message:
-----------
[cleanup] Pass FlexLayoutItem instead of RenderBox to
FlexFormattingContext-only flex-item utilities
https://bugs.webkit.org/show_bug.cgi?id=320006
Reviewed by Antti Koivisto.
FlexFormattingContext already carries a FlexLayoutItem for every in-flow item
(with its cached border/padding/margin and a style() accessor), yet it kept
unwrapping it back to the RenderBox to feed FlexFormattingUtils and to read the
item's style. Route flex-item access through FlexLayoutItem instead.
- The FFC-only instance overloads of FlexFormattingUtils (the flow-aware
margins,
crossAxisMarginExtentForFlexItem, the min/max/preferred length getters,
hasAutoMarginsInCrossAxis, useContentBasedMinimumSize,
innerCrossSizeForFlexItem,
mainAxisIsFlexItemInlineAxis, flexBasisForFlexItem, alignmentForFlexItem,
hasDefiniteCrossSizeForFlexItem, marginBoxAscentForFlexItem,
preferredAspectRatioForFlexItem, flexItemHasComputableAspectRatio and
needToStretchFlexItemLogicalHeight) now take a const FlexLayoutItem&; the
static
forms keep taking RenderBox for RenderFlexibleBox's proxies, and the item
methods
LayoutIntegration calls for positioned items (crossAxisExtentForFlexItem,
mainAxisExtentForFlexItem, mainAxisMarginExtentForFlexItem,
availableAlignmentSpaceForFlexItem, overflowAlignmentForFlexItem) stay on
RenderBox.
- Flex-item style reads in the formatting context go through
flexLayoutItem.style()
rather than reaching through to the renderer.
Along the way, tidy the item-sizing setup: the 9.2 base-size loop moves into
computeFlexBaseAndHypotheticalMainSizes(),
flexBaseSizeNeedsBlockAxisContentSize() is
inlined into ensureBlockAxisContentSizeForFlexItemIfNeeded(),
handleMainAxisAlignment()
returns its positions with the column main-content extent as an out-argument,
computeFlexLineCrossPositions() becomes a helper, and FlexLayoutItem snapshots
its
main-axis margin at construction (re-reading it only for orthogonal items after
layout).
No change in behavior.
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::FlexFormattingContext::layout):
(WebCore::FlexLayoutItem::FlexLayoutItem):
(WebCore::FlexFormattingContext::computeFlexBaseAndHypotheticalMainSizes):
(WebCore::FlexFormattingContext::computeFlexLines):
(WebCore::FlexFormattingContext::hypotheticalCrossSizeForFlexItems):
(WebCore::FlexFormattingContext::crossSizeForFlexLines):
(WebCore::FlexFormattingContext::computeFlexLineCrossPositions):
(WebCore::FlexFormattingContext::handleMainAxisAlignment):
(WebCore::FlexFormattingContext::computeCrossSizeForFlexItems):
(WebCore::FlexFormattingContext::handleCrossAxisAlignmentForFlexItems):
(WebCore::FlexFormattingContext::performBaselineAlignment):
(WebCore::FlexFormattingContext::placeFlexItems):
(WebCore::FlexFormattingContext::layoutColumnReverse):
(WebCore::FlexFormattingContext::flexBaseSizeForFlexItem):
(WebCore::FlexFormattingContext::ensureBlockAxisContentSizeForFlexItemIfNeeded):
(WebCore::FlexFormattingContext::minMaxMainSizesForFlexItem):
(WebCore::FlexFormattingContext::computeUsedMaxMainSize):
(WebCore::FlexFormattingContext::computeContentBasedMinMainSize):
(WebCore::FlexFormattingContext::computeMainAxisExtentForFlexItem):
(WebCore::FlexFormattingContext::computeMainSizeFromAspectRatioUsing const):
(WebCore::FlexFormattingContext::adjustFlexItemSizeForAspectRatioCrossAxisMinAndMax):
(WebCore::FlexFormattingContext::flexItemIntrinsicLogicalHeight const):
(WebCore::FlexFormattingContext::flexItemIntrinsicLogicalWidth):
(WebCore::FlexFormattingContext::flexItemHasComputableAspectRatioAndCrossSizeIsConsideredDefinite):
(WebCore::FlexFormattingContext::canFitItemWithTrimmedMarginEnd const):
(WebCore::FlexFormattingContext::updateAutoMarginsInCrossAxis):
(WebCore::FlexFormattingContext::applyStretchAlignmentToFlexItem):
(WebCore::FlexFormattingContext::applyStretchMinMaxCrossSize):
(WebCore::FlexFormattingContext::flexBaseAndHypotheticalMainSize): Deleted.
(WebCore::FlexFormattingContext::flexBaseSizeNeedsBlockAxisContentSize):
Deleted.
(WebCore::FlexFormattingContext::computeFlexItemMinMaxMainSizes): Deleted.
(WebCore::FlexFormattingContext::crossAxisIntrinsicExtentForFlexItem): Deleted.
(WebCore::constrainSizeByMinMax):
(WebCore::FlexFormattingContext::computeUsedNonAutoMinMainSize):
(WebCore::FlexFormattingContext::flexItemCrossSizeIsDefinite):
(WebCore::FlexFormattingContext::trimMainAxisMarginStart):
(WebCore::FlexFormattingContext::trimMainAxisMarginEnd):
(WebCore::FlexFormattingContext::removeMarginEndFromFlexSizes const):
(WebCore::FlexFormattingContext::flexFormattingUtils const):
(WebCore::FlexLayoutItem::hypotheticalMainAxisMarginBoxSize const):
(WebCore::FlexLayoutItem::flexBaseMarginBoxSize const):
(WebCore::FlexLayoutItem::flexedMarginBoxSize const):
(WebCore::FlexLayoutItem::style const):
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.h:
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.cpp:
(WebCore::FlexFormattingUtils::flowAwareMarginStartForFlexItem const):
(WebCore::FlexFormattingUtils::flowAwareMarginEndForFlexItem const):
(WebCore::FlexFormattingUtils::flowAwareMarginBeforeForFlexItem const):
(WebCore::FlexFormattingUtils::maxMainSizeLengthForFlexItem const):
(WebCore::FlexFormattingUtils::minCrossSizeLengthForFlexItem const):
(WebCore::FlexFormattingUtils::maxCrossSizeLengthForFlexItem const):
(WebCore::FlexFormattingUtils::preferredAspectRatioForFlexItem const):
(WebCore::FlexFormattingUtils::flexItemHasComputableAspectRatio const):
(WebCore::FlexFormattingUtils::needToStretchFlexItemLogicalHeight const):
(WebCore::FlexFormattingUtils::marginBoxAscentForFlexItem const):
(WebCore::FlexFormattingUtils::crossAxisMarginExtentForFlexItem const):
(WebCore::FlexFormattingUtils::preferredMainSizeLengthForFlexItem const):
(WebCore::FlexFormattingUtils::minMainSizeLengthForFlexItem const):
(WebCore::FlexFormattingUtils::preferredCrossSizeLengthForFlexItem const):
(WebCore::FlexFormattingUtils::hasAutoMarginsInCrossAxis const):
(WebCore::FlexFormattingUtils::useContentBasedMinimumSize const):
(WebCore::FlexFormattingUtils::innerCrossSizeForFlexItem const):
(WebCore::FlexFormattingUtils::mainAxisIsFlexItemInlineAxis const):
(WebCore::FlexFormattingUtils::flexBasisForFlexItem const):
(WebCore::FlexFormattingUtils::alignmentForFlexItem const):
(WebCore::FlexFormattingUtils::hasDefiniteCrossSizeForFlexItem const):
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.h:
Canonical link: https://commits.webkit.org/317753@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications