Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions CSSLayout/CSSLayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,14 +1591,18 @@ static void layoutNodeImpl(const CSSNodeRef node,
child->lineIndex = lineCount;

if (child->style.positionType != CSSPositionTypeAbsolute) {
const float marginAndPaddingAndBorderAxis = (isNodeFlexWrap
? getPaddingAndBorderAxis(child, mainAxis)
: 0) + getMarginAxis(child, mainAxis);
const float minimumSize = child->style.minDimensions[isMainAxisRow ? CSSDimensionWidth : CSSDimensionHeight] + marginAndPaddingAndBorderAxis;
const float outerFlexBasis =
child->layout.computedFlexBasis + getMarginAxis(child, mainAxis);
child->layout.computedFlexBasis + marginAndPaddingAndBorderAxis;

// 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 &&
if (sizeConsumedOnCurrentLine + fmaxf(outerFlexBasis, minimumSize) > availableInnerMainDim && isNodeFlexWrap &&
itemsOnLine > 0) {
break;
}
Expand Down Expand Up @@ -1702,7 +1706,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
// Is this child able to shrink?
if (flexShrinkScaledFactor != 0) {
baseMainSize =
childFlexBasis +
childFlexBasis + (isNodeFlexWrap ? getPaddingAndBorderAxis(currentRelativeChild, mainAxis) : 0) +
remainingFreeSpace / totalFlexShrinkScaledFactors * flexShrinkScaledFactor;
boundMainSize = boundAxis(currentRelativeChild, mainAxis, baseMainSize);
if (baseMainSize != boundMainSize) {
Expand All @@ -1721,8 +1725,8 @@ static void layoutNodeImpl(const CSSNodeRef node,

// Is this child able to grow?
if (flexGrowFactor != 0) {
baseMainSize =
childFlexBasis + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor;
baseMainSize = (isNodeFlexWrap ? getPaddingAndBorderAxis(currentRelativeChild, mainAxis) : 0) +
childFlexBasis + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor;
boundMainSize = boundAxis(currentRelativeChild, mainAxis, baseMainSize);
if (baseMainSize != boundMainSize) {
// By excluding this item's size and flex factor from remaining,
Expand Down Expand Up @@ -1766,7 +1770,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
(remainingFreeSpace / totalFlexShrinkScaledFactors) * flexShrinkScaledFactor;
}

updatedMainSize = boundAxis(currentRelativeChild, mainAxis, childSize);
updatedMainSize = boundAxis(currentRelativeChild, mainAxis, childSize + (isNodeFlexWrap ? getPaddingAndBorderAxis(currentRelativeChild, mainAxis) : 0));
}
} else if (remainingFreeSpace > 0) {
flexGrowFactor = CSSNodeStyleGetFlexGrow(currentRelativeChild);
Expand All @@ -1776,7 +1780,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
updatedMainSize =
boundAxis(currentRelativeChild,
mainAxis,
childFlexBasis +
childFlexBasis + (isNodeFlexWrap ? getPaddingAndBorderAxis(currentRelativeChild, mainAxis) : 0) +
remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor);
}
}
Expand Down Expand Up @@ -1942,6 +1946,18 @@ static void layoutNodeImpl(const CSSNodeRef node,
child->layout.position[pos[mainAxis]] += mainDim;
}

if (isNodeFlexWrap){
switch (node->style.justifyContent){
case CSSJustifyFlexEnd:
child->layout.position[pos[mainAxis]] += getPaddingAndBorderAxis(child, mainAxis);
break;
case CSSJustifyCenter:
case CSSJustifySpaceAround:
child->layout.position[pos[mainAxis]] += getLeadingPaddingAndBorder(child, mainAxis);
break;
}
}

if (canSkipFlex) {
// If we skipped the flex step, then we can't rely on the
// measuredDims because
Expand Down
Loading