Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 182d57a142ef5cfd81780b6fa836de8ade7e2a2e
      
https://github.com/WebKit/WebKit/commit/182d57a142ef5cfd81780b6fa836de8ade7e2a2e
  Author: Alan Baradlay <[email protected]>
  Date:   2026-07-28 (Tue, 28 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.h

  Log Message:
  -----------
  [cleanup] Have the flex algorithm place items in flow-relative coordinates
https://bugs.webkit.org/show_bug.cgi?id=320388

Reviewed by Antti Koivisto.

placeFlexItems walked each line forwards accumulating a main-axis offset, then 
mirrored that offset about
the container's main extent for a reversed row before recording it. So its 
output was partly logical and
partly physical, and the two cross-axis flips it does
not know about -- wrap-reverse and rtl-column --
were applied afterwards in computeFlexItemRects.

Move the main-axis flip there too. placeFlexItems now emits flow-relative 
offsets only, and
computeFlexItemRects is the single logical-to-physical conversion, resolving 
every reversed direction in
one place against extents that are final by the time it runs.

Column flow keeps reversing in layoutColumnReverse, and the flip here stays 
row-only. Two things stand in
the way of folding it in: the container's block axis is the column's main axis, 
so its extent is not
settled until the items have been placed and the flip has nothing to pivot on; 
and isLeftToRightFlow is
already false for a column whose block axis runs backwards (vertical-rl), a 
reversal the flow-aware
border, padding and margin accessors consume rather than a position flip. 
Turning the flip on for columns
therefore double-counts the writing mode, and folding flex-direction into 
isLeftToRightFlow swaps column
with
column-reverse instead of reversing either.

placeFlexItems and layoutColumnReverse keep writing the item's position, even 
though computeFlexItemRects
walks every line and writes each item again. The value is read in between: 
cross-axis stretching lays the
item out once more, and content inside it can read its position back off the 
renderer -- an outside list
marker offsets itself by the flex item's logical left in
BoxGeometryUpdater::setListMarkerOffsetForMarkerOutside. So the item needs a 
main-axis position by then, and
the row flip that produces it moves into a helper both callers share.

While here, have FlexFormattingContext keep the FlexLayoutState reference it is 
constructed with rather
than reading it back out of FlexIntegrationUtils, which it had handed the same 
reference to. That was the
last caller of FlexIntegrationUtils::flexLayoutState(), so it becomes private, 
and flexBox() turns out to
have no callers outside the class either.

No change in
behaviour.

* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::FlexFormattingContext::FlexFormattingContext):
(WebCore::FlexFormattingContext::layoutState):
(WebCore::FlexFormattingContext::computeFlexItemRects):
(WebCore::FlexFormattingContext::placeFlexItems):
(WebCore::FlexFormattingContext::layoutColumnReverse):
(WebCore::FlexFormattingContext::mainAxisFlippedOffsetForRow const):
(WebCore::FlexFormattingContext::layoutState const):
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.h:
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.h:

Canonical link: 
https://flagged.apple.com:443/proxy?t2=Do7m8X6sU3&o=aHR0cHM6Ly9jb21taXRzLndlYmtpdC5vcmcvMzE4MDY1QG1haW4=&emid=1d1b2ef2-6fb3-4c63-89ac-9d5e5db88682&c=11



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

Reply via email to