Fix min constraint incorrectly reducing available space
Summary: If a min constraint exists. It incorrectly reduces the available space by that amount. This adds a test and fix for this. Closes https://github.com/facebook/yoga/pull/501 Differential Revision: D4867146 Pulled By: emilsjolander fbshipit-source-id: ceafe070bfe7f501929d316656ac44c4e1753059
This commit is contained in:
parent
f7fe9a6219
commit
f26a99764a
|
@ -2122,6 +2122,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||||
// either set the dimensions of the node if none already exist or to compute
|
// either set the dimensions of the node if none already exist or to compute
|
||||||
// the remaining space left for the flexible children.
|
// the remaining space left for the flexible children.
|
||||||
float sizeConsumedOnCurrentLine = 0;
|
float sizeConsumedOnCurrentLine = 0;
|
||||||
|
float sizeConsumedOnCurrentLineIncludingMinConstraint = 0;
|
||||||
|
|
||||||
float totalFlexGrowFactors = 0;
|
float totalFlexGrowFactors = 0;
|
||||||
float totalFlexShrinkScaledFactors = 0;
|
float totalFlexShrinkScaledFactors = 0;
|
||||||
|
@ -2139,21 +2140,24 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||||
child->lineIndex = lineCount;
|
child->lineIndex = lineCount;
|
||||||
|
|
||||||
if (child->style.positionType != YGPositionTypeAbsolute) {
|
if (child->style.positionType != YGPositionTypeAbsolute) {
|
||||||
|
const float childMarginMainAxis = YGNodeMarginForAxis(child, mainAxis, availableInnerWidth);
|
||||||
const float outerFlexBasis =
|
const float outerFlexBasis =
|
||||||
fmaxf(YGResolveValue(&child->style.minDimensions[dim[mainAxis]], mainAxisParentSize),
|
fmaxf(YGResolveValue(&child->style.minDimensions[dim[mainAxis]], mainAxisParentSize),
|
||||||
child->layout.computedFlexBasis) +
|
child->layout.computedFlexBasis) +
|
||||||
YGNodeMarginForAxis(child, mainAxis, availableInnerWidth);
|
childMarginMainAxis;
|
||||||
|
|
||||||
// If this is a multi-line flow and this item pushes us over the
|
// If this is a multi-line flow and this item pushes us over the
|
||||||
// available size, we've
|
// available size, we've
|
||||||
// hit the end of the current line. Break out of the loop and lay out
|
// hit the end of the current line. Break out of the loop and lay out
|
||||||
// the current line.
|
// the current line.
|
||||||
if (sizeConsumedOnCurrentLine + outerFlexBasis > availableInnerMainDim && isNodeFlexWrap &&
|
if (sizeConsumedOnCurrentLineIncludingMinConstraint + outerFlexBasis >
|
||||||
itemsOnLine > 0) {
|
availableInnerMainDim &&
|
||||||
|
isNodeFlexWrap && itemsOnLine > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sizeConsumedOnCurrentLine += outerFlexBasis;
|
sizeConsumedOnCurrentLineIncludingMinConstraint += outerFlexBasis;
|
||||||
|
sizeConsumedOnCurrentLine += child->layout.computedFlexBasis + childMarginMainAxis;
|
||||||
itemsOnLine++;
|
itemsOnLine++;
|
||||||
|
|
||||||
if (YGNodeIsFlex(child)) {
|
if (YGNodeIsFlex(child)) {
|
||||||
|
|
Loading…
Reference in New Issue