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
|
||||
// the remaining space left for the flexible children.
|
||||
float sizeConsumedOnCurrentLine = 0;
|
||||
float sizeConsumedOnCurrentLineIncludingMinConstraint = 0;
|
||||
|
||||
float totalFlexGrowFactors = 0;
|
||||
float totalFlexShrinkScaledFactors = 0;
|
||||
|
@ -2139,21 +2140,24 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||
child->lineIndex = lineCount;
|
||||
|
||||
if (child->style.positionType != YGPositionTypeAbsolute) {
|
||||
const float childMarginMainAxis = YGNodeMarginForAxis(child, mainAxis, availableInnerWidth);
|
||||
const float outerFlexBasis =
|
||||
fmaxf(YGResolveValue(&child->style.minDimensions[dim[mainAxis]], mainAxisParentSize),
|
||||
child->layout.computedFlexBasis) +
|
||||
YGNodeMarginForAxis(child, mainAxis, availableInnerWidth);
|
||||
childMarginMainAxis;
|
||||
|
||||
// If this is a multi-line flow and this item pushes us over the
|
||||
// available size, we've
|
||||
// hit the end of the current line. Break out of the loop and lay out
|
||||
// the current line.
|
||||
if (sizeConsumedOnCurrentLine + outerFlexBasis > availableInnerMainDim && isNodeFlexWrap &&
|
||||
itemsOnLine > 0) {
|
||||
if (sizeConsumedOnCurrentLineIncludingMinConstraint + outerFlexBasis >
|
||||
availableInnerMainDim &&
|
||||
isNodeFlexWrap && itemsOnLine > 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
sizeConsumedOnCurrentLine += outerFlexBasis;
|
||||
sizeConsumedOnCurrentLineIncludingMinConstraint += outerFlexBasis;
|
||||
sizeConsumedOnCurrentLine += child->layout.computedFlexBasis + childMarginMainAxis;
|
||||
itemsOnLine++;
|
||||
|
||||
if (YGNodeIsFlex(child)) {
|
||||
|
|
Loading…
Reference in New Issue