diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index f4c6fdf6cc9..6a83e0fffee 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -1989,12 +1989,15 @@ nsFlexContainerFrame::GenerateFlexLines( { MOZ_ASSERT(aLines.IsEmpty(), "Expecting outparam to start out empty"); + const bool isSingleLine = + NS_STYLE_FLEX_WRAP_NOWRAP == aReflowState.mStylePosition->mFlexWrap; + // We have at least one FlexLine. Even an empty flex container has a single // (empty) flex line. FlexLine* curLine = aLines.AppendElement(); nscoord wrapThreshold; - if (NS_STYLE_FLEX_WRAP_NOWRAP == aReflowState.mStylePosition->mFlexWrap) { + if (isSingleLine) { // Not wrapping. Set threshold to sentinel value that tells us not to wrap. wrapThreshold = NS_UNCONSTRAINEDSIZE; @@ -2026,8 +2029,16 @@ nsFlexContainerFrame::GenerateFlexLines( } for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) { + nsIFrame* childFrame = e.get(); + + // Honor "page-break-before", if we're multi-line and this line isn't empty: + if (!isSingleLine && !curLine->mItems.IsEmpty() && + childFrame->StyleDisplay()->mBreakBefore) { + curLine = aLines.AppendElement(); + } + FlexItem* item = curLine->mItems.AppendElement( - GenerateFlexItemForChild(aPresContext, e.get(), + GenerateFlexItemForChild(aPresContext, childFrame, aReflowState, aAxisTracker)); nsresult rv = ResolveFlexItemMaxContentSizing(aPresContext, *item, @@ -2064,6 +2075,12 @@ nsFlexContainerFrame::GenerateFlexLines( curLine->AddToMainSizeTotals(itemInnerHypotheticalMainSize, itemOuterHypotheticalMainSize); + + // Honor "page-break-after", if we're multi-line and have more children: + if (!isSingleLine && childFrame->GetNextSibling() && + childFrame->StyleDisplay()->mBreakAfter) { + curLine = aLines.AppendElement(); + } } return NS_OK;