From 3b93ba9af7bb3e8c6288caf40611ddf18dfd7860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Fri, 16 Jun 2017 07:31:19 -0700 Subject: [PATCH] The total flex factores need to be a minimum of 1 if any MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: The only thing I found in the spec for this change is the following. Not exactly sure if this is the thing this PR is about: > For each flex item, subtract its outer flex base size from its max-content contribution size. If that result is not zero, divide it by (if the result was positive) its **flex grow factor floored at 1** or (if the result was negative) by its scaled flex shrink factor, having **floored the flex shrink factor at 1**. This is the item’s max-content flex fraction. But at least it seems a required change. Fixes facebook/yoga#566 Closes https://github.com/facebook/yoga/pull/572 Differential Revision: D5264388 Pulled By: emilsjolander fbshipit-source-id: 0004d1c3b9bad070a98cd6766c1adc06a54475f8 --- ReactCommon/yoga/yoga/Yoga.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ReactCommon/yoga/yoga/Yoga.c b/ReactCommon/yoga/yoga/Yoga.c index 96c6c5a5d0d..b946926352e 100644 --- a/ReactCommon/yoga/yoga/Yoga.c +++ b/ReactCommon/yoga/yoga/Yoga.c @@ -2278,6 +2278,16 @@ static void YGNodelayoutImpl(const YGNodeRef node, } } + // The total flex factor needs to be floored to 1. + if (totalFlexGrowFactors > 0 && totalFlexGrowFactors < 1) { + totalFlexGrowFactors = 1; + } + + // The total flex shrink factor needs to be floored to 1. + if (totalFlexShrinkScaledFactors > 0 && totalFlexShrinkScaledFactors < 1) { + totalFlexShrinkScaledFactors = 1; + } + // If we don't need to measure the cross axis, we can skip the entire flex // step. const bool canSkipFlex = !performLayout && measureModeCrossDim == YGMeasureModeExactly;