diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp index 4f14165d7e9..a7d15773fc6 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp @@ -558,7 +558,6 @@ bool layoutAbsoluteDescendants( // we need to mutate these descendents. Make sure the path of // nodes to them is mutable before positioning. child->cloneChildrenIfNeeded(); - cleanupContentsNodesRecursively(child); const Direction childDirection = child->resolveDirection(currentNodeDirection); // By now all descendants of the containing block that are not absolute @@ -584,6 +583,8 @@ bool layoutAbsoluteDescendants( containingNodeAvailableInnerHeight) || hasNewLayout; + cleanupContentsNodesRecursively( + child, /* didPerformLayout */ hasNewLayout); if (hasNewLayout) { child->setHasNewLayout(hasNewLayout); } diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp index 6c90ddce39c..e45a779f875 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp @@ -506,7 +506,9 @@ void zeroOutLayoutRecursively(yoga::Node* const node) { } } -void cleanupContentsNodesRecursively(yoga::Node* const node) { +void cleanupContentsNodesRecursively( + yoga::Node* const node, + bool didPerformLayout) { if (node->hasContentsChildren()) [[unlikely]] { node->cloneContentsChildrenIfNeeded(); for (auto child : node->getChildren()) { @@ -514,11 +516,13 @@ void cleanupContentsNodesRecursively(yoga::Node* const node) { child->getLayout() = {}; child->setLayoutDimension(0, Dimension::Width); child->setLayoutDimension(0, Dimension::Height); - child->setHasNewLayout(true); + if (didPerformLayout) { + child->setHasNewLayout(true); + } child->setDirty(false); child->cloneChildrenIfNeeded(); - cleanupContentsNodesRecursively(child); + cleanupContentsNodesRecursively(child, didPerformLayout); } } } @@ -1360,7 +1364,7 @@ static void calculateLayoutImpl( // Clean and update all display: contents nodes with a direct path to the // current node as they will not be traversed - cleanupContentsNodesRecursively(node); + cleanupContentsNodesRecursively(node, performLayout); return; } @@ -1378,7 +1382,7 @@ static void calculateLayoutImpl( // Clean and update all display: contents nodes with a direct path to the // current node as they will not be traversed - cleanupContentsNodesRecursively(node); + cleanupContentsNodesRecursively(node, performLayout); return; } @@ -1396,7 +1400,7 @@ static void calculateLayoutImpl( ownerHeight)) { // Clean and update all display: contents nodes with a direct path to the // current node as they will not be traversed - cleanupContentsNodesRecursively(node); + cleanupContentsNodesRecursively(node, /* didPerformLayout */ false); return; } @@ -1408,7 +1412,7 @@ static void calculateLayoutImpl( // Clean and update all display: contents nodes with a direct path to the // current node as they will not be traversed - cleanupContentsNodesRecursively(node); + cleanupContentsNodesRecursively(node, performLayout); // STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM const FlexDirection mainAxis = diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.h b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.h index 2314bce0e46..0cc7c678949 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.h +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.h @@ -55,6 +55,6 @@ float calculateAvailableInnerDimension( void zeroOutLayoutRecursively(yoga::Node* const node); -void cleanupContentsNodesRecursively(yoga::Node* const node); +void cleanupContentsNodesRecursively(yoga::Node* node, bool didPerformLayout); } // namespace facebook::yoga diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api index 46bf19be661..eef950f0131 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api @@ -12822,7 +12822,7 @@ void facebook::yoga::assertFatal(bool condition, const char* message); void facebook::yoga::assertFatalWithConfig(const facebook::yoga::Config* config, bool condition, const char* message); void facebook::yoga::assertFatalWithNode(const facebook::yoga::Node* node, bool condition, const char* message); void facebook::yoga::calculateLayout(facebook::yoga::Node* node, float ownerWidth, float ownerHeight, facebook::yoga::Direction ownerDirection); -void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node *const node); +void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node* node, bool didPerformLayout); void facebook::yoga::constrainMaxSizeForMode(const facebook::yoga::Node* node, facebook::yoga::Direction direction, facebook::yoga::FlexDirection axis, float ownerAxisSize, float ownerWidth, facebook::yoga::SizingMode* mode, float* size); void facebook::yoga::fatalWithMessage(const char* message); void facebook::yoga::layoutAbsoluteChild(const facebook::yoga::Node* containingNode, const facebook::yoga::Node* node, facebook::yoga::Node* child, float containingBlockWidth, float containingBlockHeight, facebook::yoga::SizingMode widthMode, facebook::yoga::Direction direction, facebook::yoga::LayoutData& layoutMarkerData, uint32_t depth, uint32_t generationCount); diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api index 2f0733cb396..8ff381554a9 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api @@ -12678,7 +12678,7 @@ void facebook::yoga::assertFatal(bool condition, const char* message); void facebook::yoga::assertFatalWithConfig(const facebook::yoga::Config* config, bool condition, const char* message); void facebook::yoga::assertFatalWithNode(const facebook::yoga::Node* node, bool condition, const char* message); void facebook::yoga::calculateLayout(facebook::yoga::Node* node, float ownerWidth, float ownerHeight, facebook::yoga::Direction ownerDirection); -void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node *const node); +void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node* node, bool didPerformLayout); void facebook::yoga::constrainMaxSizeForMode(const facebook::yoga::Node* node, facebook::yoga::Direction direction, facebook::yoga::FlexDirection axis, float ownerAxisSize, float ownerWidth, facebook::yoga::SizingMode* mode, float* size); void facebook::yoga::fatalWithMessage(const char* message); void facebook::yoga::layoutAbsoluteChild(const facebook::yoga::Node* containingNode, const facebook::yoga::Node* node, facebook::yoga::Node* child, float containingBlockWidth, float containingBlockHeight, facebook::yoga::SizingMode widthMode, facebook::yoga::Direction direction, facebook::yoga::LayoutData& layoutMarkerData, uint32_t depth, uint32_t generationCount); diff --git a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api index 62d88ff7546..659d05423e4 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api @@ -15021,7 +15021,7 @@ void facebook::yoga::assertFatal(bool condition, const char* message); void facebook::yoga::assertFatalWithConfig(const facebook::yoga::Config* config, bool condition, const char* message); void facebook::yoga::assertFatalWithNode(const facebook::yoga::Node* node, bool condition, const char* message); void facebook::yoga::calculateLayout(facebook::yoga::Node* node, float ownerWidth, float ownerHeight, facebook::yoga::Direction ownerDirection); -void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node *const node); +void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node* node, bool didPerformLayout); void facebook::yoga::constrainMaxSizeForMode(const facebook::yoga::Node* node, facebook::yoga::Direction direction, facebook::yoga::FlexDirection axis, float ownerAxisSize, float ownerWidth, facebook::yoga::SizingMode* mode, float* size); void facebook::yoga::fatalWithMessage(const char* message); void facebook::yoga::layoutAbsoluteChild(const facebook::yoga::Node* containingNode, const facebook::yoga::Node* node, facebook::yoga::Node* child, float containingBlockWidth, float containingBlockHeight, facebook::yoga::SizingMode widthMode, facebook::yoga::Direction direction, facebook::yoga::LayoutData& layoutMarkerData, uint32_t depth, uint32_t generationCount); diff --git a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api index b8feb8d7d21..8cabf8709cb 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api @@ -14887,7 +14887,7 @@ void facebook::yoga::assertFatal(bool condition, const char* message); void facebook::yoga::assertFatalWithConfig(const facebook::yoga::Config* config, bool condition, const char* message); void facebook::yoga::assertFatalWithNode(const facebook::yoga::Node* node, bool condition, const char* message); void facebook::yoga::calculateLayout(facebook::yoga::Node* node, float ownerWidth, float ownerHeight, facebook::yoga::Direction ownerDirection); -void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node *const node); +void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node* node, bool didPerformLayout); void facebook::yoga::constrainMaxSizeForMode(const facebook::yoga::Node* node, facebook::yoga::Direction direction, facebook::yoga::FlexDirection axis, float ownerAxisSize, float ownerWidth, facebook::yoga::SizingMode* mode, float* size); void facebook::yoga::fatalWithMessage(const char* message); void facebook::yoga::layoutAbsoluteChild(const facebook::yoga::Node* containingNode, const facebook::yoga::Node* node, facebook::yoga::Node* child, float containingBlockWidth, float containingBlockHeight, facebook::yoga::SizingMode widthMode, facebook::yoga::Direction direction, facebook::yoga::LayoutData& layoutMarkerData, uint32_t depth, uint32_t generationCount); diff --git a/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api index 5f8fc0c410b..425ba3f6239 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api @@ -9838,7 +9838,7 @@ void facebook::yoga::assertFatal(bool condition, const char* message); void facebook::yoga::assertFatalWithConfig(const facebook::yoga::Config* config, bool condition, const char* message); void facebook::yoga::assertFatalWithNode(const facebook::yoga::Node* node, bool condition, const char* message); void facebook::yoga::calculateLayout(facebook::yoga::Node* node, float ownerWidth, float ownerHeight, facebook::yoga::Direction ownerDirection); -void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node *const node); +void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node* node, bool didPerformLayout); void facebook::yoga::constrainMaxSizeForMode(const facebook::yoga::Node* node, facebook::yoga::Direction direction, facebook::yoga::FlexDirection axis, float ownerAxisSize, float ownerWidth, facebook::yoga::SizingMode* mode, float* size); void facebook::yoga::fatalWithMessage(const char* message); void facebook::yoga::layoutAbsoluteChild(const facebook::yoga::Node* containingNode, const facebook::yoga::Node* node, facebook::yoga::Node* child, float containingBlockWidth, float containingBlockHeight, facebook::yoga::SizingMode widthMode, facebook::yoga::Direction direction, facebook::yoga::LayoutData& layoutMarkerData, uint32_t depth, uint32_t generationCount); diff --git a/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api index 727e60d3be7..efbcee3bfbd 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api @@ -9829,7 +9829,7 @@ void facebook::yoga::assertFatal(bool condition, const char* message); void facebook::yoga::assertFatalWithConfig(const facebook::yoga::Config* config, bool condition, const char* message); void facebook::yoga::assertFatalWithNode(const facebook::yoga::Node* node, bool condition, const char* message); void facebook::yoga::calculateLayout(facebook::yoga::Node* node, float ownerWidth, float ownerHeight, facebook::yoga::Direction ownerDirection); -void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node *const node); +void facebook::yoga::cleanupContentsNodesRecursively(facebook::yoga::Node* node, bool didPerformLayout); void facebook::yoga::constrainMaxSizeForMode(const facebook::yoga::Node* node, facebook::yoga::Direction direction, facebook::yoga::FlexDirection axis, float ownerAxisSize, float ownerWidth, facebook::yoga::SizingMode* mode, float* size); void facebook::yoga::fatalWithMessage(const char* message); void facebook::yoga::layoutAbsoluteChild(const facebook::yoga::Node* containingNode, const facebook::yoga::Node* node, facebook::yoga::Node* child, float containingBlockWidth, float containingBlockHeight, facebook::yoga::SizingMode widthMode, facebook::yoga::Direction direction, facebook::yoga::LayoutData& layoutMarkerData, uint32_t depth, uint32_t generationCount);