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

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

  Log Message:
  -----------
  [cleanup] Snapshot the flex item main-axis margin on FlexLayoutItem instead 
of a parallel array
https://bugs.webkit.org/show_bug.cgi?id=318599

Reviewed by Antti Koivisto.

performFlexLayout kept each flex item's main-axis margin extent in a parallel 
array
(marginsList) computed up front and threaded through the main-size pipeline. 
Snapshot it
onto FlexLayoutItem instead, as the first of the geometry the core reads off 
the renderer.

FlexLayoutItem gains a mainAxisMargin field, populated in collectFlexItems from 
the flow-aware
margin extent right after the item's flexBaseAndHypotheticalMainSize is 
computed. That timing
matters: an orthogonal flex item only resolves its physical margins when it is 
laid out for its
flex base size, so the snapshot has to happen after that layout -- reading the 
margin at
FlexLayoutItem construction would capture stale, pre-layout values and throw 
off margin-trim.
This is the same point the old marginsList was filled (after collectFlexItems 
returned). The
field is mutable because margin-trim reduces it during line collection, so
trimMainAxisMarginStart/End now take a FlexLayoutItem& and adjust the field. 
The margin-box
helpers (flexBaseMarginBoxSize, hypotheticalMainAxisMarginBoxSize, 
flexedMarginBoxSize) and
canFitItemWithTrimmedMarginEnd read the field, and the marginsList array plus 
the margin
parameter to computeFlexLines, computeMainSizeForFlexItems, 
resolveFlexibleLengthsForLineItems,
handleMainAxisAlignment, and 
distributeMainAxisFreeSpaceForMultilineColumnIfNeeded are gone.

No change in behavior: the margin is computed the same way, snapshotted at the 
same point, and
follows the same trim. Covered by existing tests (e.g.
imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-row-orthogonal-item.html).

* Source/WebCore/rendering/RenderFlexibleBox.cpp:
* Source/WebCore/rendering/RenderFlexibleBox.h:

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



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

Reply via email to