diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index d2529a3ffb12..fcd71bc8a376 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -107,7 +107,7 @@ nsContainerFrame* NS_NewColumnSetFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle, nsFrameState aStateFlags) { nsColumnSetFrame* it = new (aPresShell) nsColumnSetFrame(aStyle); - it->AddStateBits(aStateFlags | NS_BLOCK_MARGIN_ROOT); + it->AddStateBits(aStateFlags); return it; } @@ -481,12 +481,11 @@ nsColumnSetFrame::ReflowColumns(ReflowOutput& aDesiredSize, nsReflowStatus& aReflowStatus, ReflowConfig& aConfig, bool aLastColumnUnbounded, - nsCollapsingMargin* aCarriedOutBEndMargin, ColumnBalanceData& aColData) { bool feasible = ReflowChildren(aDesiredSize, aReflowInput, aReflowStatus, aConfig, aLastColumnUnbounded, - aCarriedOutBEndMargin, aColData); + aColData); if (aColData.mHasExcessBSize) { aConfig = ChooseColumnStrategy(aReflowInput, true); @@ -495,8 +494,7 @@ nsColumnSetFrame::ReflowColumns(ReflowOutput& aDesiredSize, // end up with a stale column height for some of our columns, since we // bailed out of balancing. feasible = ReflowChildren(aDesiredSize, aReflowInput, aReflowStatus, - aConfig, aLastColumnUnbounded, - aCarriedOutBEndMargin, aColData); + aConfig, aLastColumnUnbounded, aColData); } return feasible; @@ -595,7 +593,6 @@ nsColumnSetFrame::ReflowChildren(ReflowOutput& aDesiredSize, nsReflowStatus& aStatus, const ReflowConfig& aConfig, bool aUnboundedLastColumn, - nsCollapsingMargin* aCarriedOutBEndMargin, ColumnBalanceData& aColData) { aColData.Reset(); @@ -807,7 +804,7 @@ nsColumnSetFrame::ReflowChildren(ReflowOutput& aDesiredSize, reflowNext = aStatus.NextInFlowNeedsReflow(); COLUMN_SET_LOG("%s: Reflowed child #%d %p: status=%s," - " desiredSize=(%d,%d), CarriedOutBEndMargin=%d", + " desiredSize=(%d,%d), CarriedOutBEndMargin=%d (ignored)", __func__, columnCount, child, @@ -816,9 +813,23 @@ nsColumnSetFrame::ReflowChildren(ReflowOutput& aDesiredSize, kidDesiredSize.BSize(wm), kidDesiredSize.mCarriedOutBEndMargin.get()); - NS_FRAME_TRACE_REFLOW_OUT("Column::Reflow", aStatus); + // The carried-out block-end margin of column content might be non-zero + // when we try to find the best column balancing block size, but it should + // never affect the size column set nor be further carried out. Set it to + // zero. + // + // FIXME: For some types of fragmentation, we should carry the margin into + // the next column. Also see + // https://drafts.csswg.org/css-break-4/#break-margins + // + // FIXME: This should never happen for the last column, since it should be + // a margin root; see nsBlockFrame::IsMarginRoot(). However, sometimes the + // last column has an empty continuation while searching for the best + // column balancing bsize, which prevents the last column from being a + // margin root. + kidDesiredSize.mCarriedOutBEndMargin.Zero(); - *aCarriedOutBEndMargin = kidDesiredSize.mCarriedOutBEndMargin; + NS_FRAME_TRACE_REFLOW_OUT("Column::Reflow", aStatus); FinishReflowChild(child, PresContext(), kidDesiredSize, &kidReflowInput, wm, childOrigin, containerSize, 0); @@ -1032,7 +1043,6 @@ nsColumnSetFrame::FindBestBalanceBSize(const ReflowInput& aReflowInput, ReflowConfig& aConfig, ColumnBalanceData& aColData, ReflowOutput& aDesiredSize, - nsCollapsingMargin& aOutMargin, bool& aUnboundedLastColumn, bool& aRunWasFeasible, nsReflowStatus& aStatus) @@ -1144,7 +1154,7 @@ nsColumnSetFrame::FindBestBalanceBSize(const ReflowInput& aReflowInput, aUnboundedLastColumn = false; MarkPrincipalChildrenDirty(this); feasible = ReflowColumns(aDesiredSize, aReflowInput, aStatus, aConfig, false, - &aOutMargin, aColData); + aColData); if (!aConfig.mIsBalancing) { // Looks like we had excess height when balancing, so we gave up on @@ -1174,7 +1184,7 @@ nsColumnSetFrame::FindBestBalanceBSize(const ReflowInput& aReflowInput, MarkPrincipalChildrenDirty(this); feasible = ReflowColumns(aDesiredSize, aReflowInput, aStatus, aConfig, availableContentBSize == NS_UNCONSTRAINEDSIZE, - &aOutMargin, aColData); + aColData); } } @@ -1238,20 +1248,17 @@ nsColumnSetFrame::Reflow(nsPresContext* aPresContext, // content back here and then have to push it out again! nsIFrame* nextInFlow = GetNextInFlow(); bool unboundedLastColumn = config.mIsBalancing && !nextInFlow; - nsCollapsingMargin carriedOutBottomMargin; ColumnBalanceData colData; bool feasible = ReflowColumns(aDesiredSize, aReflowInput, aStatus, config, - unboundedLastColumn, &carriedOutBottomMargin, - colData); + unboundedLastColumn, colData); // If we're not balancing, then we're already done, since we should have // reflown all of our children, and there is no need for a binary search to // determine proper column height. if (config.mIsBalancing && !aPresContext->HasPendingInterrupt()) { FindBestBalanceBSize(aReflowInput, aPresContext, config, colData, - aDesiredSize, carriedOutBottomMargin, - unboundedLastColumn, feasible, aStatus); + aDesiredSize, unboundedLastColumn, feasible, aStatus); } if (aPresContext->HasPendingInterrupt() && @@ -1271,8 +1278,6 @@ nsColumnSetFrame::Reflow(nsPresContext* aPresContext, FinishReflowWithAbsoluteFrames(aPresContext, aDesiredSize, aReflowInput, aStatus, false); - aDesiredSize.mCarriedOutBEndMargin = carriedOutBottomMargin; - NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize); } diff --git a/layout/generic/nsColumnSetFrame.h b/layout/generic/nsColumnSetFrame.h index 36ab655fa17e..2155fb935a9f 100644 --- a/layout/generic/nsColumnSetFrame.h +++ b/layout/generic/nsColumnSetFrame.h @@ -173,7 +173,6 @@ protected: nsReflowStatus& aReflowStatus, ReflowConfig& aConfig, bool aLastColumnUnbounded, - nsCollapsingMargin* aCarriedOutBEndMargin, ColumnBalanceData& aColData); /** @@ -198,8 +197,6 @@ protected: * successive iterations of the balancing process. * @param aDesiredSize The final output size of the column set frame (output * of reflow procedure). - * @param aOutMargin The bottom margin of the column set frame that may be - * carried out from reflow (and thus collapsed). * @param aUnboundedLastColumn A boolean value indicating that the last column * can be of any height. Used during the first iteration of the * balancing procedure to measure the height of all content in @@ -215,7 +212,6 @@ protected: ReflowConfig& aConfig, ColumnBalanceData& aColData, ReflowOutput& aDesiredSize, - nsCollapsingMargin& aOutMargin, bool& aUnboundedLastColumn, bool& aRunWasFeasible, nsReflowStatus& aStatus); @@ -228,7 +224,6 @@ protected: nsReflowStatus& aStatus, const ReflowConfig& aConfig, bool aLastColumnUnbounded, - nsCollapsingMargin* aCarriedOutBEndMargin, ColumnBalanceData& aColData); void ForEachColumnRule(const std::function& aSetLineRect, diff --git a/testing/web-platform/tests/css/css-multicol/multicol-margin-003.html b/testing/web-platform/tests/css/css-multicol/multicol-margin-003.html new file mode 100644 index 000000000000..769bcc79259c --- /dev/null +++ b/testing/web-platform/tests/css/css-multicol/multicol-margin-003.html @@ -0,0 +1,47 @@ + + + + CSS Multi-column Layout Test: multi-column and margin bottom of last child + + + + + + + + + +

Test passes if there is a filled green square.

+
+
a1 a2 a3 a4
+
a5
+
+
b1 b2
+ + + +