From 9a4ba52ae3ddbc3db5e5a3bd45aaeeaad5ac7edc Mon Sep 17 00:00:00 2001 From: "dholbert%cs.stanford.edu" Date: Wed, 7 Nov 2007 11:18:30 +0000 Subject: [PATCH] Bug 398215 - Add RTL case for handling overflow width in BoxReflow. r+sr=roc, a=blocking1.9+ git-svn-id: svn://10.0.0.236/trunk@238901 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsFrame.cpp | 60 ++++++++++++++++-------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 402045e6ade..9cf3e23f836 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -6163,32 +6163,41 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState, // This kinda sucks. We should be able to handle the case // where there's overflow above or to the left of the // origin. But for now just chop that stuff off. + // (note: For RTL mode, replace "to the left of the origin" + // with "to the right of the range [0, aDesiredSize.width]") //printf("OutsideChildren width=%d, height=%d\n", aDesiredSize.mOverflowArea.width, aDesiredSize.mOverflowArea.height); - aDesiredSize.width = aDesiredSize.mOverflowArea.XMost(); - if (aDesiredSize.width <= aWidth) - aDesiredSize.height = aDesiredSize.mOverflowArea.YMost(); - else { - if (aDesiredSize.width > aWidth) - { - nscoord computedWidth = aDesiredSize.width - - reflowState.mComputedBorderPadding.LeftRight(); - computedWidth = PR_MAX(computedWidth, 0); - reflowState.SetComputedWidth(computedWidth); - reflowState.availableWidth = aDesiredSize.width; - DidReflow(aPresContext, &reflowState, NS_FRAME_REFLOW_FINISHED); - #ifdef DEBUG_REFLOW - nsAdaptorAddIndents(); - nsAdaptorPrintReason(reflowState); - printf("\n"); - #endif - AddStateBits(NS_FRAME_IS_DIRTY); - WillReflow(aPresContext); - Reflow(aPresContext, aDesiredSize, reflowState, status); - if (GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) - aDesiredSize.height = aDesiredSize.mOverflowArea.YMost(); - } + if (NS_STYLE_DIRECTION_LTR == GetStyleVisibility()->mDirection) { + // LTR mode -- extend for overflow on right side. + aDesiredSize.width = PR_MAX(aDesiredSize.width, + aDesiredSize.mOverflowArea.XMost()); + } else { + // RTL mode -- extend for overflow on left side. + nscoord leftmostValue = PR_MIN(0, aDesiredSize.mOverflowArea.x); + // Note: If anything, this increases aDesiredSize.width, because + // leftmostValue is non-positive. + aDesiredSize.width = aDesiredSize.width - leftmostValue; + } + if (aDesiredSize.width <= aWidth) { + aDesiredSize.height = aDesiredSize.mOverflowArea.YMost(); + } else { + nscoord computedWidth = aDesiredSize.width - + reflowState.mComputedBorderPadding.LeftRight(); + computedWidth = PR_MAX(computedWidth, 0); + reflowState.SetComputedWidth(computedWidth); + reflowState.availableWidth = aDesiredSize.width; + DidReflow(aPresContext, &reflowState, NS_FRAME_REFLOW_FINISHED); + #ifdef DEBUG_REFLOW + nsAdaptorAddIndents(); + nsAdaptorPrintReason(reflowState); + printf("\n"); + #endif + AddStateBits(NS_FRAME_IS_DIRTY); + WillReflow(aPresContext); + Reflow(aPresContext, aDesiredSize, reflowState, status); + if (GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) + aDesiredSize.height = aDesiredSize.mOverflowArea.YMost(); } } @@ -6199,11 +6208,6 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState, Redraw(aState, &r); } - PRBool changedSize = PR_FALSE; - - if (metrics->mLastSize.width != aDesiredSize.width || metrics->mLastSize.height != aDesiredSize.height) - changedSize = PR_TRUE; - PRUint32 layoutFlags = aState.LayoutFlags(); nsContainerFrame::FinishReflowChild(this, aPresContext, &reflowState, aDesiredSize, aX, aY, layoutFlags | NS_FRAME_NO_MOVE_FRAME);