Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: c6051ef7a0eaadf86ce7cfbf026e8f4843dd6256
https://github.com/WebKit/WebKit/commit/c6051ef7a0eaadf86ce7cfbf026e8f4843dd6256
Author: Alan Baradlay <[email protected]>
Date: 2026-07-25 (Sat, 25 Jul 2026)
Changed paths:
M Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp
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/LayoutIntegrationFlexLayout.cpp
Log Message:
-----------
[cleanup] Stop FlexFormattingContext from reading flex-item margins and
border/padding off the renderer
https://bugs.webkit.org/show_bug.cgi?id=320283
Reviewed by Antti Koivisto.
A few flex-item reads were left in FlexFormattingContext, all going straight to
the renderer for
values the formatting context either already has or can get through the utils.
computeFlexBaseAndHypotheticalMainSizes re-reads an orthogonal item's main-axis
margin after
flexBaseSizeForFlexItem has laid the item out (the item's block-direction
margins are only resolved
at that point), duplicating the horizontal/verticalMarginExtent selection that
FlexFormattingUtils
already does. That helper had two behaviours behind one name though: for a
clean item it returned
the resolved physical extent, but for a dirty one it recomputed the margins in
the container's
inline/block directions, which only line up with the main/cross axes in a
horizontal writing mode.
Split it in two -- usedMainAxisMarginExtentForFlexItem returns what layout
resolved, and
resolveMainAxisMarginExtentForFlexItem resolves first for the one caller that
needs that,
staticMainAxisPositionForPositionedFlexItem, which computes an out-of-flow
item's static position
outside of flex layout. computeFlexBaseAndHypotheticalMainSizes wants the
former.
removeMarginEndFromFlexSizes computes the item's main-axis end margin to
subtract it from the
running flex base and hypothetical main sizes -- the same value that
FlexIntegrationUtils::trimMainAxisMarginEnd subtracts from the item's cached
mainAxisMargin, and the
two are always called together. Add
FlexFormattingUtils::mainAxisMarginEndForFlexItem (a static form
taking the container, plus the usual instance overload, matching
crossAxisMarginExtentForFlexItem)
and have both call sites use it.
computeMainSizeFromAspectRatioUsing recomputes the item's main-axis
border/padding from the renderer
even though FlexLayoutItem already caches it (with the same expression), and
the same function
already uses the cached cross-axis value a few lines up. Unlike margins,
border/padding is not
resolved during layout, so this is simply a duplicate read: use the cached
FlexLayoutItem::mainAxisBorderAndPadding instead.
With this the formatting context reaches a flex item's renderer only through
the FlexLayoutItem
constructor's one-time snapshot, cheap getters and asserts.
No change in behavior.
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::FlexFormattingContext::computeFlexBaseAndHypotheticalMainSizes):
(WebCore::FlexFormattingContext::computeMainSizeFromAspectRatioUsing):
(WebCore::FlexFormattingContext::removeMarginEndFromFlexSizes):
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.h:
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.cpp:
(WebCore::FlexFormattingUtils::resolveMainAxisMarginExtentForFlexItem):
(WebCore::FlexFormattingUtils::usedMainAxisMarginExtentForFlexItem):
(WebCore::FlexFormattingUtils::mainAxisMarginEndForFlexItem):
(WebCore::FlexFormattingUtils::mainAxisMarginExtentForFlexItem): Deleted.
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp:
(WebCore::LayoutIntegration::FlexIntegrationUtils::trimMainAxisMarginEnd):
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
(WebCore::LayoutIntegration::FlexLayout::staticMainAxisPositionForPositionedFlexItem):
Canonical link: https://commits.webkit.org/317929@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications