From f751c3460e5dc48c1f1a2d72a56173285899de21 Mon Sep 17 00:00:00 2001 From: Yuichi ONO Date: Thu, 15 Feb 2018 07:16:59 -0800 Subject: [PATCH] Fix main size calculation from the aspect ratio Summary: When the following conditions are met, the main size become smaller by the margins in the main axis. * The aspect ratio is defined * The main size is not defined * The cross size is defined * The main margin is defined This is because the main margin size is not included when calculating the main size from the aspect ratio. Closes https://github.com/facebook/yoga/pull/715 Reviewed By: emilsjolander Differential Revision: D6998988 Pulled By: priteshrnandgaonkar fbshipit-source-id: f6f69c47ece17bd7c5e41517b96032bf0c149356 --- ReactCommon/yoga/yoga/Yoga.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 63b00c6cc8a586..8f1f5e04e84ecd 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -1102,10 +1102,11 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, if (!YGFloatIsUndefined(child->getStyle().aspectRatio)) { if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) { - childHeight = (childWidth - marginRow) / child->getStyle().aspectRatio; + childHeight = marginColumn + + (childWidth - marginRow) / child->getStyle().aspectRatio; childHeightMeasureMode = YGMeasureModeExactly; } else if (isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) { - childWidth = + childWidth = marginRow + (childHeight - marginColumn) * child->getStyle().aspectRatio; childWidthMeasureMode = YGMeasureModeExactly; }