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

  Changed paths:
    M Source/WebCore/inspector/InspectorOverlay.cpp
    M Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp
    M Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h
    M Source/WebCore/rendering/RenderFlexibleBox.cpp
    M Source/WebCore/rendering/RenderFlexibleBox.h

  Log Message:
  -----------
  [Flexbox] Replace RenderFlexibleBox's OrderIterator with an ordered flex item 
list built once per layout
https://bugs.webkit.org/show_bug.cgi?id=319866

Reviewed by Antti Koivisto.

RenderFlexibleBox reached its children through an OrderIterator: a stateful 
iterator
that re-walked the container's live children (sorted by the used 'order' value) 
on
demand, every time paint, hit-testing, the flex formatting context, or a 
baseline
query needed them. Reversed traversal was expressed by walking the child stream 
from
the back, which had no notion of flex lines.

Replace it with a list built once per layout: a 
Vector<SingleThreadWeakPtr<RenderBox>>
of the container's in-flow flex items in order-modified document order (a 
stable sort by
the used 'order' value, so document order breaks ties), rebuilt in
prepareFlexItemsAndMargins (renamed from prepareOrderIteratorAndMargins). The 
pointers
are weak because painting/hit-testing/baseline queries read the list after 
layout, when
a child may have been removed; out-of-flow and excluded children are not flex 
items and
are left out, so the shared shouldSkipChild predicate is applied once, at build 
time,
rather than by every consumer.

All consumers now read this list: paintChildren, hitTestChildren (iterating the 
list in
reverse instead of building an ad-hoc reversed Vector), 
appendFlexItemBorderBoxRects,
repaintFlexItemsDuringLayoutIfMoved, the integration's collectFlexItems and 
baseline
candidate selection, and InspectorOverlay. Out-of-flow static-position 
preparation, which
used to piggyback on the iterator walk, moves to its own document-order child 
walk in
collectFlexItems (it does not depend on flex order). OrderIterator itself is 
unchanged and
still used by RenderGrid.

No new tests: no intended behavior change (the list reproduces the iterator's
order-modified document order, and reversed iteration is the list reversed).

* Source/WebCore/rendering/RenderFlexibleBox.h:
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::shouldSkipChild):
(WebCore::RenderFlexibleBox::hitTestChildren):
(WebCore::RenderFlexibleBox::paintChildren):
(WebCore::RenderFlexibleBox::appendFlexItemBorderBoxRects):
(WebCore::RenderFlexibleBox::repaintFlexItemsDuringLayoutIfMoved):
(WebCore::RenderFlexibleBox::prepareFlexItemsAndMargins):
(WebCore::RenderFlexibleBox::layoutBlock):
(WebCore::RenderFlexibleBox::prepareOrderIteratorAndMargins): Deleted.
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h:
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
(WebCore::LayoutIntegration::FlexLayout::collectFlexItems):
(WebCore::LayoutIntegration::FlexLayout::firstBaselineCandidateOnLine):
(WebCore::LayoutIntegration::FlexLayout::lastBaselineCandidateOnLine):
(WebCore::LayoutIntegration::FlexLayout::flexItemForFirstBaseline const):
(WebCore::LayoutIntegration::FlexLayout::flexItemForLastBaseline const):
(WebCore::LayoutIntegration::FlexLayout::firstBaselineCandidateOnLine const):
(WebCore::LayoutIntegration::FlexLayout::lastBaselineCandidateOnLine const):
* Source/WebCore/inspector/InspectorOverlay.cpp:
(WebCore::rendererIsFlexboxItem):
(WebCore::InspectorOverlay::buildFlexOverlay):

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



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

Reply via email to