Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,12 @@ static MinContentSize measureOrWalkMinContentMainSize(

const Direction direction = node->resolveDirection(ownerDirection);
// Children add up along the container's main axis; across it the largest
// counts.
const bool alongMainAxis = isRow(node->style().flexDirection()) == wantRow;
// counts. A wrapping row can put each child on a line of its own, so its
// largest child counts along it too (css-flexbox-1 §9.9.1). A wrapping
// column still adds up: Chrome finds a min-content height by layout at an
// indefinite height, where nothing wraps.
const bool childrenAddUp = isRow(node->style().flexDirection()) == wantRow &&
(node->style().flexWrap() == Wrap::NoWrap || !wantRow);

float minContent = 0.0f;
size_t itemCount = 0;
Expand All @@ -1052,15 +1056,15 @@ static MinContentSize measureOrWalkMinContentMainSize(
generationCount);
const float childSize =
child.size + childStyle.computeMarginForAxis(requestedAxis, ownerWidth);
minContent = alongMainAxis ? minContent + childSize
minContent = childrenAddUp ? minContent + childSize
: std::max(minContent, childSize);
resolvesAgainstOwnerWidth = resolvesAgainstOwnerWidth ||
child.resolvesAgainstOwnerWidth || childStyle.hasPercentMargin();
}

// A percentage gap resolves against the size being found, so it counts as
// zero (css-sizing-3 §5.2.1).
if (alongMainAxis && itemCount > 1) {
if (childrenAddUp && itemCount > 1) {
minContent += node->style().computeGapForAxis(requestedAxis, 0.0f) *
static_cast<float>(itemCount - 1);
}
Expand Down Expand Up @@ -1190,9 +1194,9 @@ static MinContentSize computeChildMinContentContribution(
// * Container: iterate in-flow children. For each, take its
// min-content contribution along `requestedAxis` plus its margins:
// the sum of them where that is the container's main axis, the
// largest where it is its cross axis. Add the gaps between them
// along the main axis, and the container's own padding and border
// on both ends of the axis.
// largest where it is its cross axis or the container is a
// wrapping row. Add the gaps between the children that add up, and
// the container's own padding and border on both ends of the axis.
//
// Container-level recursion does no layout writes (no positions, no
// alignment, no flex distribution); only the descendant leaf measure
Expand Down
Loading