From 32739afcc1db1997a887dfba7bc6b45b9b7e3e87 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Mon, 8 Apr 2019 03:16:53 -0700 Subject: [PATCH] Fix bugs around `align-content` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: @public Regenerating the “golden master” tests with chrome surfaced different bugs around `align-content`: - a misunderstanding that values in `align-content` only applied *if there is only one line.* In fact, it applies *every time* a container is set to `flex-wrap: wrap`. Chrome had this wrong, and as such our tests were generated with incorrect parameters. - empty children growing to the cross axis size of the container, even when `align-content` is different from `stretch`. This was implemented incorrectly in Chrome as well. Here, we fix it with an extra check. Reviewed By: SidharthGuglani Differential Revision: D14725402 fbshipit-source-id: a45bebdadb9c694dc0eb7e27cb52b3d247f81c50 --- ReactCommon/yoga/yoga/Yoga.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 8190399125d..431a59a888a 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -3089,12 +3089,19 @@ static void YGNodelayoutImpl( const float childHeight = !isMainAxisRow ? childMainSize : childCrossSize; + auto alignContent = node->getStyle().alignContent; + auto crossAxisDoesNotGrow = + alignContent != YGAlignStretch && isNodeFlexWrap; const YGMeasureMode childWidthMeasureMode = - YGFloatIsUndefined(childWidth) ? YGMeasureModeUndefined - : YGMeasureModeExactly; + YGFloatIsUndefined(childWidth) || + (!isMainAxisRow && crossAxisDoesNotGrow) + ? YGMeasureModeUndefined + : YGMeasureModeExactly; const YGMeasureMode childHeightMeasureMode = - YGFloatIsUndefined(childHeight) ? YGMeasureModeUndefined - : YGMeasureModeExactly; + YGFloatIsUndefined(childHeight) || + (isMainAxisRow && crossAxisDoesNotGrow) + ? YGMeasureModeUndefined + : YGMeasureModeExactly; YGLayoutNodeInternal( child, @@ -3148,7 +3155,7 @@ static void YGNodelayoutImpl( // STEP 8: MULTI-LINE CONTENT ALIGNMENT // currentLead stores the size of the cross dim - if (performLayout && (lineCount > 1 || YGIsBaselineLayout(node))) { + if (performLayout && (isNodeFlexWrap || YGIsBaselineLayout(node))) { float crossDimLead = 0; float currentLead = leadingPaddingAndBorderCross; if (!YGFloatIsUndefined(availableInnerCrossDim)) {