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

  Changed paths:
    M Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp
    M Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h

  Log Message:
  -----------
  [cleanup] Simplify flex baseline item selection to a single per-line scan
https://bugs.webkit.org/show_bug.cgi?id=319896

Reviewed by Antti Koivisto.

A flex container's first/last baseline comes from a single baseline flex item: 
the item
nearest the visual start of the visually-first flex line (first baseline) or 
the visual end
of the visually-last line (last baseline). "Which end" is decided by two 
orthogonal CSS
flips: flex-wrap: wrap-reverse flips which line is visually first, and 
flex-direction:
*-reverse flips which item within a line is visually first.

Selecting that item used a 2x2x2 matrix: flexItemForFirstBaseline / 
flexItemForLastBaseline
each branched on wrap-reverse and direction-reverse and dispatched to one of 
two helpers
(firstBaselineCandidateOnLine / lastBaselineCandidateOnLine), which walked the 
whole flat
child stream from the front or back and counted numberOfItemsOn{First,Last}Line 
to reach a
line. That contortion was a leftover from the order iterator, which had no 
notion of flex
lines.

Now that RenderFlexibleBox exposes its flex items as an ordered list (bug 
319866), a flex
line is just a contiguous slice of it: [0, firstCount) or [size - lastCount, 
size). So the
whole thing collapses to one helper, baselineFlexItemInLine(lineStart, 
itemCount, reverse),
which scans that slice in the given direction and returns the first item 
participating in
baseline alignment (baseline self-alignment, main axis is the item's inline 
axis, no auto
cross-axis margins), or the first item scanned when none participate. 
firstBaseline picks
its line via wrap-reverse and scans reversed for a reversed main axis; 
lastBaseline picks
the opposite line and scans the opposite direction.

No new tests: no behavior change (the single helper reproduces the two old 
helpers, which
differed only in scan direction, and all eight wrap-reverse x direction-reverse 
x first/last
combinations map to the same line slice and scan direction).

* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h:
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
(WebCore::LayoutIntegration::FlexLayout::flexItemForFirstBaseline):
(WebCore::LayoutIntegration::FlexLayout::flexItemForLastBaseline):
(WebCore::LayoutIntegration::FlexLayout::baselineFlexItemInLine):
(WebCore::LayoutIntegration::FlexLayout::firstBaselineCandidateOnLine): Deleted.
(WebCore::LayoutIntegration::FlexLayout::lastBaselineCandidateOnLine): Deleted.

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



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

Reply via email to