diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp index b54eeeeca3f4af..58394a4563210b 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp @@ -545,12 +545,8 @@ static float computeFlexBasisForChildren( if (performLayout) { // Set the initial position (relative to the owner). const Direction childDirection = child->resolveDirection(direction); - const float mainDim = - isRow(mainAxis) ? availableInnerWidth : availableInnerHeight; - const float crossDim = - isRow(mainAxis) ? availableInnerHeight : availableInnerWidth; child->setPosition( - childDirection, mainDim, crossDim, availableInnerWidth); + childDirection, availableInnerWidth, availableInnerHeight); } if (child->style().positionType() == PositionType::Absolute) { @@ -2388,8 +2384,7 @@ void calculateLayout( markerData, 0, // tree root gCurrentGenerationCount.load(std::memory_order_relaxed))) { - node->setPosition( - node->getLayout().direction(), ownerWidth, ownerHeight, ownerWidth); + node->setPosition(node->getLayout().direction(), ownerWidth, ownerHeight); roundLayoutResultsToPixelGrid(node, 0.0f, 0.0f); } diff --git a/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp b/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp index 31ad09f8c98131..abda52f5cfe93c 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp @@ -230,9 +230,8 @@ float Node::relativePosition( void Node::setPosition( const Direction direction, - const float mainSize, - const float crossSize, - const float ownerWidth) { + const float ownerWidth, + const float ownerHeight) { /* Root nodes should be always layouted as LTR, so we don't return negative * values. */ const Direction directionRespectingRoot = @@ -244,10 +243,14 @@ void Node::setPosition( // In the case of position static these are just 0. See: // https://www.w3.org/TR/css-position-3/#valdef-position-static - const float relativePositionMain = - relativePosition(mainAxis, directionRespectingRoot, mainSize); - const float relativePositionCross = - relativePosition(crossAxis, directionRespectingRoot, crossSize); + const float relativePositionMain = relativePosition( + mainAxis, + directionRespectingRoot, + isRow(mainAxis) ? ownerWidth : ownerHeight); + const float relativePositionCross = relativePosition( + crossAxis, + directionRespectingRoot, + isRow(mainAxis) ? ownerHeight : ownerWidth); const auto mainAxisLeadingEdge = inlineStartEdge(mainAxis, direction); const auto mainAxisTrailingEdge = inlineEndEdge(mainAxis, direction); diff --git a/packages/react-native/ReactCommon/yoga/yoga/node/Node.h b/packages/react-native/ReactCommon/yoga/yoga/node/Node.h index cd029b40d46671..06175b8ee03249 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/node/Node.h +++ b/packages/react-native/ReactCommon/yoga/yoga/node/Node.h @@ -229,11 +229,7 @@ class YG_EXPORT Node : public ::YGNode { void setLayoutBorder(float border, PhysicalEdge edge); void setLayoutPadding(float padding, PhysicalEdge edge); void setLayoutPosition(float position, PhysicalEdge edge); - void setPosition( - Direction direction, - float mainSize, - float crossSize, - float ownerWidth); + void setPosition(Direction direction, float ownerWidth, float ownerHeight); // Other methods Style::Length resolveFlexBasisPtr() const;