Bug 1000957: For single-line flex containers, clamp the flex line to container's min/max cross size. r=dholbert

MozReview-Commit-ID: 9Kqg0lPnkv0
This commit is contained in:
Emilio Cobos Álvarez 2016-08-09 10:17:24 -07:00
Родитель 15e65891fc
Коммит ddbd14670c
1 изменённых файлов: 20 добавлений и 12 удалений

Просмотреть файл

@ -2033,7 +2033,7 @@ private:
class MOZ_STACK_CLASS CrossAxisPositionTracker : public PositionTracker {
public:
CrossAxisPositionTracker(FlexLine* aFirstLine,
uint8_t aAlignContent,
const ReflowInput& aReflowInput,
nscoord aContentBoxCrossSize,
bool aIsCrossSizeDefinite,
const FlexboxAxisTracker& aAxisTracker);
@ -2737,7 +2737,7 @@ MainAxisPositionTracker::TraversePackingSpace()
CrossAxisPositionTracker::
CrossAxisPositionTracker(FlexLine* aFirstLine,
uint8_t aAlignContent,
const ReflowInput& aReflowInput,
nscoord aContentBoxCrossSize,
bool aIsCrossSizeDefinite,
const FlexboxAxisTracker& aAxisTracker)
@ -2745,7 +2745,7 @@ CrossAxisPositionTracker::
aAxisTracker.IsCrossAxisReversed()),
mPackingSpaceRemaining(0),
mNumPackingSpacesRemaining(0),
mAlignContent(aAlignContent)
mAlignContent(aReflowInput.mStylePosition->ComputedAlignContent())
{
MOZ_ASSERT(aFirstLine, "null first line pointer");
@ -2757,17 +2757,26 @@ CrossAxisPositionTracker::
// XXX strip of the <overflow-position> bit until we implement that
mAlignContent &= ~NS_STYLE_ALIGN_FLAG_BITS;
if (aIsCrossSizeDefinite && !aFirstLine->getNext()) {
// "If the flex container has only a single line (even if it's a
// multi-line flex container) and has a definite cross size, the cross
// size of the flex line is the flex container's inner cross size."
if (!aFirstLine->getNext()) {
// "If the flex container is single-line and has a definite cross size, the
// cross size of the flex line is the flex container's inner cross size."
//
// SOURCE: http://dev.w3.org/csswg/css-flexbox/#algo-line-break
// NOTE: This means (by definition) that there's no packing space, which
// means we don't need to be concerned with "align-conent" at all and we
// can return early. This is handy, because this is the usual case (for
// single-line flexbox).
aFirstLine->SetLineCrossSize(aContentBoxCrossSize);
return;
if (aIsCrossSizeDefinite) {
aFirstLine->SetLineCrossSize(aContentBoxCrossSize);
return;
}
// "If the flex container is single-line, then clamp the line's
// cross-size to be within the container's computed min and max cross-size
// properties."
aFirstLine->SetLineCrossSize(NS_CSS_MINMAX(aFirstLine->GetLineCrossSize(),
aReflowInput.ComputedMinBSize(),
aReflowInput.ComputedMaxBSize()));
}
// NOTE: The rest of this function should essentially match
@ -4020,9 +4029,8 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
// scope of a particular flex line)
CrossAxisPositionTracker
crossAxisPosnTracker(lines.getFirst(),
aReflowInput.mStylePosition->ComputedAlignContent(),
contentBoxCrossSize, isCrossSizeDefinite,
aAxisTracker);
aReflowInput, contentBoxCrossSize,
isCrossSizeDefinite, aAxisTracker);
// Now that we know the cross size of each line (including
// "align-content:stretch" adjustments, from the CrossAxisPositionTracker