Title: [295081] trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp
Revision
295081
Author
za...@apple.com
Date
2022-05-31 22:27:39 -0700 (Tue, 31 May 2022)

Log Message

DOM order may not be sufficient when constructing the LogicalFlexItemList
https://bugs.webkit.org/show_bug.cgi?id=241166

Reviewed by Antti Koivisto.

We need to hold on to a reference to the layout box in case logical order != DOM order.

* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::Layout::FlexFormattingContext::convertFlexItemsToLogicalSpace):

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp (295080 => 295081)


--- trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp	2022-06-01 05:00:40 UTC (rev 295080)
+++ trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp	2022-06-01 05:27:39 UTC (rev 295081)
@@ -152,6 +152,7 @@
     struct FlexItem {
         FlexRect marginRect;
         int logicalOrder { 0 };
+        CheckedPtr<const ContainerBox> layoutBox;
     };
 
     auto& formattingState = this->formattingState();
@@ -201,7 +202,7 @@
             flexItemsNeedReordering = flexItemsNeedReordering || flexItemOrder != previousLogicalOrder.value_or(0);
             previousLogicalOrder = flexItemOrder;
 
-            flexItemList.append({ { logicalSize }, flexItemOrder });
+            flexItemList.append({ { logicalSize }, flexItemOrder, downcast<ContainerBox>(flexItem) });
         }
     };
     convertVisualToLogical();
@@ -217,11 +218,8 @@
     reorderFlexItemsIfApplicable();
 
     auto logicalFlexItemList = FlexLayout::LogicalFlexItems(flexItemList.size());
-    auto* layoutBox = root().firstInFlowChild();
-    for (size_t index = 0; index < flexItemList.size(); ++index) {
-        logicalFlexItemList[index] = { flexItemList[index].marginRect, downcast<ContainerBox>(layoutBox) };
-        layoutBox = layoutBox->nextInFlowSibling();
-    }
+    for (size_t index = 0; index < flexItemList.size(); ++index)
+        logicalFlexItemList[index] = { flexItemList[index].marginRect, flexItemList[index].layoutBox };
     return logicalFlexItemList;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to