From 7162d3aa1678536149f4c7e4e594ac9fa3d51953 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Thu, 21 Nov 2013 10:20:02 -0800 Subject: [PATCH] Bug 811024 part 4: Don't ask for bottom border/padding space on a flex container if it's going to get a continuation. r=mats --- layout/generic/nsFlexContainerFrame.cpp | 33 ++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 80b78ef6efaf..235406f7bba3 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -2550,8 +2550,9 @@ nsFlexContainerFrame::Reflow(nsPresContext* aPresContext, aDesiredSize.width = desiredContentBoxSize.width + containerBorderPadding.LeftRight(); + // Does *NOT* include bottom border/padding yet (we add that a bit lower down) aDesiredSize.height = desiredContentBoxSize.height + - containerBorderPadding.TopBottom(); + containerBorderPadding.top; if (flexContainerAscent == nscoord_MIN) { // Still don't have our baseline set -- this happens if we have no @@ -2562,12 +2563,36 @@ nsFlexContainerFrame::Reflow(nsPresContext* aPresContext, "Have flex items but didn't get an ascent - that's odd " "(or there are just gigantic sizes involved)"); // Per spec, just use the bottom of content-box. - flexContainerAscent = aDesiredSize.height - - aReflowState.mComputedBorderPadding.bottom; + flexContainerAscent = aDesiredSize.height; } - aDesiredSize.ascent = flexContainerAscent; + // Now: If we're complete, add bottom border/padding to desired height + // (unless that pushes us over available height, in which case we become + // incomplete (unless we already weren't asking for any height, in which case + // we stay complete to avoid looping forever)). + // NOTE: If we're auto-height, we allow our bottom border/padding to push us + // over the available height without requesting a continuation, for + // consistency with the behavior of "display:block" elements. + if (NS_FRAME_IS_COMPLETE(aStatus)) { + // NOTE: We can't use containerBorderPadding.bottom for this, because if + // we're auto-height, ApplySkipSides will have zeroed it (because it + // assumed we might get a continuation). We have the correct value in + // aReflowState.mComputedBorderPadding.bottom, though, so we use that. + nscoord desiredHeightWithBottomBP = + aDesiredSize.height + aReflowState.mComputedBorderPadding.bottom; + + if (aDesiredSize.height == 0 || + desiredHeightWithBottomBP <= aReflowState.availableHeight || + aReflowState.ComputedHeight() == NS_INTRINSICSIZE) { + // Update desired height to include bottom border/padding + aDesiredSize.height = desiredHeightWithBottomBP; + } else { + // We couldn't fit bottom border/padding, so we'll need a continuation. + NS_FRAME_SET_INCOMPLETE(aStatus); + } + } + // Overflow area = union(my overflow area, kids' overflow areas) aDesiredSize.SetOverflowAreasToDesiredBounds(); for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {