From 5da0a9909ee40777d695a4e2831dca3b5c369c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Mon, 10 Jul 2017 11:49:21 -0700 Subject: [PATCH] Reset the hadOverflow flag at the beginning of the algorithm Summary: This fixes the case where we change the layout, so that it doesn't overflow anymore. This also improves the readability by using `|=` instead of referencing the value twice. Closes https://github.com/facebook/yoga/pull/587 Differential Revision: D5388657 Pulled By: emilsjolander fbshipit-source-id: ce1b1ded1feed7314a2c16bf695f62b866c19ea0 --- ReactCommon/yoga/yoga/Yoga.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ReactCommon/yoga/yoga/Yoga.c b/ReactCommon/yoga/yoga/Yoga.c index bde8deae4d2..68009fd8300 100644 --- a/ReactCommon/yoga/yoga/Yoga.c +++ b/ReactCommon/yoga/yoga/Yoga.c @@ -2041,6 +2041,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, return; } + // Reset layout flags, as they could have changed. + node->layout.hadOverflow = false; + // STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM const YGFlexDirection mainAxis = YGResolveFlexDirection(node->style.flexDirection, direction); const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction); @@ -2577,14 +2580,14 @@ static void YGNodelayoutImpl(const YGNodeRef node, performLayout && !requiresStretchLayout, "flex", config); - node->layout.hadOverflow = node->layout.hadOverflow || currentRelativeChild->layout.hadOverflow; + node->layout.hadOverflow |= currentRelativeChild->layout.hadOverflow; currentRelativeChild = currentRelativeChild->nextChild; } } remainingFreeSpace = originalRemainingFreeSpace + deltaFreeSpace; - node->layout.hadOverflow = node->layout.hadOverflow || (remainingFreeSpace < 0); + node->layout.hadOverflow |= (remainingFreeSpace < 0); // STEP 6: MAIN-AXIS JUSTIFICATION & CROSS-AXIS SIZE DETERMINATION