Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ca48ed48ca69cb0783146155be73b09906cedd41
      
https://github.com/WebKit/WebKit/commit/ca48ed48ca69cb0783146155be73b09906cedd41
  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/FlexFormattingContext.h
    M Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp
    M Source/WebCore/layout/integration/flex/FlexIntegrationUtils.h

  Log Message:
  -----------
  [cleanup] Move the flex item's remaining margin, min/max and size operations 
into FlexIntegrationUtils
https://bugs.webkit.org/show_bug.cgi?id=320252

Reviewed by Antti Koivisto.

FlexFormattingContext still made a number of non-trivial calls directly on the 
flex item's renderer
-- margin trimming, auto-margin resolution, min/max constraining, and 
percentage-height /
logical-size computation. Move them behind FlexIntegrationUtils so the 
formatting context reaches
the flex item's renderer only through cheap getters.

Moved to FlexIntegrationUtils (each takes a FlexLayoutItem and derives the 
container's flow /
writing mode from flexBox() rather than from the formatting context's 
constraints):

- updateAutoMarginsInMainAxis / updateAutoMarginsInCrossAxis (renderer margin 
mutations).
- trimMainAxisMarginStart / trimMainAxisMarginEnd / trimCrossAxisMarginStart / 
trimCrossAxisMarginEnd.
- constrainFlexItemLogicalHeightByMinMax / 
constrainFlexItemLogicalWidthByMinMax (the width helper
  supplies flexBox() as the containing block).
- computePercentageLogicalHeightForFlexItem, 
computeLogicalHeightUsingForFlexItem and
  computeLogicalWidthUsingForFlexItem (templated, with explicit instantiations 
for the size types
  the formatting context resolves).

The formatting context keeps the flex-algorithm decisions: it still gates 
margin trimming on
FlexFormattingUtils::shouldTrim*, and computes the stretch / 
cross-size-definiteness booleans it
passes into the intrinsic-size helpers.

Drive-by cleanup in the same functions: dropped the redundant 
out-of-flow-positioned ASSERTs and
the CheckedRef renderer locals that existed only to feed the moved calls, and 
converted the
isRenderTable() / isRenderReplaced() virtual checks to is<RenderTable> / 
is<RenderReplaced> (adding
the corresponding includes).

No change in behavior.

* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::FlexFormattingContext::computeFlexLines):
(WebCore::FlexFormattingContext::trimCrossAxisMarginsForFlexItems):
(WebCore::FlexFormattingContext::handleCrossAxisAlignmentForFlexItems):
(WebCore::FlexFormattingContext::performBaselineAlignment):
(WebCore::FlexFormattingContext::placeFlexItems):
(WebCore::FlexFormattingContext::computeContentBasedMinMainSize):
(WebCore::FlexFormattingContext::computeMainSizeFromAspectRatioUsing):
(WebCore::FlexFormattingContext::computeUsedNonAutoMinMainSize):
(WebCore::FlexFormattingContext::flexItemCrossSizeIsDefinite):
(WebCore::FlexFormattingContext::applyStretchAlignmentToFlexItem):
(WebCore::FlexFormattingContext::applyStretchMinMaxCrossSize):
(WebCore::FlexFormattingContext::updateAutoMarginsInMainAxis): Deleted.
(WebCore::FlexFormattingContext::updateAutoMarginsInCrossAxis): Deleted.
(WebCore::FlexFormattingContext::trimMainAxisMarginStart): Deleted.
(WebCore::FlexFormattingContext::trimMainAxisMarginEnd): Deleted.
(WebCore::FlexFormattingContext::trimCrossAxisMarginStart): Deleted.
(WebCore::FlexFormattingContext::trimCrossAxisMarginEnd): Deleted.
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.h:
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp:
(WebCore::LayoutIntegration::FlexIntegrationUtils::updateAutoMarginsInMainAxis):
(WebCore::LayoutIntegration::FlexIntegrationUtils::updateAutoMarginsInCrossAxis):
(WebCore::LayoutIntegration::FlexIntegrationUtils::trimMainAxisMarginStart):
(WebCore::LayoutIntegration::FlexIntegrationUtils::trimMainAxisMarginEnd):
(WebCore::LayoutIntegration::FlexIntegrationUtils::trimCrossAxisMarginStart):
(WebCore::LayoutIntegration::FlexIntegrationUtils::trimCrossAxisMarginEnd):
(WebCore::LayoutIntegration::FlexIntegrationUtils::constrainFlexItemLogicalHeightByMinMax):
(WebCore::LayoutIntegration::FlexIntegrationUtils::constrainFlexItemLogicalWidthByMinMax):
(WebCore::LayoutIntegration::FlexIntegrationUtils::computePercentageLogicalHeightForFlexItem):
(WebCore::LayoutIntegration::FlexIntegrationUtils::computeLogicalHeightUsingForFlexItem):
(WebCore::LayoutIntegration::FlexIntegrationUtils::computeLogicalWidthUsingForFlexItem):
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.h:

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



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

Reply via email to