From 82f2df73ba697eb7b3fa1eec409696bb210e0f04 Mon Sep 17 00:00:00 2001 From: Simon Montagu Date: Fri, 20 Jun 2014 02:55:35 -0700 Subject: [PATCH] Bug 789096 patch 8: use logical coordinates in nsBlockReflowState. r=jfkthame --- layout/generic/nsBlockFrame.cpp | 711 +++++++++++++----------- layout/generic/nsBlockFrame.h | 46 +- layout/generic/nsBlockReflowState.cpp | 230 ++++---- layout/generic/nsBlockReflowState.h | 107 ++-- layout/generic/nsColumnSetFrame.cpp | 8 +- layout/generic/nsFlexContainerFrame.cpp | 16 +- layout/generic/nsGridContainerFrame.cpp | 2 +- layout/generic/nsHTMLReflowMetrics.h | 9 + layout/generic/nsLineBox.cpp | 22 +- layout/generic/nsLineBox.h | 10 +- layout/generic/nsSplittableFrame.cpp | 24 +- layout/generic/nsSplittableFrame.h | 10 +- layout/tables/nsTableFrame.cpp | 3 +- 13 files changed, 638 insertions(+), 560 deletions(-) diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 31ea2be2b1ec..3ff1bebe3beb 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -920,9 +920,10 @@ AvailableSpaceShrunk(const nsRect& aOldAvailableSpace, return aOldAvailableSpace.width != aNewAvailableSpace.width; } -static nsSize -CalculateContainingBlockSizeForAbsolutes(const nsHTMLReflowState& aReflowState, - nsSize aFrameSize) +static LogicalSize +CalculateContainingBlockSizeForAbsolutes(WritingMode aWM, + const nsHTMLReflowState& aReflowState, + LogicalSize aFrameSize) { // The issue here is that for a 'height' of 'auto' the reflow state // code won't know how to calculate the containing block height @@ -930,12 +931,13 @@ CalculateContainingBlockSizeForAbsolutes(const nsHTMLReflowState& aReflowState, // size as the dimensions. nsIFrame* frame = aReflowState.frame; - nsSize cbSize(aFrameSize); + LogicalSize cbSize(aFrameSize); // Containing block is relative to the padding edge - const nsMargin& border = - aReflowState.ComputedPhysicalBorderPadding() - aReflowState.ComputedPhysicalPadding(); - cbSize.width -= border.LeftRight(); - cbSize.height -= border.TopBottom(); + const LogicalMargin& border = + LogicalMargin(aWM, aReflowState.ComputedPhysicalBorderPadding() - + aReflowState.ComputedPhysicalPadding()); + cbSize.ISize(aWM) -= border.IStartEnd(aWM); + cbSize.BSize(aWM) -= border.BStartEnd(aWM); if (frame->GetParent()->GetContent() == frame->GetContent() && frame->GetParent()->GetType() != nsGkAtoms::canvasFrame) { @@ -976,14 +978,24 @@ CalculateContainingBlockSizeForAbsolutes(const nsHTMLReflowState& aReflowState, } } // We found a reflow state for the outermost wrapping frame, so use - // its computed metrics if available - if (aLastRS->ComputedWidth() != NS_UNCONSTRAINEDSIZE) { - cbSize.width = std::max(0, - aLastRS->ComputedWidth() + aLastRS->ComputedPhysicalPadding().LeftRight() - scrollbars.LeftRight()); + // its computed metrics if available, converted to our writing mode + WritingMode lastWM = aLastRS->GetWritingMode(); + LogicalSize lastRSSize = + LogicalSize(lastWM, + aLastRS->ComputedISize(), + aLastRS->ComputedBSize()).ConvertTo(aWM, lastWM); + LogicalMargin lastRSPadding = + aLastRS->ComputedLogicalPadding().ConvertTo(aWM, lastWM); + LogicalMargin logicalScrollbars(aWM, scrollbars); + if (lastRSSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE) { + cbSize.ISize(aWM) = std::max(0, lastRSSize.ISize(aWM) + + lastRSPadding.IStartEnd(aWM) - + logicalScrollbars.IStartEnd(aWM)); } - if (aLastRS->ComputedHeight() != NS_UNCONSTRAINEDSIZE) { - cbSize.height = std::max(0, - aLastRS->ComputedHeight() + aLastRS->ComputedPhysicalPadding().TopBottom() - scrollbars.TopBottom()); + if (lastRSSize.BSize(aWM) != NS_UNCONSTRAINEDSIZE) { + cbSize.BSize(aWM) = std::max(0, lastRSSize.BSize(aWM) + + lastRSPadding.BStartEnd(aWM) - + logicalScrollbars.BStartEnd(aWM)); } } } @@ -1004,8 +1016,8 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, IndentBy(stdout, gNoiseIndent); ListTag(stdout); printf(": begin reflow availSize=%d,%d computedSize=%d,%d\n", - aReflowState.AvailableWidth(), aReflowState.AvailableHeight(), - aReflowState.ComputedWidth(), aReflowState.ComputedHeight()); + aReflowState.AvailableISize(), aReflowState.AvailableBSize(), + aReflowState.ComputedISize(), aReflowState.ComputedBSize()); } AutoNoisyIndenter indent(gNoisy); PRTime start = 0; // Initialize these variablies to silence the compiler. @@ -1017,17 +1029,17 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, #endif const nsHTMLReflowState *reflowState = &aReflowState; - nscoord consumedHeight = GetConsumedHeight(); - nscoord effectiveComputedHeight = GetEffectiveComputedHeight(aReflowState, - consumedHeight); + WritingMode wm = aReflowState.GetWritingMode(); + nscoord consumedBSize = GetConsumedBSize(); + nscoord effectiveComputedBSize = GetEffectiveComputedBSize(aReflowState, + consumedBSize); Maybe mutableReflowState; - // If we have non-auto height, we're clipping our kids and we fit, + // If we have non-auto block size, we're clipping our kids and we fit, // make sure our kids fit too. - if (aReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE && - aReflowState.ComputedHeight() != NS_AUTOHEIGHT && + if (aReflowState.AvailableBSize() != NS_UNCONSTRAINEDSIZE && + aReflowState.ComputedBSize() != NS_AUTOHEIGHT && ShouldApplyOverflowClipping(this, aReflowState.mStyleDisplay)) { LogicalMargin blockDirExtras = aReflowState.ComputedLogicalBorderPadding(); - WritingMode wm = aReflowState.GetWritingMode(); if (GetLogicalSkipSides() & (LOGICAL_SIDE_B_START)) { blockDirExtras.BStart(wm) = 0; } else { @@ -1037,7 +1049,7 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, aReflowState.ComputedLogicalMargin().BStart(wm); } - if (effectiveComputedHeight + blockDirExtras.BStartEnd(wm) <= + if (effectiveComputedBSize + blockDirExtras.BStartEnd(wm) <= aReflowState.AvailableBSize()) { mutableReflowState.construct(aReflowState); mutableReflowState.ref().AvailableBSize() = NS_UNCONSTRAINEDSIZE; @@ -1070,14 +1082,14 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, return; } - bool topMarginRoot, bottomMarginRoot; - IsMarginRoot(&topMarginRoot, &bottomMarginRoot); + bool blockStartMarginRoot, blockEndMarginRoot; + IsMarginRoot(&blockStartMarginRoot, &blockEndMarginRoot); // Cache the consumed height in the block reflow state so that we don't have // to continually recompute it. nsBlockReflowState state(*reflowState, aPresContext, this, - topMarginRoot, bottomMarginRoot, needFloatManager, - consumedHeight); + blockStartMarginRoot, blockEndMarginRoot, + needFloatManager, consumedBSize); if (GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION) static_cast(FirstContinuation())->ResolveBidi(); @@ -1149,7 +1161,7 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, // If we end in a BR with clear and affected floats continue, // we need to continue, too. - if (NS_UNCONSTRAINEDSIZE != reflowState->AvailableHeight() && + if (NS_UNCONSTRAINEDSIZE != reflowState->AvailableBSize() && NS_FRAME_IS_COMPLETE(state.mReflowStatus) && state.mFloatManager->ClearContinues(FindTrailingClear())) { NS_FRAME_SET_INCOMPLETE(state.mReflowStatus); @@ -1214,11 +1226,11 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, CheckFloats(state); // Compute our final size - nscoord bottomEdgeOfChildren; - ComputeFinalSize(*reflowState, state, aMetrics, &bottomEdgeOfChildren); + nscoord blockEndEdgeOfChildren; + ComputeFinalSize(*reflowState, state, aMetrics, &blockEndEdgeOfChildren); nsRect areaBounds = nsRect(0, 0, aMetrics.Width(), aMetrics.Height()); ComputeOverflowAreas(areaBounds, reflowState->mStyleDisplay, - bottomEdgeOfChildren, aMetrics.mOverflowAreas); + blockEndEdgeOfChildren, aMetrics.mOverflowAreas); // Factor overflow container child bounds into the overflow area aMetrics.mOverflowAreas.UnionWith(ocBounds); // Factor pushed float child bounds into the overflow area @@ -1258,10 +1270,10 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, absoluteContainer->MarkSizeDependentFramesDirty(); } } else { - nsSize containingBlockSize = - CalculateContainingBlockSizeForAbsolutes(*reflowState, - nsSize(aMetrics.Width(), - aMetrics.Height())); + WritingMode parentWM = aMetrics.GetWritingMode(); + LogicalSize containingBlockSize = + CalculateContainingBlockSizeForAbsolutes(parentWM, *reflowState, + aMetrics.Size(parentWM)); // Mark frames that depend on changes we just made to this frame as dirty: // Now we can assume that the padding edge hasn't moved. @@ -1269,6 +1281,9 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, // its placeholder position, or the containing block size in a // direction in which the containing block size might have // changed. + + // XXX "width" and "height" in this block will become ISize and BSize + // when nsAbsoluteContainingBlock is logicalized bool cbWidthChanged = aMetrics.Width() != oldSize.width; bool isRoot = !GetContent()->GetParent(); // If isRoot and we have auto height, then we are the initial @@ -1279,14 +1294,13 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, !(isRoot && NS_UNCONSTRAINEDSIZE == reflowState->ComputedHeight()) && aMetrics.Height() != oldSize.height; - nsRect containingBlock(nsPoint(0, 0), containingBlockSize); + nsRect containingBlock(nsPoint(0, 0), + containingBlockSize.GetPhysicalSize(parentWM)); absoluteContainer->Reflow(this, aPresContext, *reflowState, state.mReflowStatus, containingBlock, true, cbWidthChanged, cbHeightChanged, &aMetrics.mOverflowAreas); - - //XXXfr Why isn't this rv (and others in this file) checked/returned? } } @@ -1354,7 +1368,7 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, } bool -nsBlockFrame::CheckForCollapsedBottomMarginFromClearanceLine() +nsBlockFrame::CheckForCollapsedBEndMarginFromClearanceLine() { line_iterator begin = begin_lines(); line_iterator line = end_lines(); @@ -1378,91 +1392,94 @@ void nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState, nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics, - nscoord* aBottomEdgeOfChildren) + nscoord* aBEndEdgeOfChildren) { - const nsMargin& borderPadding = aState.BorderPadding(); + WritingMode wm = aState.mReflowState.GetWritingMode(); + const LogicalMargin& borderPadding = aState.BorderPadding(); #ifdef NOISY_FINAL_SIZE ListTag(stdout); - printf(": mY=%d mIsBottomMarginRoot=%s mPrevBottomMargin=%d bp=%d,%d\n", - aState.mY, aState.GetFlag(BRS_ISBOTTOMMARGINROOT) ? "yes" : "no", - aState.mPrevBottomMargin, - borderPadding.top, borderPadding.bottom); + printf(": mBCoord=%d mIsBEndMarginRoot=%s mPrevBEndMargin=%d bp=%d,%d\n", + aState.mBCoord, aState.GetFlag(BRS_ISBENDMARGINROOT) ? "yes" : "no", + aState.mPrevBEndMargin, + borderPadding.BStart(wm), borderPadding.BEnd(wm)); #endif - // Compute final width - aMetrics.Width() = - NSCoordSaturatingAdd(NSCoordSaturatingAdd(borderPadding.left, - aReflowState.ComputedWidth()), - borderPadding.right); + // Compute final inline size + LogicalSize finalSize(wm); + finalSize.ISize(wm) = + NSCoordSaturatingAdd(NSCoordSaturatingAdd(borderPadding.IStart(wm), + aReflowState.ComputedISize()), + borderPadding.IEnd(wm)); // Return bottom margin information // rbs says he hit this assertion occasionally (see bug 86947), so // just set the margin to zero and we'll figure out why later //NS_ASSERTION(aMetrics.mCarriedOutBottomMargin.IsZero(), // "someone else set the margin"); - nscoord nonCarriedOutVerticalMargin = 0; - if (!aState.GetFlag(BRS_ISBOTTOMMARGINROOT)) { + nscoord nonCarriedOutBDirMargin = 0; + if (!aState.GetFlag(BRS_ISBENDMARGINROOT)) { // Apply rule from CSS 2.1 section 8.3.1. If we have some empty // line with clearance and a non-zero top margin and all // subsequent lines are empty, then we do not allow our children's // carried out bottom margin to be carried out of us and collapse // with our own bottom margin. - if (CheckForCollapsedBottomMarginFromClearanceLine()) { + if (CheckForCollapsedBEndMarginFromClearanceLine()) { // Convert the children's carried out margin to something that // we will include in our height - nonCarriedOutVerticalMargin = aState.mPrevBottomMargin.get(); - aState.mPrevBottomMargin.Zero(); + nonCarriedOutBDirMargin = aState.mPrevBEndMargin.get(); + aState.mPrevBEndMargin.Zero(); } - aMetrics.mCarriedOutBottomMargin = aState.mPrevBottomMargin; + aMetrics.mCarriedOutBottomMargin = aState.mPrevBEndMargin; } else { aMetrics.mCarriedOutBottomMargin.Zero(); } - nscoord bottomEdgeOfChildren = aState.mY + nonCarriedOutVerticalMargin; + nscoord blockEndEdgeOfChildren = aState.mBCoord + nonCarriedOutBDirMargin; // Shrink wrap our height around our contents. - if (aState.GetFlag(BRS_ISBOTTOMMARGINROOT) || - NS_UNCONSTRAINEDSIZE != aReflowState.ComputedHeight()) { + if (aState.GetFlag(BRS_ISBENDMARGINROOT) || + NS_UNCONSTRAINEDSIZE != aReflowState.ComputedBSize()) { // When we are a bottom-margin root make sure that our last // childs bottom margin is fully applied. We also do this when // we have a computed height, since in that case the carried out // margin is not going to be applied anywhere, so we should note it // here to be included in the overflow area. // Apply the margin only if there's space for it. - if (bottomEdgeOfChildren < aState.mReflowState.AvailableHeight()) + if (blockEndEdgeOfChildren < aState.mReflowState.AvailableBSize()) { // Truncate bottom margin if it doesn't fit to our available height. - bottomEdgeOfChildren = - std::min(bottomEdgeOfChildren + aState.mPrevBottomMargin.get(), - aState.mReflowState.AvailableHeight()); + blockEndEdgeOfChildren = + std::min(blockEndEdgeOfChildren + aState.mPrevBEndMargin.get(), + aState.mReflowState.AvailableBSize()); } } if (aState.GetFlag(BRS_FLOAT_MGR)) { // Include the float manager's state to properly account for the // bottom margin of any floated elements; e.g., inside a table cell. nscoord floatHeight = - aState.ClearFloats(bottomEdgeOfChildren, NS_STYLE_CLEAR_BOTH, + aState.ClearFloats(blockEndEdgeOfChildren, NS_STYLE_CLEAR_BOTH, nullptr, nsFloatManager::DONT_CLEAR_PUSHED_FLOATS); - bottomEdgeOfChildren = std::max(bottomEdgeOfChildren, floatHeight); + blockEndEdgeOfChildren = std::max(blockEndEdgeOfChildren, floatHeight); } - if (NS_UNCONSTRAINEDSIZE != aReflowState.ComputedHeight() + if (NS_UNCONSTRAINEDSIZE != aReflowState.ComputedBSize() && (GetParent()->GetType() != nsGkAtoms::columnSetFrame || - aReflowState.parentReflowState->AvailableHeight() == NS_UNCONSTRAINEDSIZE)) { - ComputeFinalHeight(aReflowState, &aState.mReflowStatus, - aState.mY + nonCarriedOutVerticalMargin, - borderPadding, aMetrics, aState.mConsumedHeight); + aReflowState.parentReflowState->AvailableBSize() == NS_UNCONSTRAINEDSIZE)) { + ComputeFinalBSize(aReflowState, &aState.mReflowStatus, + aState.mBCoord + nonCarriedOutBDirMargin, + borderPadding, finalSize, aState.mConsumedBSize); if (!NS_FRAME_IS_COMPLETE(aState.mReflowStatus)) { // Use the current height; continuations will take up the rest. // Do extend the height to at least consume the available // height, otherwise our left/right borders (for example) won't // extend all the way to the break. - aMetrics.Height() = std::max(aReflowState.AvailableHeight(), - aState.mY + nonCarriedOutVerticalMargin); - // ... but don't take up more height than is available - nscoord effectiveComputedHeight = - GetEffectiveComputedHeight(aReflowState, aState.GetConsumedHeight()); - aMetrics.Height() = std::min(aMetrics.Height(), - borderPadding.top + effectiveComputedHeight); + finalSize.BSize(wm) = std::max(aReflowState.AvailableBSize(), + aState.mBCoord + nonCarriedOutBDirMargin); + // ... but don't take up more block size than is available + nscoord effectiveComputedBSize = + GetEffectiveComputedBSize(aReflowState, aState.GetConsumedBSize()); + finalSize.BSize(wm) = + std::min(finalSize.BSize(wm), + borderPadding.BStart(wm) + effectiveComputedBSize); // XXX It's pretty wrong that our bottom border still gets drawn on // on its own on the last-in-flow, even if we ran out of height // here. We need GetSkipSides to check whether we ran out of content @@ -1473,45 +1490,49 @@ nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState, aMetrics.mCarriedOutBottomMargin.Zero(); } else if (NS_FRAME_IS_COMPLETE(aState.mReflowStatus)) { - nscoord contentHeight = bottomEdgeOfChildren - borderPadding.top; - nscoord autoHeight = aReflowState.ApplyMinMaxHeight(contentHeight); - if (autoHeight != contentHeight) { + nscoord contentBSize = blockEndEdgeOfChildren - borderPadding.BStart(wm); + nscoord autoBSize = aReflowState.ApplyMinMaxHeight(contentBSize); + if (autoBSize != contentBSize) { // Our min-height or max-height made our height change. Don't carry out // our kids' bottom margins. aMetrics.mCarriedOutBottomMargin.Zero(); } - autoHeight += borderPadding.top + borderPadding.bottom; - aMetrics.Height() = autoHeight; + autoBSize += borderPadding.BStart(wm) + borderPadding.BEnd(wm); + finalSize.BSize(wm) = autoBSize; } else { - NS_ASSERTION(aReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE, - "Shouldn't be incomplete if availableHeight is UNCONSTRAINED."); - aMetrics.Height() = std::max(aState.mY, aReflowState.AvailableHeight()); - if (aReflowState.AvailableHeight() == NS_UNCONSTRAINEDSIZE) + NS_ASSERTION(aReflowState.AvailableBSize() != NS_UNCONSTRAINEDSIZE, + "Shouldn't be incomplete if availableBSize is UNCONSTRAINED."); + finalSize.BSize(wm) = std::max(aState.mBCoord, + aReflowState.AvailableBSize()); + if (aReflowState.AvailableBSize() == NS_UNCONSTRAINEDSIZE) // This should never happen, but it does. See bug 414255 - aMetrics.Height() = aState.mY; + finalSize.BSize(wm) = aState.mBCoord; } if (IS_TRUE_OVERFLOW_CONTAINER(this) && NS_FRAME_IS_NOT_COMPLETE(aState.mReflowStatus)) { // Overflow containers can only be overflow complete. // Note that auto height overflow containers have no normal children - NS_ASSERTION(aMetrics.Height() == 0, "overflow containers must be zero-height"); + NS_ASSERTION(finalSize.BSize(wm) == 0, + "overflow containers must be zero-block-size"); NS_FRAME_SET_OVERFLOW_INCOMPLETE(aState.mReflowStatus); } - // Screen out negative heights --- can happen due to integer overflows :-( - aMetrics.Height() = std::max(0, aMetrics.Height()); - *aBottomEdgeOfChildren = bottomEdgeOfChildren; + // Screen out negative block sizes --- can happen due to integer overflows :-( + finalSize.BSize(wm) = std::max(0, finalSize.BSize(wm)); + *aBEndEdgeOfChildren = blockEndEdgeOfChildren; FrameProperties properties = Properties(); - if (bottomEdgeOfChildren != aMetrics.Height() - borderPadding.bottom) { + if (blockEndEdgeOfChildren != finalSize.BSize(wm) - borderPadding.BEnd(wm)) { properties.Set(BottomEdgeOfChildrenProperty(), - NS_INT32_TO_PTR(bottomEdgeOfChildren)); + NS_INT32_TO_PTR(blockEndEdgeOfChildren)); } else { properties.Delete(BottomEdgeOfChildrenProperty()); } + aMetrics.SetSize(wm, finalSize); + #ifdef DEBUG_blocks if (CRAZY_SIZE(aMetrics.Width()) || CRAZY_SIZE(aMetrics.Height())) { ListTag(stdout); @@ -1714,17 +1735,19 @@ nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState) if (!tryAndSkipLines) { IndentBy(stdout, gNoiseIndent); ListTag(stdout); - printf(": marking all lines dirty: availWidth=%d\n", - aState.mReflowState.AvailableWidth()); + printf(": marking all lines dirty: availISize=%d\n", + aState.mReflowState.AvailableISize()); } } #endif if (tryAndSkipLines) { - nscoord newAvailWidth = aState.mReflowState.ComputedPhysicalBorderPadding().left + - aState.mReflowState.ComputedWidth(); - NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aState.mReflowState.ComputedPhysicalBorderPadding().left && - NS_UNCONSTRAINEDSIZE != aState.mReflowState.ComputedWidth(), + WritingMode wm = aState.mReflowState.GetWritingMode(); + nscoord newAvailISize = + aState.mReflowState.ComputedLogicalBorderPadding().IStart(wm) + + aState.mReflowState.ComputedISize(); + NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aState.mReflowState.ComputedLogicalBorderPadding().IStart(wm) && + NS_UNCONSTRAINEDSIZE != aState.mReflowState.ComputedISize(), "math on NS_UNCONSTRAINEDSIZE"); #ifdef DEBUG @@ -1748,7 +1771,7 @@ nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState) ((isLastLine || !line->IsLineWrapped())) || line->ResizeReflowOptimizationDisabled() || line->IsImpactedByFloat() || - (line->IEnd() > newAvailWidth)) { + (line->IEnd() > newAvailISize)) { line->MarkDirty(); } @@ -1842,9 +1865,9 @@ nsBlockFrame::PropagateFloatDamage(nsBlockReflowState& aState, } else { bool wasImpactedByFloat = aLine->IsImpactedByFloat(); nsFlowAreaRect floatAvailableSpace = - aState.GetFloatAvailableSpaceForHeight(aLine->BStart() + aDeltaY, - aLine->BSize(), - nullptr); + aState.GetFloatAvailableSpaceForBSize(aLine->BStart() + aDeltaY, + aLine->BSize(), + nullptr); #ifdef REALLY_NOISY_REFLOW printf("nsBlockFrame::PropagateFloatDamage %p was = %d, is=%d\n", @@ -1895,14 +1918,14 @@ static void DumpLine(const nsBlockReflowState& aState, nsLineBox* aLine, nsRect ovis(aLine->GetVisualOverflowArea()); nsRect oscr(aLine->GetScrollableOverflowArea()); nsBlockFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent + aDeltaIndent); - printf("line=%p mY=%d dirty=%s oldBounds={%d,%d,%d,%d} oldoverflow-vis={%d,%d,%d,%d} oldoverflow-scr={%d,%d,%d,%d} deltaY=%d mPrevBottomMargin=%d childCount=%d\n", - static_cast(aLine), aState.mY, + printf("line=%p mBCoord=%d dirty=%s oldBounds={%d,%d,%d,%d} oldoverflow-vis={%d,%d,%d,%d} oldoverflow-scr={%d,%d,%d,%d} deltaBCoord=%d mPrevBEndMargin=%d childCount=%d\n", + static_cast(aLine), aState.mBCoord, aLine->IsDirty() ? "yes" : "no", aLine->IStart(), aLine->BStart(), aLine->ISize(), aLine->BSize(), ovis.x, ovis.y, ovis.width, ovis.height, oscr.x, oscr.y, oscr.width, oscr.height, - aDeltaY, aState.mPrevBottomMargin.get(), aLine->GetChildCount()); + aDeltaY, aState.mPrevBEndMargin.get(), aLine->GetChildCount()); } #endif } @@ -1920,7 +1943,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) IndentBy(stdout, gNoiseIndent); ListTag(stdout); printf(": reflowing dirty lines"); - printf(" computedWidth=%d\n", aState.mReflowState.ComputedWidth()); + printf(" computedISize=%d\n", aState.mReflowState.ComputedISize()); } AutoNoisyIndenter indent(gNoisyReflow); #endif @@ -1929,10 +1952,11 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) (aState.mReflowState.mFlags.mVResize && (GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT)); - // Reflow our last line if our availableHeight has increased + // Reflow our last line if our availableBSize has increased // so that we (and our last child) pull up content as necessary - if (aState.mReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE - && GetNextInFlow() && aState.mReflowState.AvailableHeight() > mRect.height) { + if (aState.mReflowState.AvailableBSize() != NS_UNCONSTRAINEDSIZE + && GetNextInFlow() && aState.mReflowState.AvailableBSize() > + GetLogicalSize().BSize(aState.mReflowState.GetWritingMode())) { line_iterator lastLine = end_lines(); if (lastLine != begin_lines()) { --lastLine; @@ -1941,7 +1965,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) } // the amount by which we will slide the current line if it is not // dirty - nscoord deltaY = 0; + nscoord deltaBCoord = 0; // whether we did NOT reflow the previous line and thus we need to // recompute the carried out margin before the line if we want to @@ -1958,7 +1982,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // Reflow the lines that are already ours for ( ; line != line_end; ++line, aState.AdvanceToNextLine()) { - DumpLine(aState, line, deltaY, 0); + DumpLine(aState, line, deltaBCoord, 0); #ifdef DEBUG AutoNoisyIndenter indent2(gNoisyReflow); #endif @@ -1985,29 +2009,29 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) if (!line->IsDirty() && (line->GetBreakTypeBefore() != NS_STYLE_CLEAR_NONE || replacedBlock)) { - nscoord curY = aState.mY; + nscoord curBCoord = aState.mBCoord; // See where we would be after applying any clearance due to // BRs. if (inlineFloatBreakType != NS_STYLE_CLEAR_NONE) { - curY = aState.ClearFloats(curY, inlineFloatBreakType); + curBCoord = aState.ClearFloats(curBCoord, inlineFloatBreakType); } - nscoord newY = - aState.ClearFloats(curY, line->GetBreakTypeBefore(), replacedBlock); - + nscoord newBCoord = + aState.ClearFloats(curBCoord, line->GetBreakTypeBefore(), replacedBlock); + if (line->HasClearance()) { // Reflow the line if it might not have clearance anymore. - if (newY == curY - // aState.mY is the clearance point which should be the + if (newBCoord == curBCoord + // aState.mBCoord is the clearance point which should be the // top border-edge of the block frame. If sliding the - // block by deltaY isn't going to put it in the predicted + // block by deltaBCoord isn't going to put it in the predicted // position, then we'd better reflow the line. - || newY != line->BStart() + deltaY) { + || newBCoord != line->BStart() + deltaBCoord) { line->MarkDirty(); } } else { // Reflow the line if the line might have clearance now. - if (curY != newY) { + if (curBCoord != newBCoord) { line->MarkDirty(); } } @@ -2015,8 +2039,8 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // We might have to reflow a line that is after a clearing BR. if (inlineFloatBreakType != NS_STYLE_CLEAR_NONE) { - aState.mY = aState.ClearFloats(aState.mY, inlineFloatBreakType); - if (aState.mY != line->BStart() + deltaY) { + aState.mBCoord = aState.ClearFloats(aState.mBCoord, inlineFloatBreakType); + if (aState.mBCoord != line->BStart() + deltaBCoord) { // SlideLine is not going to put the line where the clearance // put it. Reflow the line to be sure. line->MarkDirty(); @@ -2029,7 +2053,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // If the previous margin is dirty, reflow the current line line->MarkDirty(); line->ClearPreviousMarginDirty(); - } else if (line->BEnd() + deltaY > aState.mBottomEdge) { + } else if (line->BEnd() + deltaBCoord > aState.mBEndEdge) { // Lines that aren't dirty but get slid past our height constraint must // be reflowed. line->MarkDirty(); @@ -2040,11 +2064,11 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // to reflow any line that might have floats in it, both because the // breakpoints within those floats may have changed and because we // might have to push/pull the floats in their entirety. - // FIXME: What about a deltaY or height change that forces us to + // FIXME: What about a deltaBCoord or block-size change that forces us to // push lines? Why does that work? if (!line->IsDirty() && - aState.mReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE && - (deltaY != 0 || aState.mReflowState.mFlags.mVResize || + aState.mReflowState.AvailableBSize() != NS_UNCONSTRAINEDSIZE && + (deltaBCoord != 0 || aState.mReflowState.mFlags.mVResize || aState.mReflowState.mFlags.mMustReflowPlaceholders) && (line->IsBlock() || line->HasFloats() || line->HadFloatPushed())) { line->MarkDirty(); @@ -2053,7 +2077,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) if (!line->IsDirty()) { // See if there's any reflow damage that requires that we mark the // line dirty. - PropagateFloatDamage(aState, line, deltaY); + PropagateFloatDamage(aState, line, deltaBCoord); } // If the container width has changed reset the container width. If the @@ -2081,7 +2105,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // We need to reconstruct the bottom margin only if we didn't // reflow the previous line and we do need to reflow (or repair // the top position of) the next line. - aState.ReconstructMarginAbove(line); + aState.ReconstructMarginBefore(line); } bool reflowedPrevLine = !needToRecoverState; @@ -2097,7 +2121,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) } } - // Now repair the line and update |aState.mY| by calling + // Now repair the line and update |aState.mBCoord| by calling // |ReflowLine| or |SlideLine|. // If we're going to reflow everything again, then no need to reflow // the dirty line ... unless the line has floats, in which case we'd @@ -2114,10 +2138,10 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) line->ISize() == 0 && line->BSize() == 0; // Compute the dirty lines "before" BEnd, after factoring in - // the running deltaY value - the running value is implicit in - // aState.mY. - nscoord oldY = line->BStart(); - nscoord oldYMost = line->BEnd(); + // the running deltaBCoord value - the running value is implicit in + // aState.mBCoord. + nscoord oldB = line->BStart(); + nscoord oldBMost = line->BEnd(); NS_ASSERTION(!willReflowAgain || !line->IsBlock(), "Don't reflow blocks while willReflowAgain is true, reflow of block abs-pos children depends on this"); @@ -2139,7 +2163,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) } if (!keepGoing) { - DumpLine(aState, line, deltaY, -1); + DumpLine(aState, line, deltaBCoord, -1); if (0 == line->GetChildCount()) { DeleteLine(aState, line, line_end); } @@ -2161,7 +2185,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // bottom margin from previous lines that didn't used to reach NL // now does // 4) the line might have changed in a way that affects NL's - // ShouldApplyTopMargin decision. The three things that matter + // ShouldApplyBStartMargin decision. The three things that matter // are the line's emptiness, its adjacency to the top of the block, // and whether it has clearance (the latter only matters if the block // was and is adjacent to the top and empty). @@ -2171,24 +2195,24 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // This means the checks in 4) are redundant; if the line is empty now // we don't need to check 4), but if the line is not empty now and we're sure // it wasn't empty before, any adjacency and clearance changes are irrelevant - // to the result of nextLine->ShouldApplyTopMargin. + // to the result of nextLine->ShouldApplyBStartMargin. if (line.next() != end_lines()) { - bool maybeWasEmpty = oldY == line.next()->BStart(); + bool maybeWasEmpty = oldB == line.next()->BStart(); bool isEmpty = line->CachedIsEmpty(); if (maybeReflowingForFirstTime /*1*/ || (isEmpty || maybeWasEmpty) /*2/3/4*/) { line.next()->MarkPreviousMarginDirty(); - // since it's marked dirty, nobody will care about |deltaY| + // since it's marked dirty, nobody will care about |deltaBCoord| } } // If the line was just reflowed for the first time, then its - // old mBounds cannot be trusted so this deltaY computation is + // old mBounds cannot be trusted so this deltaBCoord computation is // bogus. But that's OK because we just did // MarkPreviousMarginDirty on the next line which will force it - // to be reflowed, so this computation of deltaY will not be + // to be reflowed, so this computation of deltaBCoord will not be // used. - deltaY = line->BEnd() - oldYMost; + deltaBCoord = line->BEnd() - oldBMost; // Now do an interrupt check. We want to do this only in the case when we // actually reflow the line, so that if we get back in here we'll get @@ -2200,10 +2224,10 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // continuations for any inlines atm), so only checking mFirstChild // is enough - lastLineMovedUp = deltaY < 0; + lastLineMovedUp = deltaBCoord < 0; - if (deltaY != 0) - SlideLine(aState, line, deltaY); + if (deltaBCoord != 0) + SlideLine(aState, line, deltaBCoord); else repositionViews = true; @@ -2219,19 +2243,19 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // block's descendant lines may have float caches containing dangling // frame pointers. Ugh! // If this line is inline, then we need to recover its state now - // to make sure that we don't forget to move its floats by deltaY. + // to make sure that we don't forget to move its floats by deltaBCoord. } else { // XXX EVIL O(N^2) EVIL - aState.RecoverStateFrom(line, deltaY); + aState.RecoverStateFrom(line, deltaBCoord); } - // Keep mY up to date in case we're propagating reflow damage + // Keep mBCoord up to date in case we're propagating reflow damage // and also because our final height may depend on it. If the - // line is inlines, then only update mY if the line is not + // line is inlines, then only update mBCoord if the line is not // empty, because that's what PlaceLine does. (Empty blocks may - // want to update mY, e.g. if they have clearance.) + // want to update mBCoord, e.g. if they have clearance.) if (line->IsBlock() || !line->CachedIsEmpty()) { - aState.mY = line->BEnd(); + aState.mBCoord = line->BEnd(); } needToRecoverState = true; @@ -2258,7 +2282,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) foundAnyClears = true; } - DumpLine(aState, line, deltaY, -1); + DumpLine(aState, line, deltaBCoord, -1); if (aState.mPresContext->HasPendingInterrupt()) { willReflowAgain = true; @@ -2275,12 +2299,12 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // Handle BR-clearance from the last line of the block if (inlineFloatBreakType != NS_STYLE_CLEAR_NONE) { - aState.mY = aState.ClearFloats(aState.mY, inlineFloatBreakType); + aState.mBCoord = aState.ClearFloats(aState.mBCoord, inlineFloatBreakType); } if (needToRecoverState) { // Is this expensive? - aState.ReconstructMarginAbove(line); + aState.ReconstructMarginBefore(line); // Update aState.mPrevChild as if we had reflowed all of the frames in // the last line. @@ -2306,7 +2330,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // -- my chain of next-in-flows either has no first line, or its first // line isn't dirty. bool heightConstrained = - aState.mReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE; + aState.mReflowState.AvailableBSize() != NS_UNCONSTRAINEDSIZE; bool skipPull = willReflowAgain && heightConstrained; if (!skipPull && heightConstrained && aState.mNextInFlow && (aState.mReflowState.mFlags.mNextInFlowUntouched && @@ -2396,7 +2420,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) // Reparent floats whose placeholders are in the line. ReparentFloats(pulledLine->mFirstChild, nextInFlow, true); - DumpLine(aState, pulledLine, deltaY, 0); + DumpLine(aState, pulledLine, deltaBCoord, 0); #ifdef DEBUG AutoNoisyIndenter indent2(gNoisyReflow); #endif @@ -2418,7 +2442,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) break; } - DumpLine(aState, line, deltaY, -1); + DumpLine(aState, line, deltaBCoord, -1); if (!keepGoing) { if (0 == line->GetChildCount()) { DeleteLine(aState, line, line_end); @@ -2451,15 +2475,15 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) if (HasOutsideBullet() && mLines.empty()) { nsHTMLReflowMetrics metrics(aState.mReflowState); nsIFrame* bullet = GetOutsideBullet(); + WritingMode wm = aState.mReflowState.GetWritingMode(); ReflowBullet(bullet, aState, metrics, aState.mReflowState.ComputedPhysicalBorderPadding().top); - NS_ASSERTION(!BulletIsEmpty() || metrics.Height() == 0, + NS_ASSERTION(!BulletIsEmpty() || metrics.BSize(wm) == 0, "empty bullet took up space"); if (!BulletIsEmpty()) { // There are no lines so we have to fake up some y motion so that // we end up with *some* height. - WritingMode wm = aState.mReflowState.GetWritingMode(); if (metrics.BlockStartAscent() == nsHTMLReflowMetrics::ASK_FOR_BASELINE) { nscoord ascent; @@ -2480,9 +2504,9 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) nsLayoutUtils::GetCenteredFontBaseline(fm, aState.mMinLineHeight); nscoord minDescent = aState.mMinLineHeight - minAscent; - aState.mY += std::max(minAscent, metrics.BlockStartAscent()) + - std::max(minDescent, metrics.BSize(wm) - - metrics.BlockStartAscent()); + aState.mBCoord += std::max(minAscent, metrics.BlockStartAscent()) + + std::max(minDescent, metrics.BSize(wm) - + metrics.BlockStartAscent()); nscoord offset = minAscent - metrics.BlockStartAscent(); if (offset > 0) { @@ -2863,10 +2887,10 @@ nsBlockFrame::IsEmpty() } bool -nsBlockFrame::ShouldApplyTopMargin(nsBlockReflowState& aState, +nsBlockFrame::ShouldApplyBStartMargin(nsBlockReflowState& aState, nsLineBox* aLine) { - if (aState.GetFlag(BRS_APPLYTOPMARGIN)) { + if (aState.GetFlag(BRS_APPLYBSTARTMARGIN)) { // Apply short-circuit check to avoid searching the line list return true; } @@ -2875,7 +2899,7 @@ nsBlockFrame::ShouldApplyTopMargin(nsBlockReflowState& aState, // If we aren't at the top Y coordinate then something of non-zero // height must have been placed. Therefore the childs top-margin // applies. - aState.SetFlag(BRS_APPLYTOPMARGIN, true); + aState.SetFlag(BRS_APPLYBSTARTMARGIN, true); return true; } @@ -2888,7 +2912,7 @@ nsBlockFrame::ShouldApplyTopMargin(nsBlockReflowState& aState, if (!line->CachedIsEmpty() || line->HasClearance()) { // A line which precedes aLine is non-empty, or has clearance, // so therefore the top margin applies. - aState.SetFlag(BRS_APPLYTOPMARGIN, true); + aState.SetFlag(BRS_APPLYBSTARTMARGIN, true); return true; } // No need to apply the top margin if the line has floats. We @@ -2935,11 +2959,11 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, // reflowed is a continuation (non-null prev-in-flow) then we don't // apply its top margin because it's not significant. Otherwise, dig // deeper. - bool applyTopMargin = - !frame->GetPrevInFlow() && ShouldApplyTopMargin(aState, aLine); + bool applyBStartMargin = + !frame->GetPrevInFlow() && ShouldApplyBStartMargin(aState, aLine); - if (applyTopMargin) { - // The HasClearance setting is only valid if ShouldApplyTopMargin + if (applyBStartMargin) { + // The HasClearance setting is only valid if ShouldApplyBStartMargin // returned false (in which case the top-margin-root set our // clearance flag). Otherwise clear it now. We'll set it later on // ourselves if necessary. @@ -2958,11 +2982,11 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, // collapse and we are being speculatively reflowed assuming this // frame DID NOT need clearance, then we need to check that // assumption. - if (!treatWithClearance && !applyTopMargin && mightClearFloats && + if (!treatWithClearance && !applyBStartMargin && mightClearFloats && aState.mReflowState.mDiscoveredClearance) { - nscoord curY = aState.mY + aState.mPrevBottomMargin.get(); - nscoord clearY = aState.ClearFloats(curY, breakType, replacedBlock); - if (clearY != curY) { + nscoord curBCoord = aState.mBCoord + aState.mPrevBEndMargin.get(); + nscoord clearBCoord = aState.ClearFloats(curBCoord, breakType, replacedBlock); + if (clearBCoord != curBCoord) { // Looks like that assumption was invalid, we do need // clearance. Tell our ancestor so it can reflow again. It is // responsible for actually setting our clearance flag before @@ -2979,60 +3003,61 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, } } if (treatWithClearance) { - applyTopMargin = true; + applyBStartMargin = true; } nsIFrame* clearanceFrame = nullptr; - nscoord startingY = aState.mY; - nsCollapsingMargin incomingMargin = aState.mPrevBottomMargin; + nscoord startingBCoord = aState.mBCoord; + nsCollapsingMargin incomingMargin = aState.mPrevBEndMargin; nscoord clearance; // Save the original position of the frame so that we can reposition // its view as needed. nsPoint originalPosition = frame->GetPosition(); while (true) { clearance = 0; - nscoord topMargin = 0; + nscoord bStartMargin = 0; bool mayNeedRetry = false; bool clearedFloats = false; - if (applyTopMargin) { + if (applyBStartMargin) { // Precompute the blocks top margin value so that we can get the // correct available space (there might be a float that's - // already been placed below the aState.mPrevBottomMargin + // already been placed below the aState.mPrevBEndMargin // Setup a reflowState to get the style computed margin-top // value. We'll use a reason of `resize' so that we don't fudge // any incremental reflow state. - + // The availSpace here is irrelevant to our needs - all we want // out if this setup is the margin-top value which doesn't depend // on the childs available space. // XXX building a complete nsHTMLReflowState just to get the margin-top // seems like a waste. And we do this for almost every block! - nsSize availSpace(aState.mContentArea.width, NS_UNCONSTRAINEDSIZE); + nsSize availSpace(aState.ContentISize(), NS_UNCONSTRAINEDSIZE); nsHTMLReflowState reflowState(aState.mPresContext, aState.mReflowState, frame, availSpace); - + if (treatWithClearance) { - aState.mY += aState.mPrevBottomMargin.get(); - aState.mPrevBottomMargin.Zero(); + aState.mBCoord += aState.mPrevBEndMargin.get(); + aState.mPrevBEndMargin.Zero(); } - - // Now compute the collapsed margin-top value into aState.mPrevBottomMargin, assuming - // that all child margins collapse down to clearanceFrame. + + // Now compute the collapsed margin-block-start value into + // aState.mPrevBEndMargin, assuming that all child margins + // collapse down to clearanceFrame. nsBlockReflowContext::ComputeCollapsedBStartMargin(reflowState, - &aState.mPrevBottomMargin, + &aState.mPrevBEndMargin, clearanceFrame, &mayNeedRetry); - + // XXX optimization; we could check the collapsing children to see if they are sure // to require clearance, and so avoid retrying them - + if (clearanceFrame) { // Don't allow retries on the second pass. The clearance decisions for the // blocks whose top-margins collapse with ours are now fixed. mayNeedRetry = false; } - + if (!treatWithClearance && !clearanceFrame && mightClearFloats) { // We don't know if we need clearance and this is the first, // optimistic pass. So determine whether *this block* needs @@ -3040,62 +3065,64 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, // this block has clearance to change on the second pass; that // decision is only allowed to be made under the optimistic // first pass. - nscoord curY = aState.mY + aState.mPrevBottomMargin.get(); - nscoord clearY = aState.ClearFloats(curY, breakType, replacedBlock); - if (clearY != curY) { + nscoord curBCoord = aState.mBCoord + aState.mPrevBEndMargin.get(); + nscoord clearBCoord = aState.ClearFloats(curBCoord, breakType, replacedBlock); + if (clearBCoord != curBCoord) { // Looks like we need clearance and we didn't know about it already. So // recompute collapsed margin treatWithClearance = true; // Remember this decision, needed for incremental reflow aLine->SetHasClearance(); - + // Apply incoming margins - aState.mY += aState.mPrevBottomMargin.get(); - aState.mPrevBottomMargin.Zero(); - + aState.mBCoord += aState.mPrevBEndMargin.get(); + aState.mPrevBEndMargin.Zero(); + // Compute the collapsed margin again, ignoring the incoming margin this time mayNeedRetry = false; nsBlockReflowContext::ComputeCollapsedBStartMargin(reflowState, - &aState.mPrevBottomMargin, + &aState.mPrevBEndMargin, clearanceFrame, &mayNeedRetry); } } - + // Temporarily advance the running Y value so that the // GetAvailableSpace method will return the right available // space. This undone as soon as the horizontal margins are // computed. - topMargin = aState.mPrevBottomMargin.get(); - + bStartMargin = aState.mPrevBEndMargin.get(); + if (treatWithClearance) { - nscoord currentY = aState.mY; - // advance mY to the clear position. - aState.mY = aState.ClearFloats(aState.mY, breakType, replacedBlock); + nscoord currentBCoord = aState.mBCoord; + // advance mBCoord to the clear position. + aState.mBCoord = aState.ClearFloats(aState.mBCoord, breakType, + replacedBlock); - clearedFloats = aState.mY != currentY; + clearedFloats = aState.mBCoord != currentBCoord; - // Compute clearance. It's the amount we need to add to the top + // Compute clearance. It's the amount we need to add to the block-start // border-edge of the frame, after applying collapsed margins // from the frame and its children, to get it to line up with - // the bottom of the floats. The former is currentY + topMargin, - // the latter is the current aState.mY. + // the block-end of the floats. The former is + // currentBCoord + bStartMargin, the latter is the current + // aState.mBCoord. // Note that negative clearance is possible - clearance = aState.mY - (currentY + topMargin); - + clearance = aState.mBCoord - (currentBCoord + bStartMargin); + // Add clearance to our top margin while we compute available // space for the frame - topMargin += clearance; - - // Note that aState.mY should stay where it is: at the top + bStartMargin += clearance; + + // Note that aState.mBCoord should stay where it is: at the block-start // border-edge of the frame } else { - // Advance aState.mY to the top border-edge of the frame. - aState.mY += topMargin; + // Advance aState.mBCoord to the block-start border-edge of the frame. + aState.mBCoord += bStartMargin; } } - - // Here aState.mY is the top border-edge of the block. + + // Here aState.mBCoord is the block-start border-edge of the block. // Compute the available space for the block nsFlowAreaRect floatAvailableSpace = aState.GetFloatAvailableSpace(); #ifdef REALLY_NOISY_REFLOW @@ -3121,11 +3148,11 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, // won't, and will thus make their parent overly-large and force // *it* to be pushed in its entirety.) // Doing this means that we also don't need to worry about the - // |availSpace.height += topMargin| below interacting with pushed + // |availSpace.height += bStartMargin| below interacting with pushed // floats (which force nscoord_MAX clearance) to cause a // constrained height to turn into an unconstrained one. - aState.mY = startingY; - aState.mPrevBottomMargin = incomingMargin; + aState.mBCoord = startingBCoord; + aState.mPrevBEndMargin = incomingMargin; *aKeepReflowGoing = false; if (ShouldAvoidBreakInside(aState.mReflowState)) { aState.mReflowStatus = NS_INLINE_LINE_BREAK_BEFORE(); @@ -3138,36 +3165,36 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, // Now put the Y coordinate back to the top of the top-margin + // clearance, and flow the block. - aState.mY -= topMargin; - availSpace.y -= topMargin; + aState.mBCoord -= bStartMargin; + availSpace.y -= bStartMargin; if (NS_UNCONSTRAINEDSIZE != availSpace.height) { - availSpace.height += topMargin; + availSpace.height += bStartMargin; } - + // Reflow the block into the available space - // construct the html reflow state for the block. ReflowBlock + // construct the html reflow state for the block. ReflowBlock // will initialize it - nsHTMLReflowState blockHtmlRS(aState.mPresContext, aState.mReflowState, frame, + nsHTMLReflowState blockHtmlRS(aState.mPresContext, aState.mReflowState, frame, availSpace.Size()); blockHtmlRS.mFlags.mHasClearance = aLine->HasClearance(); - + nsFloatManager::SavedState floatManagerState; if (mayNeedRetry) { blockHtmlRS.mDiscoveredClearance = &clearanceFrame; aState.mFloatManager->PushState(&floatManagerState); - } else if (!applyTopMargin) { + } else if (!applyBStartMargin) { blockHtmlRS.mDiscoveredClearance = aState.mReflowState.mDiscoveredClearance; } - + nsReflowStatus frameReflowStatus = NS_FRAME_COMPLETE; - brc.ReflowBlock(availSpace, applyTopMargin, aState.mPrevBottomMargin, - clearance, aState.IsAdjacentWithTop(), - aLine.get(), blockHtmlRS, frameReflowStatus, aState); - + brc.ReflowBlock(availSpace, applyBStartMargin, aState.mPrevBEndMargin, + clearance, aState.IsAdjacentWithTop(), + aLine.get(), blockHtmlRS, frameReflowStatus, aState); + if (mayNeedRetry && clearanceFrame) { aState.mFloatManager->PopState(&floatManagerState); - aState.mY = startingY; - aState.mPrevBottomMargin = incomingMargin; + aState.mBCoord = startingBCoord; + aState.mPrevBEndMargin = incomingMargin; continue; } @@ -3209,10 +3236,10 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, // isImpacted doesn't include impact from the block's own floats. bool forceFit = aState.IsAdjacentWithTop() && clearance <= 0 && !floatAvailableSpace.mHasFloats; - nsCollapsingMargin collapsedBottomMargin; + nsCollapsingMargin collapsedBEndMargin; nsOverflowAreas overflowAreas; *aKeepReflowGoing = brc.PlaceBlock(blockHtmlRS, forceFit, aLine.get(), - collapsedBottomMargin, + collapsedBEndMargin, overflowAreas, frameReflowStatus); if (!NS_FRAME_IS_FULLY_COMPLETE(frameReflowStatus) && @@ -3220,7 +3247,7 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, *aKeepReflowGoing = false; } - if (aLine->SetCarriedOutBottomMargin(collapsedBottomMargin)) { + if (aLine->SetCarriedOutBEndMargin(collapsedBEndMargin)) { line_iterator nextLine = aLine; ++nextLine; if (nextLine != end_lines()) { @@ -3233,8 +3260,9 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, // Some of the child block fit // Advance to new Y position - nscoord newY = aLine->BEnd(); - aState.mY = newY; + nscoord newBCoord = aLine->BEnd(); + aState.mBCoord = newBCoord; + // Continue the block frame now if it didn't completely fit in // the available space. @@ -3307,10 +3335,10 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, ListTag(stdout); printf(": reflow incomplete, frame="); nsFrame::ListTag(stdout, frame); - printf(" prevBottomMargin=%d, setting to zero\n", - aState.mPrevBottomMargin); + printf(" prevBEndMargin=%d, setting to zero\n", + aState.mPrevBEndMargin); #endif - aState.mPrevBottomMargin.Zero(); + aState.mPrevBEndMargin.Zero(); } else { // frame is complete but its overflow is not complete // Disconnect the next-in-flow and put it in our overflow tracker @@ -3335,10 +3363,10 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, ListTag(stdout); printf(": reflow complete but overflow incomplete for "); nsFrame::ListTag(stdout, frame); - printf(" prevBottomMargin=%d collapsedBottomMargin=%d\n", - aState.mPrevBottomMargin, collapsedBottomMargin.get()); + printf(" prevBEndMargin=%d collapsedBEndMargin=%d\n", + aState.mPrevBEndMargin, collapsedBEndMargin.get()); #endif - aState.mPrevBottomMargin = collapsedBottomMargin; + aState.mPrevBEndMargin = collapsedBEndMargin; } } else { // frame is fully complete @@ -3346,18 +3374,18 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, ListTag(stdout); printf(": reflow complete for "); nsFrame::ListTag(stdout, frame); - printf(" prevBottomMargin=%d collapsedBottomMargin=%d\n", - aState.mPrevBottomMargin, collapsedBottomMargin.get()); + printf(" prevBEndMargin=%d collapsedBEndMargin=%d\n", + aState.mPrevBEndMargin, collapsedBEndMargin.get()); #endif - aState.mPrevBottomMargin = collapsedBottomMargin; + aState.mPrevBEndMargin = collapsedBEndMargin; } #ifdef NOISY_BLOCK_DIR_MARGINS ListTag(stdout); printf(": frame="); nsFrame::ListTag(stdout, frame); - printf(" carriedOutBEndMargin=%d collapsedBottomMargin=%d => %d\n", - brc.GetCarriedOutBEndMargin(), collapsedBottomMargin.get(), - aState.mPrevBottomMargin); + printf(" carriedOutBEndMargin=%d collapsedBEndMargin=%d => %d\n", + brc.GetCarriedOutBEndMargin(), collapsedBEndMargin.get(), + aState.mPrevBEndMargin); #endif } else { if ((aLine == mLines.front() && !GetPrevInFlow()) || @@ -3401,8 +3429,8 @@ nsBlockFrame::ReflowInlineFrames(nsBlockReflowState& aState, // Setup initial coordinate system for reflowing the inline frames // into. Apply a previous block frame's bottom margin first. - if (ShouldApplyTopMargin(aState, aLine)) { - aState.mY += aState.mPrevBottomMargin.get(); + if (ShouldApplyBStartMargin(aState, aLine)) { + aState.mBCoord += aState.mPrevBEndMargin.get(); } nsFlowAreaRect floatAvailableSpace = aState.GetFloatAvailableSpace(); @@ -3507,30 +3535,30 @@ nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState, this, aFloatAvailableSpace.mHasFloats); #endif - WritingMode wm = GetWritingMode(aLine->mFirstChild); - LogicalRect lineRect(wm, aFloatAvailableSpace.mRect, aState.mContainerWidth); + WritingMode lineWM = GetWritingMode(aLine->mFirstChild); + LogicalRect lineRect(lineWM, aFloatAvailableSpace.mRect, + aState.mContainerWidth); - nscoord iStart = lineRect.IStart(wm); - - nscoord availISize = lineRect.ISize(wm); + nscoord iStart = lineRect.IStart(lineWM); + nscoord availISize = lineRect.ISize(lineWM); nscoord availBSize; - if (aState.GetFlag(BRS_UNCONSTRAINEDHEIGHT)) { + if (aState.GetFlag(BRS_UNCONSTRAINEDBSIZE)) { availBSize = NS_UNCONSTRAINEDSIZE; } else { /* XXX get the height right! */ - availBSize = lineRect.BSize(wm); + availBSize = lineRect.BSize(lineWM); } // Make sure to enable resize optimization before we call BeginLineReflow // because it might get disabled there aLine->EnableResizeReflowOptimization(); - aLineLayout.BeginLineReflow(iStart, aState.mY, + aLineLayout.BeginLineReflow(iStart, aState.mBCoord, availISize, availBSize, aFloatAvailableSpace.mHasFloats, false, /*XXX isTopOfPage*/ - wm, aState.mContainerWidth); + lineWM, aState.mContainerWidth); aState.SetFlag(BRS_LINE_LAYOUT_EMPTY, false); @@ -3658,14 +3686,14 @@ nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState, // and needs to happen after the caller pops the space manager // state. aState.mFloatManager->AssertStateMatches(aFloatStateBeforeLine); - aState.mY += aFloatAvailableSpace.mRect.height; + aState.mBCoord += aFloatAvailableSpace.mRect.height; aFloatAvailableSpace = aState.GetFloatAvailableSpace(); } else { - NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aState.mReflowState.AvailableHeight(), + NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aState.mReflowState.AvailableBSize(), "We shouldn't be running out of height here"); - if (NS_UNCONSTRAINEDSIZE == aState.mReflowState.AvailableHeight()) { + if (NS_UNCONSTRAINEDSIZE == aState.mReflowState.AvailableBSize()) { // just move it down a bit to try to get out of this mess - aState.mY += 1; + aState.mBCoord += 1; // We should never hit this case if we've placed floats on the // line; if we have, then the GetFloatAvailableSpace call is wrong // and needs to happen after the caller pops the space manager @@ -3695,7 +3723,7 @@ nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState, aFloatAvailableSpace.mRect, aAvailableSpaceHeight, aKeepReflowGoing)) { lineReflowStatus = LINE_REFLOW_REDO_MORE_FLOATS; - // PlaceLine already called GetAvailableSpaceForHeight for us. + // PlaceLine already called GetAvailableSpaceForBSize for us. } } } @@ -4102,8 +4130,9 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, aLine == mLines.begin().next()))) { nsHTMLReflowMetrics metrics(aState.mReflowState); nsIFrame* bullet = GetOutsideBullet(); - ReflowBullet(bullet, aState, metrics, aState.mY); - NS_ASSERTION(!BulletIsEmpty() || metrics.Height() == 0, + ReflowBullet(bullet, aState, metrics, aState.mBCoord); + NS_ASSERTION(!BulletIsEmpty() || + metrics.BSize(aState.mReflowState.GetWritingMode()) == 0, "empty bullet took up space"); aLineLayout.AddBulletFrame(bullet, metrics); addedBullet = true; @@ -4119,10 +4148,10 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, // As we redo for floats, we can't reduce the amount of height we're // checking. aAvailableSpaceHeight = std::max(aAvailableSpaceHeight, aLine->BSize()); - aFloatAvailableSpace = - aState.GetFloatAvailableSpaceForHeight(aLine->BStart(), - aAvailableSpaceHeight, - aFloatStateBeforeLine).mRect; + aFloatAvailableSpace = + aState.GetFloatAvailableSpaceForBSize(aLine->BStart(), + aAvailableSpaceHeight, + aFloatStateBeforeLine).mRect; NS_ASSERTION(aFloatAvailableSpace.y == oldFloatAvailableSpace.y, "yikes"); // Restore the height to the position of the next band. aFloatAvailableSpace.height = oldFloatAvailableSpace.height; @@ -4187,23 +4216,23 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, // already applied to the line's starting Y coordinate. Otherwise we // leave it be so that the previous blocks bottom margin can be // collapsed with a block that follows. - nscoord newY; + nscoord newBCoord; if (!aLine->CachedIsEmpty()) { // This line has some height. Therefore the application of the // previous-bottom-margin should stick. - aState.mPrevBottomMargin.Zero(); - newY = aLine->BEnd(); + aState.mPrevBEndMargin.Zero(); + newBCoord = aLine->BEnd(); } else { - // Don't let the previous-bottom-margin value affect the newY + // Don't let the previous-bottom-margin value affect the newBCoord // coordinate (it was applied in ReflowInlineFrames speculatively) // since the line is empty. - // We already called |ShouldApplyTopMargin|, and if we applied it - // then BRS_APPLYTOPMARGIN is set. - nscoord dy = aState.GetFlag(BRS_APPLYTOPMARGIN) - ? -aState.mPrevBottomMargin.get() : 0; - newY = aState.mY + dy; + // We already called |ShouldApplyBStartMargin|, and if we applied it + // then BRS_APPLYBSTARTMARGIN is set. + nscoord dy = aState.GetFlag(BRS_APPLYBSTARTMARGIN) + ? -aState.mPrevBEndMargin.get() : 0; + newBCoord = aState.mBCoord + dy; } if (!NS_FRAME_IS_FULLY_COMPLETE(aState.mReflowStatus) && @@ -4215,8 +4244,8 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, // See if the line fit (our first line always does). if (mLines.front() != aLine && - newY > aState.mBottomEdge && - aState.mBottomEdge != NS_UNCONSTRAINEDSIZE) { + newBCoord > aState.mBEndEdge && + aState.mBEndEdge != NS_UNCONSTRAINEDSIZE) { NS_ASSERTION(aState.mCurrentLine == aLine, "oops"); if (ShouldAvoidBreakInside(aState.mReflowState)) { // All our content doesn't fit, start on the next page. @@ -4229,8 +4258,8 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, return true; } - aState.mY = newY; - + aState.mBCoord = newBCoord; + // Add the already placed current-line floats to the line aLine->AppendFloats(aState.mCurrentLineFloats); @@ -4274,7 +4303,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, // Apply break-after clearing if necessary // This must stay in sync with |ReflowDirtyLines|. if (aLine->HasFloatBreakAfter()) { - aState.mY = aState.ClearFloats(aState.mY, aLine->GetBreakTypeAfter()); + aState.mBCoord = aState.ClearFloats(aState.mBCoord, aLine->GetBreakTypeAfter()); } return true; } @@ -4387,7 +4416,7 @@ nsBlockFrame::DrainOverflowLines() if (!mLines.empty()) { // Remember to recompute the margins on the first line. This will - // also recompute the correct deltaY if necessary. + // also recompute the correct deltaBCoord if necessary. mLines.front()->MarkPreviousMarginDirty(); } // The overflow lines have already been marked dirty and their previous @@ -5686,39 +5715,42 @@ nsBlockFrame::AdjustFloatAvailableSpace(nsBlockReflowState& aState, { // Compute the available width. By default, assume the width of the // containing block. - nscoord availWidth; + nscoord availISize; const nsStyleDisplay* floatDisplay = aFloatFrame->StyleDisplay(); if (NS_STYLE_DISPLAY_TABLE != floatDisplay->mDisplay || eCompatibility_NavQuirks != aState.mPresContext->CompatibilityMode() ) { - availWidth = aState.mContentArea.width; + availISize = aState.ContentISize(); } else { // This quirk matches the one in nsBlockReflowState::FlowAndPlaceFloat // give tables only the available space // if they can shrink we may not be constrained to place // them in the next line - availWidth = aFloatAvailableSpace.width; + availISize = aFloatAvailableSpace.width; } - nscoord availHeight = NS_UNCONSTRAINEDSIZE == aState.mContentArea.height - ? NS_UNCONSTRAINEDSIZE - : std::max(0, aState.mContentArea.YMost() - aState.mY); + nscoord availBSize = NS_UNCONSTRAINEDSIZE == aState.ContentBSize() + ? NS_UNCONSTRAINEDSIZE + : std::max(0, aState.ContentBEnd() - aState.mBCoord); #ifdef DISABLE_FLOAT_BREAKING_IN_COLUMNS - if (availHeight != NS_UNCONSTRAINEDSIZE && + if (availBSize != NS_UNCONSTRAINEDSIZE && nsLayoutUtils::GetClosestFrameOfType(this, nsGkAtoms::columnSetFrame)) { - // Tell the float it has unrestricted height, so it won't break. + // Tell the float it has unrestricted block-size, so it won't break. // If the float doesn't actually fit in the column it will fail to be - // placed, and either move to the top of the next column or just + // placed, and either move to the block-start of the next column or just // overflow. - availHeight = NS_UNCONSTRAINEDSIZE; + availBSize = NS_UNCONSTRAINEDSIZE; } #endif - return nsRect(aState.mContentArea.x, - aState.mContentArea.y, - availWidth, availHeight); + WritingMode wm = aState.mReflowState.GetWritingMode(); + LogicalRect availSpace(wm, aState.ContentIStart(), aState.ContentBStart(), + availISize, availBSize); + + // for now return a physical rect + return availSpace.GetPhysicalRect(wm, aState.ContentISize()); } nscoord @@ -5774,7 +5806,7 @@ nsBlockFrame::ReflowFloat(nsBlockReflowState& aState, // about adjacency with the top, so it seems misleading. if (floatRS.mFlags.mIsTopOfPage && (aFloatPushedDown || - aAdjustedAvailableSpace.width != aState.mContentArea.width)) { + aAdjustedAvailableSpace.width != aState.ContentISize())) { floatRS.mFlags.mIsTopOfPage = false; } @@ -6762,7 +6794,7 @@ nsBlockFrame::ReflowBullet(nsIFrame* aBulletFrame, // Reflow the bullet now nsSize availSize; // Make up a width since it doesn't really matter (XXX). - availSize.width = aState.mContentArea.width; + availSize.width = aState.ContentISize(); availSize.height = NS_UNCONSTRAINEDSIZE; // Get the reason right. @@ -6925,24 +6957,24 @@ nsBlockFrame::CheckFloats(nsBlockReflowState& aState) } void -nsBlockFrame::IsMarginRoot(bool* aTopMarginRoot, bool* aBottomMarginRoot) +nsBlockFrame::IsMarginRoot(bool* aBStartMarginRoot, bool* aBEndMarginRoot) { if (!(GetStateBits() & NS_BLOCK_MARGIN_ROOT)) { nsIFrame* parent = GetParent(); if (!parent || parent->IsFloatContainingBlock()) { - *aTopMarginRoot = false; - *aBottomMarginRoot = false; + *aBStartMarginRoot = false; + *aBEndMarginRoot = false; return; } if (parent->GetType() == nsGkAtoms::columnSetFrame) { - *aTopMarginRoot = GetPrevInFlow() == nullptr; - *aBottomMarginRoot = GetNextInFlow() == nullptr; + *aBStartMarginRoot = GetPrevInFlow() == nullptr; + *aBEndMarginRoot = GetNextInFlow() == nullptr; return; } } - *aTopMarginRoot = true; - *aBottomMarginRoot = true; + *aBStartMarginRoot = true; + *aBEndMarginRoot = true; } /* static */ @@ -6977,13 +7009,14 @@ nsBlockFrame::WidthToClearPastFloats(nsBlockReflowState& aState, nsIFrame* aFrame) { nscoord leftOffset, rightOffset; + WritingMode wm = aState.mReflowState.GetWritingMode(); nsCSSOffsetState offsetState(aFrame, aState.mReflowState.rendContext, - aState.mContentArea.width); + aState.mContentArea.Width(wm)); ReplacedElementWidthToClear result; aState.ComputeReplacedBlockOffsetsForFloats(aFrame, aFloatAvailableSpace, leftOffset, rightOffset); - nscoord availWidth = aState.mContentArea.width - leftOffset - rightOffset; + nscoord availWidth = aState.mContentArea.Width(wm) - leftOffset - rightOffset; // We actually don't want the min width here; see bug 427782; we only // want to displace if the width won't compute to a value small enough @@ -7022,38 +7055,38 @@ nsBlockFrame::GetNearestAncestorBlock(nsIFrame* aCandidate) } void -nsBlockFrame::ComputeFinalHeight(const nsHTMLReflowState& aReflowState, - nsReflowStatus* aStatus, - nscoord aContentHeight, - const nsMargin& aBorderPadding, - nsHTMLReflowMetrics& aMetrics, - nscoord aConsumed) +nsBlockFrame::ComputeFinalBSize(const nsHTMLReflowState& aReflowState, + nsReflowStatus* aStatus, + nscoord aContentBSize, + const LogicalMargin& aBorderPadding, + LogicalSize& aFinalSize, + nscoord aConsumed) { - + WritingMode wm = aReflowState.GetWritingMode(); // Figure out how much of the computed height should be // applied to this frame. - nscoord computedHeightLeftOver = GetEffectiveComputedHeight(aReflowState, - aConsumed); + nscoord computedBSizeLeftOver = GetEffectiveComputedBSize(aReflowState, + aConsumed); NS_ASSERTION(!( IS_TRUE_OVERFLOW_CONTAINER(this) - && computedHeightLeftOver ), - "overflow container must not have computedHeightLeftOver"); + && computedBSizeLeftOver ), + "overflow container must not have computedBSizeLeftOver"); - aMetrics.Height() = - NSCoordSaturatingAdd(NSCoordSaturatingAdd(aBorderPadding.top, - computedHeightLeftOver), - aBorderPadding.bottom); + aFinalSize.BSize(wm) = + NSCoordSaturatingAdd(NSCoordSaturatingAdd(aBorderPadding.BStart(wm), + computedBSizeLeftOver), + aBorderPadding.BEnd(wm)); if (NS_FRAME_IS_NOT_COMPLETE(*aStatus) - && aMetrics.Height() < aReflowState.AvailableHeight()) { + && aFinalSize.BSize(wm) < aReflowState.AvailableBSize()) { // We ran out of height on this page but we're incomplete // Set status to complete except for overflow NS_FRAME_SET_OVERFLOW_INCOMPLETE(*aStatus); } if (NS_FRAME_IS_COMPLETE(*aStatus)) { - if (computedHeightLeftOver > 0 && - NS_UNCONSTRAINEDSIZE != aReflowState.AvailableHeight() && - aMetrics.Height() > aReflowState.AvailableHeight()) { + if (computedBSizeLeftOver > 0 && + NS_UNCONSTRAINEDSIZE != aReflowState.AvailableBSize() && + aFinalSize.BSize(wm) > aReflowState.AvailableBSize()) { if (ShouldAvoidBreakInside(aReflowState)) { *aStatus = NS_INLINE_LINE_BREAK_BEFORE(); return; @@ -7063,8 +7096,8 @@ nsBlockFrame::ComputeFinalHeight(const nsHTMLReflowState& aReflowState, // break. If our bottom border/padding straddles the break // point, then this will increase our height and push the // border/padding to the next page/column. - aMetrics.Height() = std::max(aReflowState.AvailableHeight(), - aContentHeight); + aFinalSize.BSize(wm) = std::max(aReflowState.AvailableBSize(), + aContentBSize); NS_FRAME_SET_INCOMPLETE(*aStatus); if (!GetNextInFlow()) *aStatus |= NS_FRAME_REFLOW_NEXTINFLOW; diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 2760e461d501..666069fb40b0 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -232,36 +232,34 @@ public: virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; virtual nsRect ComputeTightBounds(gfxContext* aContext) const MOZ_OVERRIDE; - + virtual nsresult GetPrefWidthTightBounds(nsRenderingContext* aContext, nscoord* aX, nscoord* aXMost) MOZ_OVERRIDE; /** - * Compute the final height of this frame. + * Compute the final block size of this frame. * * @param aReflowState Data structure passed from parent during reflow. - * @param aReflowStatus A pointed to the reflow status for when we're finished - * doing reflow. this will get set appropriately if the height causes - * us to exceed the current available (page) height. - * @param aContentHeight The height of content, precomputed outside of this - * function. The final height that is used in aMetrics will be set to - * either this or the available height, whichever is larger, in the - * case where our available height is constrained, and we overflow that - * available height. + * @param aReflowStatus A pointer to the reflow status for when we're finished + * doing reflow. this will get set appropriately if the block-size + * causes us to exceed the current available (page) block-size. + * @param aContentBSize The block-size of content, precomputed outside of this + * function. The final block-size that is used in aMetrics will be set + * to either this or the available block-size, whichever is larger, in + * the case where our available block-size is constrained, and we + * overflow that available block-size. * @param aBorderPadding The margins representing the border padding for block * frames. Can be 0. - * @param aMetrics Out parameter for final height. Taken as an - * nsHTMLReflowMetrics object so that aMetrics can be passed in - * directly during reflow. - * @param aConsumed The height already consumed by our previous-in-flows. + * @param aFinalSize Out parameter for final block-size. + * @param aConsumed The block-size already consumed by our previous-in-flows. */ - void ComputeFinalHeight(const nsHTMLReflowState& aReflowState, - nsReflowStatus* aStatus, - nscoord aContentHeight, - const nsMargin& aBorderPadding, - nsHTMLReflowMetrics& aMetrics, - nscoord aConsumed); + void ComputeFinalBSize(const nsHTMLReflowState& aReflowState, + nsReflowStatus* aStatus, + nscoord aContentBSize, + const mozilla::LogicalMargin& aBorderPadding, + mozilla::LogicalSize& aFinalSize, + nscoord aConsumed); virtual void Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, @@ -297,14 +295,14 @@ public: * line includes the margin-top of a line with clearance (in which * case we must avoid collapsing that margin with our bottom margin) */ - bool CheckForCollapsedBottomMarginFromClearanceLine(); + bool CheckForCollapsedBEndMarginFromClearanceLine(); static nsresult GetCurrentLine(nsBlockReflowState *aState, nsLineBox **aOutCurrentLine); /** * Determine if this block is a margin root at the top/bottom edges. */ - void IsMarginRoot(bool* aTopMarginRoot, bool* aBottomMarginRoot); + void IsMarginRoot(bool* aBStartMarginRoot, bool* aBEndMarginRoot); static bool BlockNeedsFloatManager(nsIFrame* aBlock); @@ -638,8 +636,8 @@ protected: //---------------------------------------- // Methods for individual frame reflow - bool ShouldApplyTopMargin(nsBlockReflowState& aState, - nsLineBox* aLine); + bool ShouldApplyBStartMargin(nsBlockReflowState& aState, + nsLineBox* aLine); void ReflowBlockFrame(nsBlockReflowState& aState, line_iterator aLine, diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index 0a6e6ff2f058..d95777181367 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -27,37 +27,41 @@ using namespace mozilla::layout; nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState, nsPresContext* aPresContext, nsBlockFrame* aFrame, - bool aTopMarginRoot, - bool aBottomMarginRoot, + bool aBStartMarginRoot, + bool aBEndMarginRoot, bool aBlockNeedsFloatManager, - nscoord aConsumedHeight) + nscoord aConsumedBSize) : mBlock(aFrame), mPresContext(aPresContext), mReflowState(aReflowState), + mContentArea(aReflowState.GetWritingMode()), mPushedFloats(nullptr), mOverflowTracker(nullptr), - mPrevBottomMargin(), + mBorderPadding(mReflowState.ComputedLogicalBorderPadding()), + mPrevBEndMargin(), mLineNumber(0), mFlags(0), mFloatBreakType(NS_STYLE_CLEAR_NONE), - mConsumedHeight(aConsumedHeight) + mConsumedBSize(aConsumedBSize) { + WritingMode wm = aReflowState.GetWritingMode(); SetFlag(BRS_ISFIRSTINFLOW, aFrame->GetPrevInFlow() == nullptr); SetFlag(BRS_ISOVERFLOWCONTAINER, IS_TRUE_OVERFLOW_CONTAINER(aFrame)); - mBorderPadding = mReflowState.ComputedPhysicalBorderPadding(); - aFrame->ApplySkipSides(mBorderPadding, &aReflowState); - mContainerWidth = aReflowState.ComputedWidth() + mBorderPadding.LeftRight(); + aFrame->ApplyLogicalSkipSides(mBorderPadding, &aReflowState); - if (aTopMarginRoot || 0 != mBorderPadding.top) { - SetFlag(BRS_ISTOPMARGINROOT, true); + // Note that mContainerWidth is the physical width! + mContainerWidth = aReflowState.ComputedWidth() + mBorderPadding.LeftRight(wm); + + if (aBStartMarginRoot || 0 != mBorderPadding.BStart(wm)) { + SetFlag(BRS_ISBSTARTMARGINROOT, true); } - if (aBottomMarginRoot || 0 != mBorderPadding.bottom) { - SetFlag(BRS_ISBOTTOMMARGINROOT, true); + if (aBEndMarginRoot || 0 != mBorderPadding.BEnd(wm)) { + SetFlag(BRS_ISBENDMARGINROOT, true); } - if (GetFlag(BRS_ISTOPMARGINROOT)) { - SetFlag(BRS_APPLYTOPMARGIN, true); + if (GetFlag(BRS_ISBSTARTMARGINROOT)) { + SetFlag(BRS_APPLYBSTARTMARGIN, true); } if (aBlockNeedsFloatManager) { SetFlag(BRS_FLOAT_MGR, true); @@ -77,11 +81,11 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState, mNextInFlow = static_cast(mBlock->GetNextInFlow()); - NS_WARN_IF_FALSE(NS_UNCONSTRAINEDSIZE != aReflowState.ComputedWidth(), + NS_WARN_IF_FALSE(NS_UNCONSTRAINEDSIZE != aReflowState.ComputedISize(), "have unconstrained width; this should only result from " "very large sizes, not attempts at intrinsic width " "calculation"); - mContentArea.width = aReflowState.ComputedWidth(); + mContentArea.ISize(wm) = aReflowState.ComputedISize(); // Compute content area height. Unlike the width, if we have a // specified style height we ignore it since extra content is @@ -89,21 +93,21 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState, // specified style height then we may end up limiting our height if // the availableHeight is constrained (this situation occurs when we // are paginated). - if (NS_UNCONSTRAINEDSIZE != aReflowState.AvailableHeight()) { + if (NS_UNCONSTRAINEDSIZE != aReflowState.AvailableBSize()) { // We are in a paginated situation. The bottom edge is just inside // the bottom border and padding. The content area height doesn't // include either border or padding edge. - mBottomEdge = aReflowState.AvailableHeight() - mBorderPadding.bottom; - mContentArea.height = std::max(0, mBottomEdge - mBorderPadding.top); + mBEndEdge = aReflowState.AvailableBSize() - mBorderPadding.BEnd(wm); + mContentArea.BSize(wm) = std::max(0, mBEndEdge - mBorderPadding.BStart(wm)); } else { // When we are not in a paginated situation then we always use // an constrained height. - SetFlag(BRS_UNCONSTRAINEDHEIGHT, true); - mContentArea.height = mBottomEdge = NS_UNCONSTRAINEDSIZE; + SetFlag(BRS_UNCONSTRAINEDBSIZE, true); + mContentArea.BSize(wm) = mBEndEdge = NS_UNCONSTRAINEDSIZE; } - mContentArea.x = mBorderPadding.left; - mY = mContentArea.y = mBorderPadding.top; + mContentArea.IStart(wm) = mBorderPadding.IStart(wm); + mBCoord = mContentArea.BStart(wm) = mBorderPadding.BStart(wm); mPrevChild = nullptr; mCurrentLine = aFrame->end_lines(); @@ -112,13 +116,13 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState, } nscoord -nsBlockReflowState::GetConsumedHeight() +nsBlockReflowState::GetConsumedBSize() { - if (mConsumedHeight == NS_INTRINSICSIZE) { - mConsumedHeight = mBlock->GetConsumedHeight(); + if (mConsumedBSize == NS_INTRINSICSIZE) { + mConsumedBSize = mBlock->GetConsumedBSize(); } - return mConsumedHeight; + return mConsumedBSize; } void @@ -127,31 +131,33 @@ nsBlockReflowState::ComputeReplacedBlockOffsetsForFloats(nsIFrame* aFrame, nscoord& aLeftResult, nscoord& aRightResult) { + nsRect contentArea = + mContentArea.GetPhysicalRect(mReflowState.GetWritingMode(), mContainerWidth); // The frame is clueless about the float manager and therefore we // only give it free space. An example is a table frame - the // tables do not flow around floats. // However, we can let its margins intersect floats. - NS_ASSERTION(aFloatAvailableSpace.x >= mContentArea.x, "bad avail space rect x"); + NS_ASSERTION(aFloatAvailableSpace.x >= contentArea.x, "bad avail space rect x"); NS_ASSERTION(aFloatAvailableSpace.width == 0 || - aFloatAvailableSpace.XMost() <= mContentArea.XMost(), + aFloatAvailableSpace.XMost() <= contentArea.XMost(), "bad avail space rect width"); nscoord leftOffset, rightOffset; - if (aFloatAvailableSpace.width == mContentArea.width) { + if (aFloatAvailableSpace.width == contentArea.width) { // We don't need to compute margins when there are no floats around. leftOffset = 0; rightOffset = 0; } else { nsMargin frameMargin; - nsCSSOffsetState os(aFrame, mReflowState.rendContext, mContentArea.width); + nsCSSOffsetState os(aFrame, mReflowState.rendContext, contentArea.width); frameMargin = os.ComputedPhysicalMargin(); - nscoord leftFloatXOffset = aFloatAvailableSpace.x - mContentArea.x; + nscoord leftFloatXOffset = aFloatAvailableSpace.x - contentArea.x; leftOffset = std::max(leftFloatXOffset, frameMargin.left) - frameMargin.left; leftOffset = std::max(leftOffset, 0); // in case of negative margin nscoord rightFloatXOffset = - mContentArea.XMost() - aFloatAvailableSpace.XMost(); + contentArea.XMost() - aFloatAvailableSpace.XMost(); rightOffset = std::max(rightFloatXOffset, frameMargin.right) - frameMargin.right; rightOffset = std::max(rightOffset, 0); // in case of negative margin @@ -174,11 +180,16 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame, printf("CBAS frame=%p has floats %d\n", aFrame, aFloatAvailableSpace.mHasFloats); #endif - aResult.y = mY; - aResult.height = GetFlag(BRS_UNCONSTRAINEDHEIGHT) + WritingMode wm = mReflowState.GetWritingMode(); + LogicalRect result(wm); + LogicalRect floatAvailSpace = LogicalRect(wm, + aFloatAvailableSpace.mRect, + mContainerWidth); //??mReflowState.AvailableWidth()); + result.BStart(wm) = mBCoord; + result.BSize(wm) = GetFlag(BRS_UNCONSTRAINEDBSIZE) ? NS_UNCONSTRAINEDSIZE - : mReflowState.AvailableHeight() - mY; - // mY might be greater than mBottomEdge if the block's top margin pushes + : mReflowState.AvailableBSize() - mBCoord; + // mBCoord might be greater than mBEndEdge if the block's top margin pushes // it off the page/column. Negative available height can confuse other code // and is nonsense in principle. @@ -207,15 +218,15 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame, case NS_STYLE_FLOAT_EDGE_CONTENT: // content and only content does runaround of floats // The child block will flow around the float. Therefore // give it all of the available space. - aResult.x = mContentArea.x; - aResult.width = mContentArea.width; + result.IStart(wm) = ContentIStart(); + result.ISize(wm) = ContentISize(); break; case NS_STYLE_FLOAT_EDGE_MARGIN: { // The child block's margins should be placed adjacent to, // but not overlap the float. - aResult.x = aFloatAvailableSpace.mRect.x; - aResult.width = aFloatAvailableSpace.mRect.width; + result.IStart(wm) = floatAvailSpace.IStart(wm); + result.ISize(wm) = floatAvailSpace.ISize(wm); } break; } @@ -224,16 +235,20 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame, // Since there are no floats present the float-edge property // doesn't matter therefore give the block element all of the // available space since it will flow around the float itself. - aResult.x = mContentArea.x; - aResult.width = mContentArea.width; + result.IStart(wm) = ContentIStart(); + result.ISize(wm) = ContentISize(); } + aResult = result.GetPhysicalRect(wm, mContainerWidth); } else { + aResult = result.GetPhysicalRect(wm, mContainerWidth); + nsRect contentArea = + mContentArea.GetPhysicalRect(wm, mContainerWidth); nscoord leftOffset, rightOffset; ComputeReplacedBlockOffsetsForFloats(aFrame, aFloatAvailableSpace.mRect, leftOffset, rightOffset); - aResult.x = mContentArea.x + leftOffset; - aResult.width = mContentArea.width - leftOffset - rightOffset; + aResult.x = contentArea.x + leftOffset; + aResult.width = contentArea.width - leftOffset - rightOffset; } #ifdef REALLY_NOISY_REFLOW @@ -243,7 +258,7 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame, nsFlowAreaRect nsBlockReflowState::GetFloatAvailableSpaceWithState( - nscoord aY, + nscoord aBCoord, nsFloatManager::SavedState *aState) const { #ifdef DEBUG @@ -254,11 +269,13 @@ nsBlockReflowState::GetFloatAvailableSpaceWithState( "bad coord system"); #endif - nscoord height = (mContentArea.height == nscoord_MAX) - ? nscoord_MAX : std::max(mContentArea.YMost() - aY, 0); + nsRect contentArea = + mContentArea.GetPhysicalRect(mReflowState.GetWritingMode(), mContainerWidth); + nscoord height = (contentArea.height == nscoord_MAX) + ? nscoord_MAX : std::max(contentArea.YMost() - aBCoord, 0); nsFlowAreaRect result = - mFloatManager->GetFlowArea(aY, nsFloatManager::BAND_FROM_POINT, - height, mContentArea, aState); + mFloatManager->GetFlowArea(aBCoord, nsFloatManager::BAND_FROM_POINT, + height, contentArea, aState); // Keep the width >= 0 for compatibility with nsSpaceManager. if (result.mRect.width < 0) result.mRect.width = 0; @@ -275,8 +292,8 @@ nsBlockReflowState::GetFloatAvailableSpaceWithState( } nsFlowAreaRect -nsBlockReflowState::GetFloatAvailableSpaceForHeight( - nscoord aY, nscoord aHeight, +nsBlockReflowState::GetFloatAvailableSpaceForBSize( + nscoord aBCoord, nscoord aBSize, nsFloatManager::SavedState *aState) const { #ifdef DEBUG @@ -286,10 +303,11 @@ nsBlockReflowState::GetFloatAvailableSpaceForHeight( NS_ASSERTION((wx == mFloatManagerX) && (wy == mFloatManagerY), "bad coord system"); #endif - + nsRect contentArea = + mContentArea.GetPhysicalRect(mReflowState.GetWritingMode(), mContainerWidth); nsFlowAreaRect result = - mFloatManager->GetFlowArea(aY, nsFloatManager::WIDTH_WITHIN_HEIGHT, - aHeight, mContentArea, aState); + mFloatManager->GetFlowArea(aBCoord, nsFloatManager::WIDTH_WITHIN_HEIGHT, + aBSize, contentArea, aState); // Keep the width >= 0 for compatibility with nsSpaceManager. if (result.mRect.width < 0) result.mRect.width = 0; @@ -314,21 +332,21 @@ nsBlockReflowState::GetFloatAvailableSpaceForHeight( * * The reconstruction involves walking backward through the line list to * find any collapsed margins preceding the line that would have been in - * the reflow state's |mPrevBottomMargin| when we reflowed that line in + * the reflow state's |mPrevBEndMargin| when we reflowed that line in * a full reflow (under the rule in CSS2 that all adjacent vertical * margins of blocks collapse). */ void -nsBlockReflowState::ReconstructMarginAbove(nsLineList::iterator aLine) +nsBlockReflowState::ReconstructMarginBefore(nsLineList::iterator aLine) { - mPrevBottomMargin.Zero(); + mPrevBEndMargin.Zero(); nsBlockFrame *block = mBlock; nsLineList::iterator firstLine = block->begin_lines(); for (;;) { --aLine; if (aLine->IsBlock()) { - mPrevBottomMargin = aLine->GetCarriedOutBottomMargin(); + mPrevBEndMargin = aLine->GetCarriedOutBEndMargin(); break; } if (!aLine->IsEmpty()) { @@ -337,8 +355,8 @@ nsBlockReflowState::ReconstructMarginAbove(nsLineList::iterator aLine) if (aLine == firstLine) { // If the top margin was carried out (and thus already applied), // set it to zero. Either way, we're done. - if (!GetFlag(BRS_ISTOPMARGINROOT)) { - mPrevBottomMargin.Zero(); + if (!GetFlag(BRS_ISBSTARTMARGINROOT)) { + mPrevBEndMargin.Zero(); } break; } @@ -374,14 +392,14 @@ nsBlockReflowState::AppendPushedFloat(nsIFrame* aFloatCont) /** * Restore information about floats into the float manager for an * incremental reflow, and simultaneously push the floats by - * |aDeltaY|, which is the amount |aLine| was pushed relative to its + * |aDeltaBCoord|, which is the amount |aLine| was pushed relative to its * parent. The recovery of state is one of the things that makes * incremental reflow O(N^2) and this state should really be kept * around, attached to the frame tree. */ void nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine, - nscoord aDeltaY) + nscoord aDeltaBCoord) { if (aLine->HasFloats()) { // Place the floats into the space-manager again. Also slide @@ -389,8 +407,8 @@ nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine, nsFloatCache* fc = aLine->GetFirstFloat(); while (fc) { nsIFrame* floatFrame = fc->mFloat; - if (aDeltaY != 0) { - floatFrame->MovePositionBy(nsPoint(0, aDeltaY)); + if (aDeltaBCoord != 0) { + floatFrame->MovePositionBy(nsPoint(0, aDeltaBCoord)); nsContainerFrame::PositionFrameView(floatFrame); nsContainerFrame::PositionChildViews(floatFrame); } @@ -403,8 +421,8 @@ nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine, tx, ty, mFloatManagerX, mFloatManagerY); nsFrame::ListTag(stdout, floatFrame); nsRect region = nsFloatManager::GetRegionFor(floatFrame); - printf(" aDeltaY=%d region={%d,%d,%d,%d}\n", - aDeltaY, region.x, region.y, region.width, region.height); + printf(" aDeltaBCoord=%d region={%d,%d,%d,%d}\n", + aDeltaBCoord, region.x, region.y, region.width, region.height); } #endif mFloatManager->AddFloat(floatFrame, @@ -421,7 +439,7 @@ nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine, * reflow so it is O(N*M) where M is the number of incremental reflow * passes. That's bad. Don't do stuff here. * - * When this function is called, |aLine| has just been slid by |aDeltaY| + * When this function is called, |aLine| has just been slid by |aDeltaBCoord| * and the purpose of RecoverStateFrom is to ensure that the * nsBlockReflowState is in the same state that it would have been in * had the line just been reflowed. @@ -430,14 +448,14 @@ nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine, */ void nsBlockReflowState::RecoverStateFrom(nsLineList::iterator aLine, - nscoord aDeltaY) + nscoord aDeltaBCoord) { // Make the line being recovered the current line mCurrentLine = aLine; // Place floats for this line into the float manager if (aLine->HasFloats() || aLine->IsBlock()) { - RecoverFloats(aLine, aDeltaY); + RecoverFloats(aLine, aDeltaBCoord); #ifdef DEBUG if (nsBlockFrame::gNoisyReflow || nsBlockFrame::gNoisyFloatManager) { @@ -521,8 +539,8 @@ nsBlockReflowState::AddFloat(nsLineLayout* aLineLayout, placed = FlowAndPlaceFloat(aFloat); if (placed) { // Pass on updated available space to the current inline reflow engine - nsFlowAreaRect floatAvailSpace = GetFloatAvailableSpace(mY); - nsRect availSpace(nsPoint(floatAvailSpace.mRect.x, mY), + nsFlowAreaRect floatAvailSpace = GetFloatAvailableSpace(mBCoord); + nsRect availSpace(nsPoint(floatAvailSpace.mRect.x, mBCoord), floatAvailSpace.mRect.Size()); aLineLayout->UpdateBand(availSpace, aFloat); // Record this float in the current-line list @@ -587,13 +605,13 @@ bool nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) { // Save away the Y coordinate before placing the float. We will - // restore mY at the end after placing the float. This is - // necessary because any adjustments to mY during the float + // restore mBCoord at the end after placing the float. This is + // necessary because any adjustments to mBCoord during the float // placement are for the float only, not for any non-floating // content. - AutoRestore restoreY(mY); + AutoRestore restoreBCoord(mBCoord); // FIXME: Should give AutoRestore a getter for the value to avoid this. - const nscoord saveY = mY; + const nscoord saveBCoord = mBCoord; // Grab the float's display information const nsStyleDisplay* floatDisplay = aFloat->StyleDisplay(); @@ -603,17 +621,17 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) // Enforce CSS2 9.5.1 rule [2], i.e., make sure that a float isn't // ``above'' another float that preceded it in the flow. - mY = std::max(mFloatManager->GetLowestFloatTop(), mY); + mBCoord = std::max(mFloatManager->GetLowestFloatTop(), mBCoord); // See if the float should clear any preceding floats... // XXX We need to mark this float somehow so that it gets reflowed // when floats are inserted before it. if (NS_STYLE_CLEAR_NONE != floatDisplay->mBreakType) { // XXXldb Does this handle vertical margins correctly? - mY = ClearFloats(mY, floatDisplay->mBreakType); + mBCoord = ClearFloats(mBCoord, floatDisplay->mBreakType); } // Get the band of available space - nsFlowAreaRect floatAvailableSpace = GetFloatAvailableSpace(mY); + nsFlowAreaRect floatAvailableSpace = GetFloatAvailableSpace(mBCoord); nsRect adjustedAvailableSpace = mBlock->AdjustFloatAvailableSpace(*this, floatAvailableSpace.mRect, aFloat); @@ -678,11 +696,11 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) if (NS_STYLE_DISPLAY_TABLE != floatDisplay->mDisplay || eCompatibility_NavQuirks != mPresContext->CompatibilityMode() ) { - mY += floatAvailableSpace.mRect.height; + mBCoord += floatAvailableSpace.mRect.height; if (adjustedAvailableSpace.height != NS_UNCONSTRAINEDSIZE) { adjustedAvailableSpace.height -= floatAvailableSpace.mRect.height; } - floatAvailableSpace = GetFloatAvailableSpace(mY); + floatAvailableSpace = GetFloatAvailableSpace(mBCoord); } else { // This quirk matches the one in nsBlockFrame::AdjustFloatAvailableSpace // IE handles float tables in a very special way @@ -720,10 +738,10 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) } // the table does not fit anymore in this line so advance to next band - mY += floatAvailableSpace.mRect.height; + mBCoord += floatAvailableSpace.mRect.height; // To match nsBlockFrame::AdjustFloatAvailableSpace, we have to // get a new width for the new band. - floatAvailableSpace = GetFloatAvailableSpace(mY); + floatAvailableSpace = GetFloatAvailableSpace(mBCoord); adjustedAvailableSpace = mBlock->AdjustFloatAvailableSpace(*this, floatAvailableSpace.mRect, aFloat); floatMarginWidth = FloatMarginWidth(mReflowState, @@ -760,12 +778,12 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) // containing block is the content edge of the block box, this // means the margin edge of the float can't be higher than the // content edge of the block that contains it.) - floatY = std::max(mY, mContentArea.y); + floatY = std::max(mBCoord, ContentBStart()); // Reflow the float after computing its vertical position so it knows // where to break. if (!isLetter) { - bool pushedDown = mY != saveY; + bool pushedDown = mBCoord != saveBCoord; mBlock->ReflowFloat(*this, adjustedAvailableSpace, aFloat, floatMargin, floatOffsets, pushedDown, reflowStatus); } @@ -781,11 +799,11 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) // Likewise, if none of the float fit, and it needs to be pushed in // its entirety to the next page (NS_FRAME_IS_TRUNCATED or // NS_INLINE_IS_BREAK_BEFORE), we need to do the same. - if ((mContentArea.height != NS_UNCONSTRAINEDSIZE && + if ((ContentBSize() != NS_UNCONSTRAINEDSIZE && adjustedAvailableSpace.height == NS_UNCONSTRAINEDSIZE && !mustPlaceFloat && aFloat->GetSize().height + floatMargin.TopBottom() > - mContentArea.YMost() - floatY) || + ContentBEnd() - floatY) || NS_FRAME_IS_TRUNCATED(reflowStatus) || NS_INLINE_IS_BREAK_BEFORE(reflowStatus)) { PushFloatPastBreak(aFloat); @@ -795,12 +813,12 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) // We can't use aFloat->ShouldAvoidBreakInside(mReflowState) here since // its mIsTopOfPage may be true even though the float isn't at the // top when floatY > 0. - if (mContentArea.height != NS_UNCONSTRAINEDSIZE && + if (ContentBSize() != NS_UNCONSTRAINEDSIZE && !mustPlaceFloat && (!mReflowState.mFlags.mIsTopOfPage || floatY > 0) && NS_STYLE_PAGE_BREAK_AVOID == aFloat->StyleDisplay()->mBreakInside && (!NS_FRAME_IS_FULLY_COMPLETE(reflowStatus) || aFloat->GetSize().height + floatMargin.TopBottom() > - mContentArea.YMost() - floatY) && + ContentBEnd() - floatY) && !aFloat->GetPrevInFlow()) { PushFloatPastBreak(aFloat); return false; @@ -834,8 +852,8 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) nsRect region = nsFloatManager::CalculateRegionFor(aFloat, floatMargin); // if the float split, then take up all of the vertical height if (NS_FRAME_IS_NOT_COMPLETE(reflowStatus) && - (NS_UNCONSTRAINEDSIZE != mContentArea.height)) { - region.height = std::max(region.height, mContentArea.height - floatY); + (NS_UNCONSTRAINEDSIZE != ContentBSize())) { + region.height = std::max(region.height, ContentBSize() - floatY); } DebugOnly rv = mFloatManager->AddFloat(aFloat, region); @@ -937,36 +955,36 @@ nsBlockReflowState::PlaceBelowCurrentLineFloats(nsFloatCacheFreeList& aList, } nscoord -nsBlockReflowState::ClearFloats(nscoord aY, uint8_t aBreakType, +nsBlockReflowState::ClearFloats(nscoord aBCoord, uint8_t aBreakType, nsIFrame *aReplacedBlock, uint32_t aFlags) { #ifdef DEBUG if (nsBlockFrame::gNoisyReflow) { nsFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent); - printf("clear floats: in: aY=%d\n", aY); + printf("clear floats: in: aBCoord=%d\n", aBCoord); } #endif #ifdef NOISY_FLOAT_CLEARING - printf("nsBlockReflowState::ClearFloats: aY=%d breakType=%d\n", - aY, aBreakType); + printf("nsBlockReflowState::ClearFloats: aBCoord=%d breakType=%d\n", + aBCoord, aBreakType); mFloatManager->List(stdout); #endif if (!mFloatManager->HasAnyFloats()) { - return aY; + return aBCoord; } - nscoord newY = aY; + nscoord newBCoord = aBCoord; if (aBreakType != NS_STYLE_CLEAR_NONE) { - newY = mFloatManager->ClearFloats(newY, aBreakType, aFlags); + newBCoord = mFloatManager->ClearFloats(newBCoord, aBreakType, aFlags); } if (aReplacedBlock) { for (;;) { - nsFlowAreaRect floatAvailableSpace = GetFloatAvailableSpace(newY); + nsFlowAreaRect floatAvailableSpace = GetFloatAvailableSpace(newBCoord); if (!floatAvailableSpace.mHasFloats) { // If there aren't any floats here, then we always fit. // We check this before calling WidthToClearPastFloats, which is @@ -976,18 +994,18 @@ nsBlockReflowState::ClearFloats(nscoord aY, uint8_t aBreakType, nsBlockFrame::ReplacedElementWidthToClear replacedWidth = nsBlockFrame::WidthToClearPastFloats(*this, floatAvailableSpace.mRect, aReplacedBlock); - if (std::max(floatAvailableSpace.mRect.x - mContentArea.x, + if (std::max(floatAvailableSpace.mRect.x - ContentIStart(), replacedWidth.marginLeft) + replacedWidth.borderBoxWidth + - std::max(mContentArea.XMost() - floatAvailableSpace.mRect.XMost(), + std::max(ContentIEnd() - floatAvailableSpace.mRect.XMost(), replacedWidth.marginRight) <= - mContentArea.width) { + ContentISize()) { break; } // See the analogous code for inlines in nsBlockFrame::DoReflowInlineFrames if (floatAvailableSpace.mRect.height > 0) { // See if there's room in the next band. - newY += floatAvailableSpace.mRect.height; + newBCoord += floatAvailableSpace.mRect.height; } else { if (mReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE) { // Stop trying to clear here; we'll just get pushed to the @@ -995,7 +1013,7 @@ nsBlockReflowState::ClearFloats(nscoord aY, uint8_t aBreakType, break; } NS_NOTREACHED("avail space rect with zero height!"); - newY += 1; + newBCoord += 1; } } } @@ -1003,10 +1021,10 @@ nsBlockReflowState::ClearFloats(nscoord aY, uint8_t aBreakType, #ifdef DEBUG if (nsBlockFrame::gNoisyReflow) { nsFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent); - printf("clear floats: out: y=%d\n", newY); + printf("clear floats: out: y=%d\n", newBCoord); } #endif - return newY; + return newBCoord; } diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index 45141ceef4ef..9f917c371227 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -17,10 +17,10 @@ class nsFrameList; class nsOverflowContinuationTracker; // block reflow state flags -#define BRS_UNCONSTRAINEDHEIGHT 0x00000001 -#define BRS_ISTOPMARGINROOT 0x00000002 // Is this frame a root for top/bottom margin collapsing? -#define BRS_ISBOTTOMMARGINROOT 0x00000004 -#define BRS_APPLYTOPMARGIN 0x00000008 // See ShouldApplyTopMargin +#define BRS_UNCONSTRAINEDBSIZE 0x00000001 +#define BRS_ISBSTARTMARGINROOT 0x00000002 // Is this frame a root for block +#define BRS_ISBENDMARGINROOT 0x00000004 // direction start/end margin collapsing? +#define BRS_APPLYBSTARTMARGIN 0x00000008 // See ShouldApplyTopMargin #define BRS_ISFIRSTINFLOW 0x00000010 // Set when mLineAdjacentToTop is valid #define BRS_HAVELINEADJACENTTOTOP 0x00000020 @@ -39,9 +39,9 @@ public: nsBlockReflowState(const nsHTMLReflowState& aReflowState, nsPresContext* aPresContext, nsBlockFrame* aFrame, - bool aTopMarginRoot, bool aBottomMarginRoot, + bool aBStartMarginRoot, bool aBEndMarginRoot, bool aBlockNeedsFloatManager, - nscoord aConsumedHeight = NS_INTRINSICSIZE); + nscoord aConsumedBSize = NS_INTRINSICSIZE); /** * Get the available reflow space (the area not occupied by floats) @@ -49,19 +49,19 @@ public: * our coordinate system, which is the content box, with (0, 0) in the * upper left. * - * Returns whether there are floats present at the given vertical - * coordinate and within the width of the content rect. + * Returns whether there are floats present at the given block-direction + * coordinate and within the inline size of the content rect. */ nsFlowAreaRect GetFloatAvailableSpace() const - { return GetFloatAvailableSpace(mY); } - nsFlowAreaRect GetFloatAvailableSpace(nscoord aY) const - { return GetFloatAvailableSpaceWithState(aY, nullptr); } + { return GetFloatAvailableSpace(mBCoord); } + nsFlowAreaRect GetFloatAvailableSpace(nscoord aBCoord) const + { return GetFloatAvailableSpaceWithState(aBCoord, nullptr); } nsFlowAreaRect - GetFloatAvailableSpaceWithState(nscoord aY, + GetFloatAvailableSpaceWithState(nscoord aBCoord, nsFloatManager::SavedState *aState) const; nsFlowAreaRect - GetFloatAvailableSpaceForHeight(nscoord aY, nscoord aHeight, - nsFloatManager::SavedState *aState) const; + GetFloatAvailableSpaceForBSize(nscoord aBCoord, nscoord aBSize, + nsFloatManager::SavedState *aState) const; /* * The following functions all return true if they were able to @@ -71,11 +71,11 @@ public: * they are not associated with a line box). */ bool AddFloat(nsLineLayout* aLineLayout, - nsIFrame* aFloat, - nscoord aAvailableWidth); + nsIFrame* aFloat, + nscoord aAvailableISize); private: - bool CanPlaceFloat(nscoord aFloatWidth, - const nsFlowAreaRect& aFloatAvailableSpace); + bool CanPlaceFloat(nscoord aFloatISize, + const nsFlowAreaRect& aFloatAvailableSpace); public: bool FlowAndPlaceFloat(nsIFrame* aFloat); private: @@ -84,40 +84,40 @@ public: void PlaceBelowCurrentLineFloats(nsFloatCacheFreeList& aFloats, nsLineBox* aLine); - // Returns the first coordinate >= aY that clears the - // floats indicated by aBreakType and has enough width between floats + // Returns the first coordinate >= aBCoord that clears the + // floats indicated by aBreakType and has enough inline size between floats // (or no floats remaining) to accomodate aReplacedBlock. - nscoord ClearFloats(nscoord aY, uint8_t aBreakType, + nscoord ClearFloats(nscoord aBCoord, uint8_t aBreakType, nsIFrame *aReplacedBlock = nullptr, uint32_t aFlags = 0); bool IsAdjacentWithTop() const { - return mY == mBorderPadding.top; + return mBCoord == mBorderPadding.BStart(mReflowState.GetWritingMode()); } /** * Return mBlock's computed physical border+padding with GetSkipSides applied. */ - const nsMargin& BorderPadding() const { + const mozilla::LogicalMargin& BorderPadding() const { return mBorderPadding; } /** - * Retrieve the height "consumed" by any previous-in-flows. + * Retrieve the block-direction size "consumed" by any previous-in-flows. */ - nscoord GetConsumedHeight(); + nscoord GetConsumedBSize(); - // Reconstruct the previous bottom margin that goes above |aLine|. - void ReconstructMarginAbove(nsLineList::iterator aLine); + // Reconstruct the previous block-end margin that goes before |aLine|. + void ReconstructMarginBefore(nsLineList::iterator aLine); // Caller must have called GetAvailableSpace for the correct position - // (which need not be the current mY). + // (which need not be the current mBCoord). void ComputeReplacedBlockOffsetsForFloats(nsIFrame* aFrame, const nsRect& aFloatAvailableSpace, nscoord& aLeftResult, nscoord& aRightResult); - // Caller must have called GetAvailableSpace for the current mY + // Caller must have called GetAvailableSpace for the current mBCoord void ComputeBlockAvailSpace(nsIFrame* aFrame, const nsStyleDisplay* aDisplay, const nsFlowAreaRect& aFloatAvailableSpace, @@ -125,10 +125,10 @@ public: nsRect& aResult); protected: - void RecoverFloats(nsLineList::iterator aLine, nscoord aDeltaY); + void RecoverFloats(nsLineList::iterator aLine, nscoord aDeltaBCoord); public: - void RecoverStateFrom(nsLineList::iterator aLine, nscoord aDeltaY); + void RecoverStateFrom(nsLineList::iterator aLine, nscoord aDeltaBCoord); void AdvanceToNextLine() { if (GetFlag(BRS_LINE_LAYOUT_EMPTY)) { @@ -168,17 +168,36 @@ public: // block, not floats inside of it. nsFloatManager::SavedState mFloatManagerStateBefore; - nscoord mBottomEdge; + nscoord mBEndEdge; // The content area to reflow child frames within. This is within - // this frame's coordinate system, which means mContentArea.x == - // BorderPadding().left and mContentArea.y == BorderPadding().top. - // The height may be NS_UNCONSTRAINEDSIZE, which indicates that there + // this frame's coordinate system and writing mode, which means + // mContentArea.IStart == BorderPadding().IStart and + // mContentArea.BStart == BorderPadding().BStart. + // The block size may be NS_UNCONSTRAINEDSIZE, which indicates that there // is no page/column boundary below (the common case). - // mContentArea.YMost() should only be called after checking that - // mContentArea.height is not NS_UNCONSTRAINEDSIZE; otherwise + // mContentArea.BEnd() should only be called after checking that + // mContentArea.BSize is not NS_UNCONSTRAINEDSIZE; otherwise // coordinate overflow may occur. - nsRect mContentArea; + mozilla::LogicalRect mContentArea; + nscoord ContentIStart() { + return mContentArea.IStart(mReflowState.GetWritingMode()); + } + nscoord ContentISize() { + return mContentArea.ISize(mReflowState.GetWritingMode()); + } + nscoord ContentIEnd() { + return mContentArea.IEnd(mReflowState.GetWritingMode()); + } + nscoord ContentBStart() { + return mContentArea.BStart(mReflowState.GetWritingMode()); + } + nscoord ContentBSize() { + return mContentArea.BSize(mReflowState.GetWritingMode()); + } + nscoord ContentBEnd() { + return mContentArea.BEnd(mReflowState.GetWritingMode()); + } nscoord mContainerWidth; // Continuation out-of-flow float frames that need to move to our @@ -210,11 +229,11 @@ public: // always before the current line. nsLineList::iterator mLineAdjacentToTop; - // The current Y coordinate in the block - nscoord mY; + // The current block-direction coordinate in the block + nscoord mBCoord; // mBlock's computed physical border+padding with GetSkipSides applied. - nsMargin mBorderPadding; + mozilla::LogicalMargin mBorderPadding; // The overflow areas of all floats placed so far nsOverflowAreas mFloatOverflowAreas; @@ -226,7 +245,7 @@ public: nsIFrame* mPrevChild; // The previous child frames collapsed bottom margin value. - nsCollapsingMargin mPrevBottomMargin; + nsCollapsingMargin mPrevBEndMargin; // The current next-in-flow for the block. When lines are pulled // from a next-in-flow, this is used to know which next-in-flow to @@ -258,8 +277,8 @@ public: uint8_t mFloatBreakType; - // The amount of computed height "consumed" by previous-in-flows. - nscoord mConsumedHeight; + // The amount of computed block-direction size "consumed" by previous-in-flows. + nscoord mConsumedBSize; void SetFlag(uint32_t aFlag, bool aValue) { diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index 6097849b1269..6cd080822b53 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -177,13 +177,13 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState, availContentWidth = aReflowState.ComputedWidth(); } - nscoord consumedHeight = GetConsumedHeight(); + nscoord consumedBSize = GetConsumedBSize(); // The effective computed height is the height of the current continuation // of the column set frame. This should be the same as the computed height // if we have an unconstrained available height. - nscoord computedHeight = GetEffectiveComputedHeight(aReflowState, - consumedHeight); + nscoord computedBSize = GetEffectiveComputedBSize(aReflowState, + consumedBSize); nscoord colHeight = GetAvailableContentHeight(aReflowState); if (aReflowState.ComputedHeight() != NS_INTRINSICSIZE) { @@ -298,7 +298,7 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState, #endif ReflowConfig config = { numColumns, colWidth, expectedWidthLeftOver, colGap, colHeight, isBalancing, knownFeasibleHeight, - knownInfeasibleHeight, computedHeight, consumedHeight }; + knownInfeasibleHeight, computedBSize, consumedBSize }; return config; } diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index adceda0068bb..2ef627f0509b 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -2748,10 +2748,10 @@ nsFlexContainerFrame::GetMainSizeFromReflowState( if (IsAxisHorizontal(aAxisTracker.GetMainAxis())) { // Horizontal case is easy -- our main size is our computed width // (which is already resolved). - return aReflowState.ComputedWidth(); + return aReflowState.ComputedISize(); } - return GetEffectiveComputedHeight(aReflowState); + return GetEffectiveComputedBSize(aReflowState); } // Returns the largest outer hypothetical main-size of any line in |aLines|. @@ -2837,20 +2837,20 @@ nsFlexContainerFrame::ComputeCrossSize(const nsHTMLReflowState& aReflowState, // Cross axis is horizontal: our cross size is our computed width // (which is already resolved). *aIsDefinite = true; - return aReflowState.ComputedWidth(); + return aReflowState.ComputedISize(); } - nscoord effectiveComputedHeight = GetEffectiveComputedHeight(aReflowState); - if (effectiveComputedHeight != NS_INTRINSICSIZE) { + nscoord effectiveComputedBSize = GetEffectiveComputedBSize(aReflowState); + if (effectiveComputedBSize != NS_INTRINSICSIZE) { // Cross-axis is vertical, and we have a fixed height: *aIsDefinite = true; if (aAvailableHeightForContent == NS_UNCONSTRAINEDSIZE || - effectiveComputedHeight < aAvailableHeightForContent) { + effectiveComputedBSize < aAvailableHeightForContent) { // Not in a fragmenting context, OR no need to fragment because we have // more available height than we need. Either way, just use our fixed // height. (Note that the reflow state has already done the appropriate // min/max-height clamping.) - return effectiveComputedHeight; + return effectiveComputedBSize; } // Fragmenting *and* our fixed height is too tall for available height: @@ -2864,7 +2864,7 @@ nsFlexContainerFrame::ComputeCrossSize(const nsHTMLReflowState& aReflowState, if (aSumLineCrossSizes <= aAvailableHeightForContent) { return aAvailableHeightForContent; } - return std::min(effectiveComputedHeight, aSumLineCrossSizes); + return std::min(effectiveComputedBSize, aSumLineCrossSizes); } // Cross axis is vertical and we have auto-height: shrink-wrap our line(s), diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index 491229d360cf..4be55af3a32e 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -55,7 +55,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, nsMargin bp = aReflowState.ComputedPhysicalBorderPadding(); ApplySkipSides(bp); - nscoord contentHeight = GetEffectiveComputedHeight(aReflowState); + nscoord contentHeight = GetEffectiveComputedBSize(aReflowState); if (contentHeight == NS_AUTOHEIGHT) { contentHeight = 0; } diff --git a/layout/generic/nsHTMLReflowMetrics.h b/layout/generic/nsHTMLReflowMetrics.h index 386a4e568a50..ceb351022f2d 100644 --- a/layout/generic/nsHTMLReflowMetrics.h +++ b/layout/generic/nsHTMLReflowMetrics.h @@ -240,6 +240,15 @@ public: return mBSize; } + // Set inline and block size from a LogicalSize, converting to our + // writing mode as necessary. + void SetSize(mozilla::WritingMode aWM, mozilla::LogicalSize aSize) + { + mozilla::LogicalSize convertedSize = aSize.ConvertTo(mWritingMode, aWM); + mBSize = convertedSize.BSize(mWritingMode); + mISize = convertedSize.ISize(mWritingMode); + } + // Width and Height are physical dimensions, independent of writing mode. // Accessing these is slightly more expensive than accessing the logical // dimensions (once vertical writing mode support is enabled); as far as diff --git a/layout/generic/nsLineBox.cpp b/layout/generic/nsLineBox.cpp index bb8eef874bcf..eb3e7ac803fe 100644 --- a/layout/generic/nsLineBox.cpp +++ b/layout/generic/nsLineBox.cpp @@ -243,8 +243,8 @@ nsLineBox::List(FILE* out, const char* aPrefix, uint32_t aFlags) const str += nsPrintfCString("line %p: count=%d state=%s ", static_cast(this), GetChildCount(), StateToString(cbuf, sizeof(cbuf))); - if (IsBlock() && !GetCarriedOutBottomMargin().IsZero()) { - str += nsPrintfCString("bm=%d ", GetCarriedOutBottomMargin().get()); + if (IsBlock() && !GetCarriedOutBEndMargin().IsZero()) { + str += nsPrintfCString("bm=%d ", GetCarriedOutBEndMargin().get()); } nsRect bounds = GetPhysicalBounds(); str += nsPrintfCString("{%d,%d,%d,%d} ", @@ -430,17 +430,17 @@ nsLineBox::RFindLineContaining(nsIFrame* aFrame, } nsCollapsingMargin -nsLineBox::GetCarriedOutBottomMargin() const +nsLineBox::GetCarriedOutBEndMargin() const { NS_ASSERTION(IsBlock(), - "GetCarriedOutBottomMargin called on non-block line."); + "GetCarriedOutBEndMargin called on non-block line."); return (IsBlock() && mBlockData) - ? mBlockData->mCarriedOutBottomMargin + ? mBlockData->mCarriedOutBEndMargin : nsCollapsingMargin(); } bool -nsLineBox::SetCarriedOutBottomMargin(nsCollapsingMargin aValue) +nsLineBox::SetCarriedOutBEndMargin(nsCollapsingMargin aValue) { bool changed = false; if (IsBlock()) { @@ -448,12 +448,12 @@ nsLineBox::SetCarriedOutBottomMargin(nsCollapsingMargin aValue) if (!mBlockData) { mBlockData = new ExtraBlockData(GetPhysicalBounds()); } - changed = aValue != mBlockData->mCarriedOutBottomMargin; - mBlockData->mCarriedOutBottomMargin = aValue; + changed = aValue != mBlockData->mCarriedOutBEndMargin; + mBlockData->mCarriedOutBEndMargin = aValue; } else if (mBlockData) { - changed = aValue != mBlockData->mCarriedOutBottomMargin; - mBlockData->mCarriedOutBottomMargin = aValue; + changed = aValue != mBlockData->mCarriedOutBEndMargin; + mBlockData->mCarriedOutBEndMargin = aValue; MaybeFreeData(); } } @@ -471,7 +471,7 @@ nsLineBox::MaybeFreeData() mInlineData = nullptr; } } - else if (mBlockData->mCarriedOutBottomMargin.IsZero()) { + else if (mBlockData->mCarriedOutBEndMargin.IsZero()) { delete mBlockData; mBlockData = nullptr; } diff --git a/layout/generic/nsLineBox.h b/layout/generic/nsLineBox.h index 5149e950e077..1f9c7b0c11e8 100644 --- a/layout/generic/nsLineBox.h +++ b/layout/generic/nsLineBox.h @@ -427,10 +427,10 @@ public: return !IsBlock() ? mFlags.mBreakType : NS_STYLE_CLEAR_NONE; } - // mCarriedOutBottomMargin value - nsCollapsingMargin GetCarriedOutBottomMargin() const; + // mCarriedOutBEndMargin value + nsCollapsingMargin GetCarriedOutBEndMargin() const; // Returns true if the margin changed - bool SetCarriedOutBottomMargin(nsCollapsingMargin aValue); + bool SetCarriedOutBEndMargin(nsCollapsingMargin aValue); // mFloats bool HasFloats() const { @@ -647,10 +647,10 @@ public: struct ExtraBlockData : public ExtraData { ExtraBlockData(const nsRect& aBounds) : ExtraData(aBounds), - mCarriedOutBottomMargin() + mCarriedOutBEndMargin() { } - nsCollapsingMargin mCarriedOutBottomMargin; + nsCollapsingMargin mCarriedOutBEndMargin; }; struct ExtraInlineData : public ExtraData { diff --git a/layout/generic/nsSplittableFrame.cpp b/layout/generic/nsSplittableFrame.cpp index 42c4b2cca520..2fc64bb3baf9 100644 --- a/layout/generic/nsSplittableFrame.cpp +++ b/layout/generic/nsSplittableFrame.cpp @@ -207,7 +207,7 @@ nsSplittableFrame::RemoveFromFlow(nsIFrame* aFrame) } nscoord -nsSplittableFrame::GetConsumedHeight() const +nsSplittableFrame::GetConsumedBSize() const { nscoord height = 0; for (nsIFrame* prev = GetPrevInFlow(); prev; prev = prev->GetPrevInFlow()) { @@ -217,22 +217,22 @@ nsSplittableFrame::GetConsumedHeight() const } nscoord -nsSplittableFrame::GetEffectiveComputedHeight(const nsHTMLReflowState& aReflowState, - nscoord aConsumedHeight) const +nsSplittableFrame::GetEffectiveComputedBSize(const nsHTMLReflowState& aReflowState, + nscoord aConsumedBSize) const { - nscoord height = aReflowState.ComputedHeight(); - if (height == NS_INTRINSICSIZE) { + nscoord bSize = aReflowState.ComputedBSize(); + if (bSize == NS_INTRINSICSIZE) { return NS_INTRINSICSIZE; } - if (aConsumedHeight == NS_INTRINSICSIZE) { - aConsumedHeight = GetConsumedHeight(); + if (aConsumedBSize == NS_INTRINSICSIZE) { + aConsumedBSize = GetConsumedBSize(); } - height -= aConsumedHeight; + bSize -= aConsumedBSize; // We may have stretched the frame beyond its computed height. Oh well. - return std::max(0, height); + return std::max(0, bSize); } int @@ -258,10 +258,10 @@ nsSplittableFrame::GetLogicalSkipSides(const nsHTMLReflowState* aReflowState) co // height, though, then we're going to need a next-in-flow, it just hasn't // been created yet. - if (NS_UNCONSTRAINEDSIZE != aReflowState->AvailableHeight()) { - nscoord effectiveCH = this->GetEffectiveComputedHeight(*aReflowState); + if (NS_UNCONSTRAINEDSIZE != aReflowState->AvailableBSize()) { + nscoord effectiveCH = this->GetEffectiveComputedBSize(*aReflowState); if (effectiveCH != NS_INTRINSICSIZE && - effectiveCH > aReflowState->AvailableHeight()) { + effectiveCH > aReflowState->AvailableBSize()) { // Our content height is going to exceed our available height, so we're // going to need a next-in-flow. skip |= LOGICAL_SIDE_B_END; diff --git a/layout/generic/nsSplittableFrame.h b/layout/generic/nsSplittableFrame.h index 7c77c8389877..227bc1d09713 100644 --- a/layout/generic/nsSplittableFrame.h +++ b/layout/generic/nsSplittableFrame.h @@ -83,14 +83,14 @@ protected: * O(N^2)! So, use this function with caution and minimize the number * of calls to this method. */ - nscoord GetConsumedHeight() const; + nscoord GetConsumedBSize() const; /** - * Retrieve the effective computed height of this frame, which is the computed - * height, minus the height consumed by any previous in-flows. + * Retrieve the effective computed block size of this frame, which is the + * computed block size, minus the block size consumed by any previous in-flows. */ - nscoord GetEffectiveComputedHeight(const nsHTMLReflowState& aReflowState, - nscoord aConsumed = NS_INTRINSICSIZE) const; + nscoord GetEffectiveComputedBSize(const nsHTMLReflowState& aReflowState, + nscoord aConsumed = NS_INTRINSICSIZE) const; /** * @see nsIFrame::GetLogicalSkipSides() diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index c20f0bb91e9d..bf38806179fa 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -2837,7 +2837,8 @@ nsTableFrame::PlaceRepeatedFooter(nsTableReflowState& aReflowState, kidAvailSize.height = aFooterHeight; nsHTMLReflowState footerReflowState(presContext, aReflowState.reflowState, - aTfoot, kidAvailSize, + aTfoot, + kidAvailSize, -1, -1, nsHTMLReflowState::CALLER_WILL_INIT); InitChildReflowState(footerReflowState);