Fix useLegacyStretchBehaviour flag by simplifying its usage

Summary: See blame revision. we are still passing all the added tests from that pull request but with much simpler logic.

Reviewed By: gkassabli

Differential Revision: D4977923

fbshipit-source-id: cb488e63c7c2e15e4c0f0133a16df36580c646fd
This commit is contained in:
Emil Sjolander
2017-05-01 04:31:55 -07:00
committed by Facebook Github Bot
parent 40e1bf6ce3
commit 8eca67e257

View File

@@ -2199,7 +2199,6 @@ static void YGNodelayoutImpl(const YGNodeRef node,
// If the main dimension size isn't known, it is computed based on // 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. // the line length, so there's no more space left to distribute.
bool sizeBasedOnContent = false;
// If we don't measure with exact main dimension we want to ensure we don't violate min and max // If we don't measure with exact main dimension we want to ensure we don't violate min and max
if (measureModeMainDim != YGMeasureModeExactly) { if (measureModeMainDim != YGMeasureModeExactly) {
if (!YGFloatIsUndefined(minInnerMainDim) && sizeConsumedOnCurrentLine < minInnerMainDim) { if (!YGFloatIsUndefined(minInnerMainDim) && sizeConsumedOnCurrentLine < minInnerMainDim) {
@@ -2212,21 +2211,16 @@ static void YGNodelayoutImpl(const YGNodeRef node,
// space we've used is all space we need // space we've used is all space we need
availableInnerMainDim = sizeConsumedOnCurrentLine; availableInnerMainDim = sizeConsumedOnCurrentLine;
} }
sizeBasedOnContent = true;
} }
} }
float remainingFreeSpace = 0; float remainingFreeSpace = 0;
if ((!sizeBasedOnContent || node->config->useLegacyStretchBehaviour) && !YGFloatIsUndefined(availableInnerMainDim)) { if (!YGFloatIsUndefined(availableInnerMainDim)) {
remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine; remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine;
} else if (sizeConsumedOnCurrentLine < 0) { } else if (sizeConsumedOnCurrentLine < 0) {
// availableInnerMainDim is indefinite which means the node is being sized // availableInnerMainDim is indefinite which means the node is being sized based on its content.
// based on its // sizeConsumedOnCurrentLine is negative which means the node will allocate 0 points for
// content. // its content. Consequently, remainingFreeSpace is 0 - sizeConsumedOnCurrentLine.
// sizeConsumedOnCurrentLine is negative which means the node will
// allocate 0 points for
// its content. Consequently, remainingFreeSpace is 0 -
// sizeConsumedOnCurrentLine.
remainingFreeSpace = -sizeConsumedOnCurrentLine; remainingFreeSpace = -sizeConsumedOnCurrentLine;
} }