Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 000ed9be50923e8a72fc9f71f1682cdc2b528af9
      
https://github.com/WebKit/WebKit/commit/000ed9be50923e8a72fc9f71f1682cdc2b528af9
  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

  Log Message:
  -----------
  [cleanup] Remove the column-reverse placement pass from the flex algorithm
https://bugs.webkit.org/show_bug.cgi?id=320394

Reviewed by Antti Koivisto.

layoutColumnReverse walked each line a second time after placeFlexItems had 
already placed it,
subtracting where the first walk added, to lay the items out from the 
container's main-axis end. Two
placement functions had to stay in step, and column-reverse was the last 
flex-direction reversal the
algorithm resolved while laying out rather than at the 
flow-relative-to-physical conversion.

computeFlexItemRects can flip the positions instead, now that it runs after the 
container's block extent
is final -- which is what the second pass was waiting for. It flips the item's 
*margin* box and steps back
over its leading margin: the two walks consume marginStart and marginEnd in 
opposite orders, so flipping
the border box only lines up if those two swap, while the margin box is 
symmetric under reversal by
construction.

The edge to flip about is the container's main border-box extent, less the 
main-axis scrollbar, adjusted
by the difference between the flow-aware start and end border+padding -- the 
same quantities the removed
walk started from.

Note this flip keys off flex-direction alone and leaves isLeftToRightFlow 
untouched. For a column the
writing mode's own reversal is already accounted for twice over: 
isLeftToRightFlow moves the flow-aware
start edge, and the renderer flips the position in 
RenderBox::flipForWritingMode, since RenderBox::location
is stored in flipped-blocks coordinates. Folding flex-direction into 
isLeftToRightFlow would reverse a
vertical-rl column twice and leave vertical-rl column-reverse unreversed.

With this, every reversed direction -- row-reverse, RTL rows, column-reverse, 
wrap-reverse and rtl-column
-- is resolved in computeFlexItemRects, and the algorithm above it lays every 
line out forwards.

No change in behaviour.

* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::FlexFormattingContext::layout):
(WebCore::FlexFormattingContext::computeFlexItemRects):
(WebCore::FlexFormattingContext::reverseColumnLinesFromContainerMainEndIfNeeded):
 Deleted.
(WebCore::FlexFormattingContext::layoutColumnReverse): Deleted.
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.h:

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



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

Reply via email to