Diff
Modified: trunk/Source/WebCore/ChangeLog (293292 => 293293)
--- trunk/Source/WebCore/ChangeLog 2022-04-23 17:36:17 UTC (rev 293292)
+++ trunk/Source/WebCore/ChangeLog 2022-04-23 20:25:12 UTC (rev 293293)
@@ -1,3 +1,27 @@
+2022-04-23 Alan Bujtas <za...@apple.com>
+
+ [FFC][Integration] Construct and update the layout tree for the flex items
+ https://bugs.webkit.org/show_bug.cgi?id=239684
+
+ Reviewed by Antti Koivisto.
+
+ This patch implements the usual flow of preparing a subtree for integration layout.
+
+ 1. Take the direct children of a RenderFlexibleBox (flex items) and construct Layout::ContainerBox objects.
+ 2. Run layout on the direct children (RenderBlocks) first and update the associated Layout::ContainerBoxes' geometries.
+ 3. Call LayoutIntegration::FlexLayout::layout (not yet implemented) to run flex layout on the flex items.
+
+ * layout/integration/LayoutIntegrationBoxTree.cpp:
+ (WebCore::LayoutIntegration::BoxTree::buildTreeForFlexContent):
+ * layout/integration/LayoutIntegrationBoxTree.h:
+ * layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
+ (WebCore::LayoutIntegration::FlexLayout::FlexLayout):
+ (WebCore::LayoutIntegration::FlexLayout::updateFlexItemDimensions):
+ * layout/integration/flex/LayoutIntegrationFlexLayout.h:
+ * rendering/RenderFlexibleBox.cpp:
+ (WebCore::RenderFlexibleBox::layoutUsingFlexFormattingContext):
+ * rendering/RenderFlexibleBox.h:
+
2022-04-23 Andres Gonzalez <andresg...@apple.com>
AX ITM: Table row objects should return a non-null unignored parent even when a table object is not found in its ancestry.
Modified: trunk/Source/WebCore/Headers.cmake (293292 => 293293)
--- trunk/Source/WebCore/Headers.cmake 2022-04-23 17:36:17 UTC (rev 293292)
+++ trunk/Source/WebCore/Headers.cmake 2022-04-23 20:25:12 UTC (rev 293293)
@@ -970,6 +970,7 @@
inspector/agents/InspectorPageAgent.h
+ layout/LayoutState.h
layout/LayoutUnits.h
layout/MarginTypes.h
@@ -976,6 +977,8 @@
layout/formattingContexts/inline/display/InlineDisplayBox.h
layout/formattingContexts/inline/InlineRect.h
+ layout/integration/LayoutIntegrationBoxTree.h
+
layout/integration/flex/LayoutIntegrationFlexLayout.h
layout/integration/inline/InlineIteratorBox.h
@@ -991,6 +994,7 @@
layout/layouttree/LayoutContainerBox.h
layout/layouttree/LayoutBox.h
+ layout/layouttree/LayoutInitialContainingBlock.h
loader/CanvasActivityRecord.h
loader/ContentFilterClient.h
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp (293292 => 293293)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2022-04-23 17:36:17 UTC (rev 293292)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2022-04-23 20:25:12 UTC (rev 293293)
@@ -37,6 +37,7 @@
#include "RenderBlockFlow.h"
#include "RenderChildIterator.h"
#include "RenderDetailsMarker.h"
+#include "RenderFlexibleBox.h"
#include "RenderImage.h"
#include "RenderLineBreak.h"
#include "RenderListItem.h"
@@ -87,6 +88,8 @@
if (is<RenderBlockFlow>(rootRenderer))
buildTreeForInlineContent();
+ else if (is<RenderFlexibleBox>(rootRenderer))
+ buildTreeForFlexContent();
else
ASSERT_NOT_IMPLEMENTED_YET();
}
@@ -173,6 +176,15 @@
}
}
+void BoxTree::buildTreeForFlexContent()
+{
+ for (auto& flexItemRenderer : childrenOfType<RenderObject>(m_rootRenderer)) {
+ auto style = RenderStyle::clone(flexItemRenderer.style());
+ auto flexItem = makeUnique<Layout::ContainerBox>(Layout::Box::ElementAttributes { Layout::Box::ElementType::IntegrationBlockContainer }, WTFMove(style));
+ appendChild(makeUniqueRefFromNonNullUniquePtr(WTFMove(flexItem)), flexItemRenderer);
+ }
+}
+
void BoxTree::appendChild(UniqueRef<Layout::Box> childBox, RenderObject& childRenderer)
{
auto& parentBox = downcast<Layout::ContainerBox>(layoutBoxForRenderer(*childRenderer.parent()));
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h (293292 => 293293)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h 2022-04-23 17:36:17 UTC (rev 293292)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h 2022-04-23 20:25:12 UTC (rev 293293)
@@ -71,6 +71,7 @@
private:
void buildTreeForInlineContent();
+ void buildTreeForFlexContent();
void appendChild(UniqueRef<Layout::Box>, RenderObject&);
RenderBlock& m_rootRenderer;
Modified: trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp (293292 => 293293)
--- trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp 2022-04-23 17:36:17 UTC (rev 293292)
+++ trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp 2022-04-23 20:25:12 UTC (rev 293293)
@@ -31,6 +31,7 @@
#include "HitTestLocation.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"
+#include "LayoutBoxGeometry.h"
#include "RenderFlexibleBox.h"
namespace WebCore {
@@ -38,6 +39,7 @@
FlexLayout::FlexLayout(RenderFlexibleBox& flexBoxRenderer)
: m_boxTree(flexBoxRenderer)
+ , m_layoutState(flexBoxRenderer.document(), m_boxTree.rootLayoutBox())
{
}
@@ -45,8 +47,16 @@
{
}
-void FlexLayout::updateFlexItemDimensions(const RenderBlock&)
+void FlexLayout::updateFlexItemDimensions(const RenderBlock& flexItem)
{
+ auto& boxGeometry = m_layoutState.ensureGeometryForBox(m_boxTree.layoutBoxForRenderer(flexItem));
+
+ boxGeometry.setContentBoxWidth(flexItem.contentWidth());
+ boxGeometry.setContentBoxHeight(flexItem.contentHeight());
+ boxGeometry.setVerticalMargin({ flexItem.marginTop(), flexItem.marginBottom() });
+ boxGeometry.setHorizontalMargin({ flexItem.marginLeft(), flexItem.marginRight() });
+ boxGeometry.setBorder({ { flexItem.borderLeft(), flexItem.borderRight() }, { flexItem.borderTop(), flexItem.borderBottom() } });
+ boxGeometry.setPadding(Layout::Edges { { flexItem.paddingLeft(), flexItem.paddingRight() }, { flexItem.paddingTop(), flexItem.paddingBottom() } });
}
void FlexLayout::updateStyle(const RenderBlock&, const RenderStyle&)
Modified: trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h (293292 => 293293)
--- trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h 2022-04-23 17:36:17 UTC (rev 293292)
+++ trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h 2022-04-23 20:25:12 UTC (rev 293293)
@@ -28,6 +28,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "LayoutIntegrationBoxTree.h"
+#include "LayoutState.h"
#include "RenderObjectEnums.h"
#include <wtf/CheckedPtr.h>
@@ -63,6 +64,7 @@
private:
BoxTree m_boxTree;
+ Layout::LayoutState m_layoutState;
};
}
Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (293292 => 293293)
--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2022-04-23 17:36:17 UTC (rev 293292)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2022-04-23 20:25:12 UTC (rev 293293)
@@ -2344,6 +2344,14 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
void RenderFlexibleBox::layoutUsingFlexFormattingContext()
{
+ if (!m_flexLayout)
+ m_flexLayout = makeUnique<LayoutIntegration::FlexLayout>(*this);
+
+ for (auto& flexItem : childrenOfType<RenderBlock>(*this)) {
+ flexItem.layoutIfNeeded();
+ m_flexLayout->updateFlexItemDimensions(flexItem);
+ }
+ m_flexLayout->layout();
}
#endif
Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.h (293292 => 293293)
--- trunk/Source/WebCore/rendering/RenderFlexibleBox.h 2022-04-23 17:36:17 UTC (rev 293292)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.h 2022-04-23 20:25:12 UTC (rev 293293)
@@ -30,6 +30,7 @@
#pragma once
+#include "LayoutIntegrationFlexLayout.h"
#include "OrderIterator.h"
#include "RenderBlock.h"
@@ -234,6 +235,9 @@
SizeDefiniteness m_hasDefiniteHeight { SizeDefiniteness::Unknown };
bool m_inLayout { false };
bool m_shouldResetChildLogicalHeightBeforeLayout { false };
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ std::unique_ptr<LayoutIntegration::FlexLayout> m_flexLayout;
+#endif
};
} // namespace WebCore