Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f1a2d7ccc011b8da238839e6e66172d50f283e4f
      
https://github.com/WebKit/WebKit/commit/f1a2d7ccc011b8da238839e6e66172d50f283e4f
  Author: Alan Baradlay <[email protected]>
  Date:   2026-07-11 (Sat, 11 Jul 2026)

  Changed paths:
    M Source/WebCore/rendering/RenderFlexibleBox.cpp
    M Source/WebCore/rendering/RenderFlexibleBox.h

  Log Message:
  -----------
  [cleanup] Store each flex item's main-axis margin in a list instead of on 
FlexLayoutItem
https://bugs.webkit.org/show_bug.cgi?id=318514

Reviewed by Antti Koivisto.

The last mutable field on FlexLayoutItem was mainAxisMargin: seeded from the
renderer's margin extent and then trimmed in place by margin-trim during line
collection. FlexLayout::layout keeps margins in a parallel list and leaves
LogicalFlexItem immutable. Match that: performFlexLayout owns a 
Vector<LayoutUnit>
marginsList (seeded right after collectFlexItems from the same 
horizontal/vertical
margin extent the ctor used), and LineState carries a std::span<const 
LayoutUnit>
margins slice of it, symmetric with the mainSizes and positions spans.

computeFlexLines/computeNextFlexLine take the list and trim marginsList[index] 
in
place (trimMainAxisMarginStart/End now take a LayoutUnit& slot); the three
*MarginBoxSize helpers take the margin as an argument (like flexedMarginBoxSize
took the main size); canFitItemWithTrimmedMarginEnd takes it too;
resolveFlexibleLengthsForLineItems reads a per-line margins span;
handleMainAxisAlignment reads marginsList by index. 
FlexLayoutItem::mainAxisMargin
is gone, so the item is now a pure immutable input.

Behavior is unchanged: the initial margin, the trim subtraction, and every read
are the same values in the same order, only in the list rather than the item;
the trim still happens during collection before the sizing reads, and 
marginsList
lives for the whole layout and is never resized after the line slices are taken.

* Source/WebCore/rendering/RenderFlexibleBox.h:
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::FlexLayoutItem::FlexLayoutItem):
(WebCore::RenderFlexibleBox::FlexLayoutItem::hypotheticalMainAxisMarginBoxSize):
(WebCore::RenderFlexibleBox::FlexLayoutItem::flexBaseMarginBoxSize):
(WebCore::RenderFlexibleBox::FlexLayoutItem::flexedMarginBoxSize):
(WebCore::RenderFlexibleBox::LineState::LineState):
(WebCore::RenderFlexibleBox::resolveFlexibleLengthsForLineItems):
(WebCore::RenderFlexibleBox::distributeMainAxisFreeSpaceForMultilineColumnIfNeeded):
(WebCore::RenderFlexibleBox::canFitItemWithTrimmedMarginEnd):
(WebCore::RenderFlexibleBox::trimMainAxisMarginStart):
(WebCore::RenderFlexibleBox::trimMainAxisMarginEnd):
(WebCore::RenderFlexibleBox::performFlexLayout):
(WebCore::RenderFlexibleBox::computeFlexLines):
(WebCore::RenderFlexibleBox::computeMainSizeForFlexItems):
(WebCore::RenderFlexibleBox::handleMainAxisAlignment):
(WebCore::RenderFlexibleBox::computeNextFlexLine):

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



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

Reply via email to