Fix shrinking in non strech alignments while retaining legacy behaviour
Summary: This fixes shrinking of elements which are in a non stretch alignment, but keeps the legacy stretch behaviour in place. Additionally this adds a testcase for ```useLegacyStretchBehaviour``` Fixes #633 Closes https://github.com/facebook/yoga/pull/635 Differential Revision: D6408037 Pulled By: emilsjolander fbshipit-source-id: 377ab0308dd3a75a148a0af31ab5eb3ffb5b5d83
This commit is contained in:
parent
41da6e3128
commit
1d62848535
|
@ -2123,6 +2123,7 @@ 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) {
|
||||||
|
@ -2137,11 +2138,12 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||||
// space we've used is all space we need. Root node also should be shrunk to minimum
|
// space we've used is all space we need. Root node also should be shrunk to minimum
|
||||||
availableInnerMainDim = sizeConsumedOnCurrentLine;
|
availableInnerMainDim = sizeConsumedOnCurrentLine;
|
||||||
}
|
}
|
||||||
|
sizeBasedOnContent = !node->config->useLegacyStretchBehaviour;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float remainingFreeSpace = 0;
|
float remainingFreeSpace = 0;
|
||||||
if (!YGFloatIsUndefined(availableInnerMainDim)) {
|
if (!sizeBasedOnContent && !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 based on its
|
// availableInnerMainDim is indefinite which means the node is being sized based on its
|
||||||
|
|
Loading…
Reference in New Issue