Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 031302ad94939281fb77388ab8ab7d8bbc367abf
      
https://github.com/WebKit/WebKit/commit/031302ad94939281fb77388ab8ab7d8bbc367abf
  Author: Alan Baradlay <[email protected]>
  Date:   2026-10-10 (Sat, 10 Oct 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
    M Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp
    M Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp
    M Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h

  Log Message:
  -----------
  [cleanup] Merge duplicated helpers in the flex formatting context
https://bugs.webkit.org/show_bug.cgi?id=327091
<rdar://problem/189705436>

Reviewed by Antti Koivisto.

1. Add FlexLayoutItem::outerMainSize, replacing 
hypotheticalMainAxisMarginBoxSize, flexedMarginBoxSize, a lambda in
   resolveFlexibleLengthsForLineItems and an inline sum in 
handleMainAxisAlignment, which all added main-axis border,
   padding and margin.
2. Add remainingFreeSpaceForLine for the free-space loop that 
handleMainAxisAlignment and
   distributeMainAxisFreeSpaceForMultilineColumnIfNeeded wrote three times; the 
latter's outer-size sum >= available
   space test becomes remaining free space <= 0.
3. Merge mainAxisAvailableSpaceForItemAlignment and 
crossAxisAvailableSpaceForLineSizingAndAlignment into
   availableSpaceExcludingGaps; they differed only in gap type, and with one 
item or line the general formula already
   subtracts nothing.
4. Use constrainSizeByMinMax in computeFlexBaseAndHypotheticalMainSizes instead 
of repeating its expression.
5. Rename initialAlignContentOffset to initialContentAlignmentOffset and make 
initialJustifyContentOffset call it
   after resolving left and right; it keeps justify's zero-item case, which 
out-of-flow static positions use.
6. Have resolveLeftRightAlignment read the position from the 
StyleContentAlignmentData it is given; both callers
   passed that data's own position separately.
7. Add isStretchedFlexItem for the align-self: stretch, auto cross size, no 
auto cross-axis margin check that
   hasStretchedFlexItemWithAspectRatio and hasDefiniteCrossSizeForFlexItem each 
spelled out.
8. Move the code firstLineBaseline and lastLineBaseline duplicated into 
FlexLayout::baselineFromFlexItem; the two now
   only pick the item and pass ItemPosition::Baseline or 
ItemPosition::LastBaseline.
9. Read the cached FlexLayoutItem::mainAxisIsInlineAxis instead of recomputing 
it in performBaselineAlignment,
   preferredAspectRatioForFlexItem, marginBoxAscentForFlexItem and 
layoutFlexItemWithMainSize, and remove the
   FlexLayoutItem overload of mainAxisIsFlexItemInlineAxis.
10. Merge computeMainSizeFromAspectRatioUsing's intrinsic aspect ratio and 
content-box branches, which computed the
    same content-box main size.

No change in behavior.

* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::FlexFormattingContext::computeFlexBaseAndHypotheticalMainSizes):
(WebCore::FlexFormattingContext::computeFlexLines):
(WebCore::FlexFormattingContext::resolveFlexibleLengthsForLineItems):
(WebCore::FlexFormattingContext::availableSpaceExcludingGaps const):
(WebCore::FlexFormattingContext::remainingFreeSpaceForLine const):
(WebCore::FlexFormattingContext::distributeMainAxisFreeSpaceForMultilineColumnIfNeeded):
(WebCore::FlexFormattingContext::handleMainAxisAlignment):
(WebCore::FlexFormattingContext::handleCrossAxisAlignmentForFlexLines):
(WebCore::FlexFormattingContext::performBaselineAlignment):
(WebCore::FlexFormattingContext::placeFlexItems):
(WebCore::FlexFormattingContext::computeMainSizeFromAspectRatioUsing const):
(WebCore::FlexLayoutItem::outerMainSize const):
(WebCore::FlexFormattingContext::mainAxisAvailableSpaceForItemAlignment const): 
Deleted.
(WebCore::FlexFormattingContext::crossAxisAvailableSpaceForLineSizingAndAlignment
 const): Deleted.
(WebCore::FlexLayoutItem::hypotheticalMainAxisMarginBoxSize const): Deleted.
(WebCore::FlexLayoutItem::flexedMarginBoxSize const): Deleted.
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.h:
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.cpp:
(WebCore::FlexFormattingUtils::isStretchedFlexItem):
(WebCore::FlexFormattingUtils::hasStretchedFlexItemWithAspectRatio):
(WebCore::FlexFormattingUtils::preferredAspectRatioForFlexItem const):
(WebCore::FlexFormattingUtils::marginBoxAscentForFlexItem const):
(WebCore::FlexFormattingUtils::hasDefiniteCrossSizeForFlexItem):
(WebCore::FlexFormattingUtils::resolveLeftRightAlignment):
(WebCore::FlexFormattingUtils::initialJustifyContentOffset):
(WebCore::FlexFormattingUtils::initialContentAlignmentOffset):
(WebCore::FlexFormattingUtils::initialAlignContentOffset): Deleted.
(WebCore::FlexFormattingUtils::mainAxisIsFlexItemInlineAxis const): Deleted.
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.h:
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp:
(WebCore::LayoutIntegration::FlexIntegrationUtils::layoutFlexItemWithMainSize):
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
(WebCore::LayoutIntegration::FlexLayout::firstLineBaseline const):
(WebCore::LayoutIntegration::FlexLayout::lastLineBaseline const):
(WebCore::LayoutIntegration::FlexLayout::baselineFromFlexItem const):
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h:

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



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

Reply via email to