From d963e3dd7f95d1b51f5d04c817decfcd27de72a4 Mon Sep 17 00:00:00 2001 From: Georgiy Kassabli Date: Mon, 6 Feb 2017 12:58:37 -0800 Subject: [PATCH] Fix for Yoga test failure for flexing with min stack dimension Reviewed By: emilsjolander Differential Revision: D4456312 fbshipit-source-id: 82a39bc93cf3bf2374b968e9f7403397e752908e --- ReactCommon/yoga/yoga/Yoga.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ReactCommon/yoga/yoga/Yoga.c b/ReactCommon/yoga/yoga/Yoga.c index 4073d102993..4ab537a5136 100644 --- a/ReactCommon/yoga/yoga/Yoga.c +++ b/ReactCommon/yoga/yoga/Yoga.c @@ -1907,11 +1907,13 @@ static void YGNodelayoutImpl(const YGNodeRef node, // above float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; if (!YGFloatIsUndefined(availableInnerWidth)) { + // We want to make sure our available width does not violate min and max constraints availableInnerWidth = fmaxf(fminf(availableInnerWidth, maxInnerWidth), minInnerWidth); } float availableInnerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; if (!YGFloatIsUndefined(availableInnerHeight)) { + // We want to make sure our available height does not violate min and max constraints availableInnerHeight = fmaxf(fminf(availableInnerHeight, maxInnerHeight), minInnerHeight); } @@ -2086,13 +2088,15 @@ static void YGNodelayoutImpl(const YGNodeRef node, // If the main dimension size isn't known, it is computed based on // the line length, so there's no more space left to distribute. - // We resolve main dimension to fit minimum and maximum values - if (YGFloatIsUndefined(availableInnerMainDim)) { + // If we don't measure with exact main dimension we want to ensure we don't violate min and max + if (measureModeMainDim != YGMeasureModeExactly) { if (!YGFloatIsUndefined(minInnerMainDim) && sizeConsumedOnCurrentLine < minInnerMainDim) { availableInnerMainDim = minInnerMainDim; - } else if (!YGFloatIsUndefined(maxInnerMainDim) && - sizeConsumedOnCurrentLine > maxInnerMainDim) { + } else if (!YGFloatIsUndefined(maxInnerMainDim) && sizeConsumedOnCurrentLine > maxInnerMainDim) { availableInnerMainDim = maxInnerMainDim; + } else { + // If the measurement isn't exact, we want to use as little space as possible + availableInnerMainDim = sizeConsumedOnCurrentLine; } }