Make mComputedWidth private, with a getter/setter, and make the setter update

the resize flags.  Bug 367442, r+sr=dbaron


git-svn-id: svn://10.0.0.236/trunk@218933 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu 2007-01-26 00:05:12 +00:00
parent 0596f16735
commit 343ced44ba
32 changed files with 124 additions and 117 deletions

View File

@ -256,22 +256,6 @@ static PRInt32 gReflowInx = -1;
#define PX(__v) __v
#endif
//------------------------------------------
// Asserts if we return a desired size that
// doesn't correctly match the mComputedWidth
//------------------------------------------
#ifdef DO_UNCONSTRAINED_CHECK
#define UNCONSTRAINED_CHECK() \
if (aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE) { \
nscoord width = aDesiredSize.width - borderPadding.left - borderPadding.right; \
if (width != aReflowState.mComputedWidth) { \
printf("aDesiredSize.width %d %d != aReflowState.mComputedWidth %d\n", aDesiredSize.width, width, aReflowState.mComputedWidth); \
} \
NS_ASSERTION(width == aReflowState.mComputedWidth, "Returning bad value when constrained!"); \
}
#else
#define UNCONSTRAINED_CHECK()
#endif
//------------------------------------------------------
//-- Done with macros
//------------------------------------------------------
@ -479,11 +463,11 @@ nsComboboxControlFrame::ReflowDropdown(nsPresContext* aPresContext,
// If the dropdown's intrinsic width is narrower than our specified width,
// then expand it out. We want our border-box width to end up the same as
// the dropdown's so account for both sets of mComputedBorderPadding.
nscoord forcedWidth = aReflowState.mComputedWidth +
nscoord forcedWidth = aReflowState.ComputedWidth() +
aReflowState.mComputedBorderPadding.LeftRight() -
kidReflowState.mComputedBorderPadding.LeftRight();
kidReflowState.mComputedWidth = PR_MAX(kidReflowState.mComputedWidth,
forcedWidth);
kidReflowState.SetComputedWidth(PR_MAX(kidReflowState.ComputedWidth(),
forcedWidth));
// ensure we start off hidden
if (GetStateBits() & NS_FRAME_FIRST_REFLOW) {
@ -670,11 +654,11 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
nsBoxLayoutState bls(GetPresContext(), aReflowState.rendContext);
nscoord buttonWidth = scrollable->GetDesiredScrollbarSizes(&bls).LeftRight();
if (buttonWidth > aReflowState.mComputedWidth) {
if (buttonWidth > aReflowState.ComputedWidth()) {
buttonWidth = 0;
}
mDisplayWidth = aReflowState.mComputedWidth - buttonWidth;
mDisplayWidth = aReflowState.ComputedWidth() - buttonWidth;
nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState,
aStatus);
@ -1125,11 +1109,12 @@ nsComboboxDisplayFrame::Reflow(nsPresContext* aPresContext,
// rows look like, for lack of anything better.
state.mComputedHeight = mComboBox->mListControlFrame->GetHeightOfARow();
}
state.mComputedWidth = mComboBox->mDisplayWidth -
state.mComputedBorderPadding.LeftRight();
if (state.mComputedWidth < 0) {
state.mComputedWidth = 0;
nscoord computedWidth = mComboBox->mDisplayWidth -
state.mComputedBorderPadding.LeftRight();
if (computedWidth < 0) {
computedWidth = 0;
}
state.SetComputedWidth(computedWidth);
return nsBlockFrame::Reflow(aPresContext, aDesiredSize, state, aStatus);
}

View File

@ -445,7 +445,7 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
DO_GLOBAL_REFLOW_COUNT("nsFieldSetFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_PRECONDITION(aReflowState.mComputedWidth != NS_INTRINSICSIZE,
NS_PRECONDITION(aReflowState.ComputedWidth() != NS_INTRINSICSIZE,
"Should have a precomputed width!");
// Initialize OUT parameter
@ -468,7 +468,7 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN)) != 0;
}
nsSize availSize(aReflowState.mComputedWidth, aReflowState.availableHeight);
nsSize availSize(aReflowState.ComputedWidth(), aReflowState.availableHeight);
NS_ASSERTION(!mContentFrame ||
GetContentMinWidth(aReflowState.rendContext) <= availSize.width,
"Bogus availSize.width; should be bigger");
@ -495,8 +495,8 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
legendAvailSize);
// always give the legend as much size as it wants
legendReflowState.mComputedWidth =
mLegendFrame->GetPrefWidth(aReflowState.rendContext);
legendReflowState.
SetComputedWidth(mLegendFrame->GetPrefWidth(aReflowState.rendContext));
legendReflowState.mComputedHeight = NS_INTRINSICSIZE;
nsHTMLReflowMetrics legendDesiredSize;
@ -583,8 +583,8 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
}
// use the computed width if the inner content does not fill it
if (aReflowState.mComputedWidth > contentRect.width) {
contentRect.width = aReflowState.mComputedWidth;
if (aReflowState.ComputedWidth() > contentRect.width) {
contentRect.width = aReflowState.ComputedWidth();
}
if (mLegendFrame) {

View File

@ -297,7 +297,7 @@ nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext,
DO_GLOBAL_REFLOW_COUNT("nsHTMLButtonControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_PRECONDITION(aReflowState.mComputedWidth != NS_INTRINSICSIZE,
NS_PRECONDITION(aReflowState.ComputedWidth() != NS_INTRINSICSIZE,
"Should have real computed width by now");
if (mState & NS_FRAME_FIRST_REFLOW) {
@ -319,7 +319,7 @@ nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext,
ReflowButtonContents(aPresContext, aDesiredSize, aReflowState, firstKid,
focusPadding, aStatus);
aDesiredSize.width = aReflowState.mComputedWidth;
aDesiredSize.width = aReflowState.ComputedWidth();
// If computed use the computed value.
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE)
@ -361,7 +361,7 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
nsMargin aFocusPadding,
nsReflowStatus& aStatus)
{
nsSize availSize(aReflowState.mComputedWidth, NS_INTRINSICSIZE);
nsSize availSize(aReflowState.ComputedWidth(), NS_INTRINSICSIZE);
// Indent the child inside us by the focus border. We must do this separate
// from the regular border.
@ -374,7 +374,7 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
// offset to allow the kid to spill left into our padding.
nscoord xoffset = aFocusPadding.left + aReflowState.mComputedBorderPadding.left;
nscoord extrawidth = DoGetMinWidth(aReflowState.rendContext, PR_FALSE) -
aReflowState.mComputedWidth;
aReflowState.ComputedWidth();
if (extrawidth > 0) {
nscoord extraleft = extrawidth / 2;
nscoord extraright = extrawidth - extraleft;

View File

@ -526,7 +526,7 @@ nsListControlFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_PRECONDITION(aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE,
NS_PRECONDITION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
"Must have a computed width");
// If all the content and frames are here

View File

@ -334,7 +334,7 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
PrettyUC(aReflowState.availableWidth, width);
PrettyUC(aReflowState.availableHeight, height);
printf(" a=%s,%s ", width, height);
PrettyUC(aReflowState.mComputedWidth, width);
PrettyUC(aReflowState.ComputedWidth(), width);
PrettyUC(aReflowState.mComputedHeight, height);
printf("c=%s,%s \n", width, height);
}
@ -347,10 +347,10 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
nscoord availWidth = aContainingBlockWidth;
if (availWidth == -1) {
NS_ASSERTION(aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE,
NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
"Must have a useful width _somewhere_");
availWidth =
aReflowState.mComputedWidth + aReflowState.mComputedPadding.LeftRight();
aReflowState.ComputedWidth() + aReflowState.mComputedPadding.LeftRight();
}
nsHTMLReflowMetrics kidDesiredSize;

View File

@ -787,9 +787,9 @@ CalculateContainingBlockSizeForAbsolutes(const nsHTMLReflowState& aReflowState,
}
// We found a reflow state for the outermost wrapping frame, so use
// its computed metrics if available
if (aLastRS->mComputedWidth != NS_UNCONSTRAINEDSIZE) {
if (aLastRS->ComputedWidth() != NS_UNCONSTRAINEDSIZE) {
cbSize.width = PR_MAX(0,
aLastRS->mComputedWidth + aLastRS->mComputedPadding.LeftRight() - scrollbars.LeftRight());
aLastRS->ComputedWidth() + aLastRS->mComputedPadding.LeftRight() - scrollbars.LeftRight());
}
if (aLastRS->mComputedHeight != NS_UNCONSTRAINEDSIZE) {
cbSize.height = PR_MAX(0,
@ -815,7 +815,7 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
ListTag(stdout);
printf(": begin reflow availSize=%d,%d computedSize=%d,%d\n",
aReflowState.availableWidth, aReflowState.availableHeight,
aReflowState.mComputedWidth, aReflowState.mComputedHeight);
aReflowState.ComputedWidth(), aReflowState.mComputedHeight);
}
AutoNoisyIndenter indent(gNoisy);
PRTime start = LL_ZERO; // Initialize these variablies to silence the compiler.
@ -1230,7 +1230,7 @@ nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState,
#endif
// Compute final width
aMetrics.width = borderPadding.left + aReflowState.mComputedWidth +
aMetrics.width = borderPadding.left + aReflowState.ComputedWidth() +
borderPadding.right;
// Return bottom margin information
@ -1453,9 +1453,9 @@ nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState)
if (tryAndSkipLines) {
nscoord newAvailWidth = aState.mReflowState.mComputedBorderPadding.left +
aState.mReflowState.mComputedWidth;
aState.mReflowState.ComputedWidth();
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedBorderPadding.left &&
NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedWidth,
NS_UNCONSTRAINEDSIZE != aState.mReflowState.ComputedWidth(),
"math on NS_UNCONSTRAINEDSIZE");
#ifdef DEBUG
@ -1673,7 +1673,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
IndentBy(stdout, gNoiseIndent);
ListTag(stdout);
printf(": reflowing dirty lines");
printf(" computedWidth=%d\n", aState.mReflowState.mComputedWidth);
printf(" computedWidth=%d\n", aState.mReflowState.ComputedWidth());
}
AutoNoisyIndenter indent(gNoisyReflow);
#endif
@ -6180,7 +6180,7 @@ nsBlockFrame::ReflowBullet(nsBlockReflowState& aState,
// Reflow the bullet now
nsSize availSize;
// Make up a width since it doesn't really matter (XXX).
availSize.width = rs.mComputedWidth;
availSize.width = rs.ComputedWidth();
availSize.height = NS_UNCONSTRAINEDSIZE;
// Get the reason right.

View File

@ -175,14 +175,14 @@ nsBlockReflowContext::ComputeCollapsedTopMargin(const nsHTMLReflowState& aRS,
if (frame != aRS.frame) {
NS_ASSERTION(frame->GetParent() == aRS.frame,
"Can only drill through one level of block wrapper");
nsSize availSpace(aRS.mComputedWidth, aRS.mComputedHeight);
nsSize availSpace(aRS.ComputedWidth(), aRS.mComputedHeight);
outerReflowState = new nsHTMLReflowState(prescontext,
aRS, frame, availSpace);
if (!outerReflowState)
goto done;
}
{
nsSize availSpace(outerReflowState->mComputedWidth,
nsSize availSpace(outerReflowState->ComputedWidth(),
outerReflowState->mComputedHeight);
nsHTMLReflowState innerReflowState(prescontext,
*outerReflowState, kid,
@ -281,7 +281,7 @@ nsBlockReflowContext::ReflowBlock(const nsRect& aSpace,
if (!aIsAdjacentWithTop) {
aFrameRS.mFlags.mIsTopOfPage = PR_FALSE; // make sure this is cleared
}
mComputedWidth = aFrameRS.mComputedWidth;
mComputedWidth = aFrameRS.ComputedWidth();
if (aApplyTopMargin) {
mTopMargin = aPrevMargin;
@ -315,11 +315,11 @@ nsBlockReflowContext::ReflowBlock(const nsRect& aSpace,
if (NS_STYLE_FLOAT_RIGHT == aFrameRS.mStyleDisplay->mFloats) {
nscoord frameWidth;
if (NS_UNCONSTRAINEDSIZE == aFrameRS.mComputedWidth) {
if (NS_UNCONSTRAINEDSIZE == aFrameRS.ComputedWidth()) {
// Use the current frame width
frameWidth = mFrame->GetSize().width;
} else {
frameWidth = aFrameRS.mComputedWidth +
frameWidth = aFrameRS.ComputedWidth() +
aFrameRS.mComputedBorderPadding.left +
aFrameRS.mComputedBorderPadding.right;
}

View File

@ -102,9 +102,9 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState,
mPresContext = aPresContext;
mNextInFlow = NS_STATIC_CAST(nsBlockFrame*, mBlock->GetNextInFlow());
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth,
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aReflowState.ComputedWidth(),
"no unconstrained widths should be present anymore");
mContentArea.width = aReflowState.mComputedWidth;
mContentArea.width = aReflowState.ComputedWidth();
// Compute content area height. Unlike the width, if we have a
// specified style height we ignore it since extra content is

View File

@ -201,8 +201,8 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState)
{
const nsStyleColumn* colStyle = GetStyleColumn();
nscoord availContentWidth = GetAvailableContentWidth(aReflowState);
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE) {
availContentWidth = aReflowState.mComputedWidth;
if (aReflowState.ComputedWidth() != NS_INTRINSICSIZE) {
availContentWidth = aReflowState.ComputedWidth();
}
nscoord colHeight = GetAvailableContentHeight(aReflowState);
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE) {
@ -371,8 +371,8 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
nscoord targetX = borderPadding.left;
if (RTL) {
nscoord availWidth = aReflowState.availableWidth;
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE) {
availWidth = aReflowState.mComputedWidth;
if (aReflowState.ComputedWidth() != NS_INTRINSICSIZE) {
availWidth = aReflowState.ComputedWidth();
}
if (availWidth != NS_INTRINSICSIZE) {
childOrigin.x += availWidth - aConfig.mColWidth;
@ -576,8 +576,8 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
contentSize.height = PR_MAX(aReflowState.mComputedMinHeight, contentSize.height);
}
}
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE) {
contentSize.width = aReflowState.mComputedWidth;
if (aReflowState.ComputedWidth() != NS_INTRINSICSIZE) {
contentSize.width = aReflowState.ComputedWidth();
} else {
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedMaxWidth) {
contentSize.width = PR_MIN(aReflowState.mComputedMaxWidth, contentSize.width);

View File

@ -6120,7 +6120,7 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState,
// This may not do very much useful, but it's probably worth trying.
if (parentSize.width != NS_INTRINSICSIZE)
parentReflowState.mComputedWidth = parentSize.width;
parentReflowState.SetComputedWidth(parentSize.width);
if (parentSize.height != NS_INTRINSICSIZE)
parentReflowState.mComputedHeight = parentSize.height;
parentReflowState.mComputedMargin.SizeTo(0, 0, 0, 0);
@ -6143,10 +6143,10 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState,
// mComputedWidth and mComputedHeight are content-box, not
// border-box
if (aWidth != NS_INTRINSICSIZE) {
reflowState.mComputedWidth =
nscoord computedWidth =
aWidth - reflowState.mComputedBorderPadding.LeftRight();
if (reflowState.mComputedWidth < 0)
reflowState.mComputedWidth = 0;
computedWidth = PR_MAX(computedWidth, 0);
reflowState.SetComputedWidth(computedWidth);
}
if (aHeight != NS_INTRINSICSIZE) {
reflowState.mComputedHeight =
@ -6168,7 +6168,7 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState,
#ifdef DEBUG_REFLOW
nsAdaptorAddIndents();
printf("Size=(%d,%d)\n",reflowState.mComputedWidth, reflowState.mComputedHeight);
printf("Size=(%d,%d)\n",reflowState.ComputedWidth(), reflowState.mComputedHeight);
nsAdaptorAddIndents();
nsAdaptorPrintReason(reflowState);
printf("\n");
@ -6203,9 +6203,10 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState,
else {
if (aDesiredSize.width > aWidth)
{
reflowState.mComputedWidth = aDesiredSize.width - reflowState.mComputedBorderPadding.LeftRight();
if (reflowState.mComputedWidth < 0)
reflowState.mComputedWidth = 0;
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
@ -7145,7 +7146,7 @@ static void DisplayReflowEnterPrint(nsPresContext* aPresContext,
DR_state->PrettyUC(aReflowState.availableHeight, height);
printf("Reflow a=%s,%s ", width, height);
DR_state->PrettyUC(aReflowState.mComputedWidth, width);
DR_state->PrettyUC(aReflowState.ComputedWidth(), width);
DR_state->PrettyUC(aReflowState.mComputedHeight, height);
printf("c=%s,%s ", width, height);
@ -7180,7 +7181,7 @@ static void DisplayReflowEnterPrint(nsPresContext* aPresContext,
float p2t = aPresContext->ScaledPixelsToTwips();
CheckPixelError(aReflowState.availableWidth, p2t);
CheckPixelError(aReflowState.availableHeight, p2t);
CheckPixelError(aReflowState.mComputedWidth, p2t);
CheckPixelError(aReflowState.ComputedWidth(), p2t);
CheckPixelError(aReflowState.mComputedHeight, p2t);
}
}

View File

@ -269,7 +269,7 @@ static nsSize ComputeInsideBorderSize(ScrollReflowState* aState,
// aDesiredInsideBorderSize is the frame size; i.e., it includes
// borders and padding (but the scrolled child doesn't have
// borders). The scrolled child has the same padding as us.
nscoord contentWidth = aState->mReflowState.mComputedWidth;
nscoord contentWidth = aState->mReflowState.ComputedWidth();
if (contentWidth == NS_UNCONSTRAINEDSIZE) {
contentWidth = aDesiredInsideBorderSize.width -
aState->mReflowState.mComputedPadding.LeftRight();
@ -423,7 +423,7 @@ nsHTMLScrollFrame::ReflowScrolledFrame(const ScrollReflowState& aState,
// be OK
nscoord paddingLR = aState.mReflowState.mComputedPadding.LeftRight();
nscoord availWidth = aState.mReflowState.mComputedWidth + paddingLR;
nscoord availWidth = aState.mReflowState.ComputedWidth() + paddingLR;
if (aAssumeVScroll) {
nsSize vScrollbarPrefSize =

View File

@ -130,7 +130,7 @@ nsHTMLCanvasFrame::Reflow(nsPresContext* aPresContext,
aStatus = NS_FRAME_COMPLETE;
aMetrics.width = aReflowState.mComputedWidth;
aMetrics.width = aReflowState.ComputedWidth();
aMetrics.height = aReflowState.mComputedHeight;
// stash this away so we can compute our inner area later

View File

@ -203,6 +203,20 @@ nsCSSOffsetState::ComputeHeightDependentValue(nscoord aContainingBlockHeight,
aCoord);
}
void
nsHTMLReflowState::SetComputedWidth(nscoord aComputedWidth)
{
NS_ASSERTION(frame, "Must have a frame!");
NS_ASSERTION(!(frame->GetStateBits() & NS_FRAME_IN_REFLOW),
"frame shouldn't be in reflow yet");
nscoord oldComputedWidth = mComputedWidth;
mComputedWidth = aComputedWidth;
if (mComputedWidth != oldComputedWidth) {
InitResizeFlags(frame->GetPresContext());
}
}
void
nsHTMLReflowState::Init(nsPresContext* aPresContext,
nscoord aContainingBlockWidth,

View File

@ -234,6 +234,7 @@ struct nsHTMLReflowState : public nsCSSOffsetState {
// percentage widths, etc.) of this reflow state's frame.
const nsHTMLReflowState *mCBReflowState;
private:
// The computed width specifies the frame's content area width, and it does
// not apply to inline non-replaced elements
//
@ -244,6 +245,7 @@ struct nsHTMLReflowState : public nsCSSOffsetState {
// containing block, the margin/border/padding areas, and the min/max width.
nscoord mComputedWidth;
public:
// The computed height specifies the frame's content height, and it does
// not apply to inline non-replaced elements
//
@ -409,6 +411,9 @@ struct nsHTMLReflowState : public nsCSSOffsetState {
(frame->GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT));
}
nscoord ComputedWidth() const { return mComputedWidth; }
void SetComputedWidth(nscoord aComputedWidth);
protected:
void InitCBReflowState();

View File

@ -151,17 +151,17 @@ inline PRBool HaveFixedSize(const nsHTMLReflowState& aReflowState)
{
NS_ASSERTION(aReflowState.mStylePosition, "crappy reflowState - null stylePosition");
// when an image has percent css style height or width, but mComputedHeight
// or mComputedWidth of reflow state is NS_UNCONSTRAINEDSIZE
// or ComputedWidth() of reflow state is NS_UNCONSTRAINEDSIZE
// it needs to return PR_FALSE to cause an incremental reflow later
// if an image is inside table like bug 156731 simple testcase III,
// during pass 1 reflow, mComputedWidth is NS_UNCONSTRAINEDSIZE
// in pass 2 reflow, mComputedWidth is 0, it also needs to return PR_FALSE
// during pass 1 reflow, ComputedWidth() is NS_UNCONSTRAINEDSIZE
// in pass 2 reflow, ComputedWidth() is 0, it also needs to return PR_FALSE
// see bug 156731
nsStyleUnit heightUnit = (*(aReflowState.mStylePosition)).mHeight.GetUnit();
nsStyleUnit widthUnit = (*(aReflowState.mStylePosition)).mWidth.GetUnit();
return ((eStyleUnit_Percent == heightUnit && NS_UNCONSTRAINEDSIZE == aReflowState.mComputedHeight) ||
(eStyleUnit_Percent == widthUnit && (NS_UNCONSTRAINEDSIZE == aReflowState.mComputedWidth ||
0 == aReflowState.mComputedWidth)))
(eStyleUnit_Percent == widthUnit && (NS_UNCONSTRAINEDSIZE == aReflowState.ComputedWidth() ||
0 == aReflowState.ComputedWidth())))
? PR_FALSE
: HaveFixedSize(aReflowState.mStylePosition);
}
@ -837,7 +837,7 @@ nsImageFrame::Reflow(nsPresContext* aPresContext,
// transform it can.
mBorderPadding = aReflowState.mComputedBorderPadding;
nsSize newSize(aReflowState.mComputedWidth, aReflowState.mComputedHeight);
nsSize newSize(aReflowState.ComputedWidth(), aReflowState.mComputedHeight);
if (mComputedSize != newSize) {
mComputedSize = newSize;
RecalculateTransform(nsnull);

View File

@ -84,10 +84,10 @@ nsLeafFrame::Reflow(nsPresContext* aPresContext,
// XXX add in code to check for width/height being set via css
// and if set use them instead of calling GetDesiredSize.
NS_ASSERTION(aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE,
NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
"Shouldn't have unconstrained stuff here");
aMetrics.width = aReflowState.mComputedWidth;
aMetrics.width = aReflowState.ComputedWidth();
if (NS_INTRINSICSIZE != aReflowState.mComputedHeight) {
aMetrics.height = aReflowState.mComputedHeight;
} else {

View File

@ -632,7 +632,7 @@ nsObjectFrame::GetDesiredSize(nsPresContext* aPresContext,
return;
}
aMetrics.width = aReflowState.mComputedWidth;
aMetrics.width = aReflowState.ComputedWidth();
aMetrics.height = aReflowState.mComputedHeight;
// for EMBED and APPLET, default to 240x200 for compatibility

View File

@ -289,7 +289,7 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
availSize);
nsReflowStatus status;
kidReflowState.mComputedWidth = kidReflowState.availableWidth;
kidReflowState.SetComputedWidth(kidReflowState.availableWidth);
//kidReflowState.mComputedHeight = kidReflowState.availableHeight;
PR_PL(("AV W: %d H: %d\n", kidReflowState.availableWidth, kidReflowState.availableHeight));

View File

@ -235,7 +235,8 @@ nsPoint
if (scrollingFrame) {
nsMargin scrollbars = scrollingFrame->GetActualScrollbarSizes();
aReflowState->mComputedWidth -= scrollbars.left + scrollbars.right;
aReflowState->SetComputedWidth(aReflowState->ComputedWidth() -
(scrollbars.left + scrollbars.right));
aReflowState->availableWidth -= scrollbars.left + scrollbars.right;
aReflowState->mComputedHeight -= scrollbars.top + scrollbars.bottom;
// XXX why don't we also adjust "aReflowState->availableHeight"?
@ -320,7 +321,7 @@ ViewportFrame::Reflow(nsPresContext* aPresContext,
// Just reflow all the fixed-pos frames.
rv = mFixedContainer.Reflow(this, aPresContext, reflowState,
reflowState.mComputedWidth,
reflowState.ComputedWidth(),
reflowState.mComputedHeight,
PR_TRUE, PR_TRUE); // XXX could be optimized

View File

@ -1023,7 +1023,7 @@ nsMathMLContainerFrame::Reflow(nsPresContext* aPresContext,
// Asking each child to cache its bounding metrics
nsReflowStatus childStatus;
nsSize availSize(aReflowState.mComputedWidth, aReflowState.mComputedHeight);
nsSize availSize(aReflowState.ComputedWidth(), aReflowState.mComputedHeight);
nsHTMLReflowMetrics childDesiredSize(
aDesiredSize.mFlags | NS_REFLOW_CALC_BOUNDING_METRICS);
nsIFrame* childFrame = mFrames.FirstChild();

View File

@ -133,7 +133,7 @@ nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext,
// ask our children to compute their bounding metrics
nsHTMLReflowMetrics childDesiredSize(
aDesiredSize.mFlags | NS_REFLOW_CALC_BOUNDING_METRICS);
nsSize availSize(aReflowState.mComputedWidth, aReflowState.mComputedHeight);
nsSize availSize(aReflowState.ComputedWidth(), aReflowState.mComputedHeight);
PRInt32 count = 0;
nsIFrame* childFrame = GetFirstChild(nsnull);
while (childFrame) {

View File

@ -283,7 +283,8 @@ nsMathMLmactionFrame::Reflow(nsPresContext* aPresContext,
mBoundingMetrics.Clear();
nsIFrame* childFrame = GetSelectedFrame();
if (childFrame) {
nsSize availSize(aReflowState.mComputedWidth, aReflowState.mComputedHeight);
nsSize availSize(aReflowState.ComputedWidth(),
aReflowState.mComputedHeight);
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
childFrame, availSize);
rv = ReflowChild(childFrame, aPresContext, aDesiredSize,

View File

@ -285,7 +285,7 @@ nsMathMLmfencedFrame::doReflow(nsPresContext* aPresContext,
PRInt32 count = 0;
nsReflowStatus childStatus;
nsSize availSize(aReflowState.mComputedWidth, aReflowState.mComputedHeight);
nsSize availSize(aReflowState.ComputedWidth(), aReflowState.mComputedHeight);
nsHTMLReflowMetrics childDesiredSize(
aDesiredSize.mFlags | NS_REFLOW_CALC_BOUNDING_METRICS);
nsIFrame* firstChild = aForFrame->GetFirstChild(nsnull);

View File

@ -162,7 +162,7 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
// ask our children to compute their bounding metrics
nsHTMLReflowMetrics childDesiredSize(
aDesiredSize.mFlags | NS_REFLOW_CALC_BOUNDING_METRICS);
nsSize availSize(aReflowState.mComputedWidth, aReflowState.mComputedHeight);
nsSize availSize(aReflowState.ComputedWidth(), aReflowState.mComputedHeight);
nsReflowStatus childStatus;
aDesiredSize.width = aDesiredSize.height = 0;

View File

@ -283,7 +283,7 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
// aReflowState.availableHeight,
// r.width, r.height);
// printf("******* cw: %d, ch: %d \n cmaxw: %d, cmaxh: %d\n",
// aReflowState.mComputedWidth,
// aReflowState.ComputedWidth(),
// aReflowState.mComputedHeight,
// aReflowState.mComputedMaxWidth,
// aReflowState.mComputedMaxHeight);
@ -293,7 +293,7 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
// aReflowState.parentReflowState->availableWidth,
// aReflowState.parentReflowState->availableHeight);
// printf("******* parent cw: %d, parent ch: %d \n parent cmaxw: %d, parent cmaxh: %d\n",
// aReflowState.parentReflowState->mComputedWidth,
// aReflowState.parentReflowState->ComputedWidth(),
// aReflowState.parentReflowState->mComputedHeight,
// aReflowState.parentReflowState->mComputedMaxWidth,
// aReflowState.parentReflowState->mComputedMaxHeight);
@ -713,8 +713,8 @@ nsSVGOuterSVGFrame::CalculateAvailableSpace(nsRect *maxRect,
if (aReflowState.availableWidth != NS_INTRINSICSIZE)
maxRect->width = aReflowState.availableWidth;
else if (aReflowState.parentReflowState &&
aReflowState.parentReflowState->mComputedWidth != NS_INTRINSICSIZE)
maxRect->width = aReflowState.parentReflowState->mComputedWidth;
aReflowState.parentReflowState->ComputedWidth() != NS_INTRINSICSIZE)
maxRect->width = aReflowState.parentReflowState->ComputedWidth();
else
maxRect->width = NS_MAXSIZE;

View File

@ -614,7 +614,7 @@ BasicTableLayoutStrategy::MarkIntrinsicWidthsDirty()
/* virtual */ void
BasicTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowState)
{
nscoord width = aReflowState.mComputedWidth;
nscoord width = aReflowState.ComputedWidth();
if (mLastCalcWidth == width)
return;

View File

@ -160,7 +160,7 @@ FixedTableLayoutStrategy::MarkIntrinsicWidthsDirty()
/* virtual */ void
FixedTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowState)
{
nscoord tableWidth = aReflowState.mComputedWidth;
nscoord tableWidth = aReflowState.ComputedWidth();
if (mLastCalcWidth == tableWidth)
return;

View File

@ -1966,7 +1966,7 @@ NS_METHOD nsTableFrame::Reflow(nsPresContext* aPresContext,
mutable_rs.mFlags.mSpecialHeightReflow = oldSpecialHeightReflow;
}
aDesiredSize.width = aReflowState.mComputedWidth +
aDesiredSize.width = aReflowState.ComputedWidth() +
aReflowState.mComputedBorderPadding.LeftRight();
if (!haveDesiredHeight) {
CalcDesiredHeight(aReflowState, aDesiredSize);
@ -2031,7 +2031,7 @@ nsTableFrame::ReflowTable(nsHTMLReflowMetrics& aDesiredSize,
}
// Constrain our reflow width to the computed table width (of the 1st in flow).
// and our reflow height to our avail height minus border, padding, cellspacing
aDesiredSize.width = aReflowState.mComputedWidth +
aDesiredSize.width = aReflowState.ComputedWidth() +
aReflowState.mComputedBorderPadding.LeftRight();
nsTableReflowState reflowState(*GetPresContext(), aReflowState, *this,
aDesiredSize.width, aAvailHeight);
@ -2805,8 +2805,6 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
kidFrame, kidAvailSize,
-1, -1, PR_FALSE);
InitChildReflowState(kidReflowState);
// XXX fix up bad mComputedWidth for scroll frame
kidReflowState.mComputedWidth = PR_MAX(kidReflowState.mComputedWidth, 0);
// If this isn't the first row group, then we can't be at the top of the page
// When a new page starts, a head row group may be added automatically.
@ -3387,7 +3385,7 @@ nsTableFrame::GetBorderPadding(const nsHTMLReflowState& aReflowState,
while (parentRS) {
if (parentRS->frame) {
if (nsGkAtoms::tableFrame == parentRS->frame->GetType()) {
nsSize basis(parentRS->mComputedWidth, parentRS->mComputedHeight);
nsSize basis(parentRS->ComputedWidth(), parentRS->mComputedHeight);
GetPaddingFor(basis, *paddingData, padding);
break;
}

View File

@ -469,7 +469,7 @@ GetContainingBlockSize(const nsHTMLReflowState& aOuterRS)
aOuterRS.mCBReflowState;
if (containRS) {
size.width = containRS->mComputedWidth;
size.width = containRS->ComputedWidth();
if (NS_UNCONSTRAINEDSIZE == size.width) {
size.width = 0;
}
@ -1193,19 +1193,19 @@ NS_METHOD nsTableOuterFrame::Reflow(nsPresContext* aPresContext,
nsReflowStatus capStatus; // don't let the caption cause incomplete
rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS,
captionRSSpace, captionMet,
aOuterRS.mComputedWidth, captionSize,
aOuterRS.ComputedWidth(), captionSize,
captionMargin, capStatus);
if (NS_FAILED(rv)) return rv;
} else if (mCaptionFrame) {
captionSize = mCaptionFrame->GetSize();
GetMargin(aPresContext, aOuterRS, mCaptionFrame, aOuterRS.mComputedWidth,
GetMargin(aPresContext, aOuterRS, mCaptionFrame, aOuterRS.ComputedWidth(),
captionMargin);
} else {
captionSize.SizeTo(0,0);
captionMargin.SizeTo(0,0,0,0);
}
nscoord innerAvailWidth = aOuterRS.mComputedWidth;
nscoord innerAvailWidth = aOuterRS.ComputedWidth();
if (captionSide == NS_SIDE_LEFT || captionSide == NS_SIDE_RIGHT)
// If side is left/right then we know we have a caption and we
// reflowed it.
@ -1225,7 +1225,7 @@ NS_METHOD nsTableOuterFrame::Reflow(nsPresContext* aPresContext,
} else {
innerSize = mInnerTableFrame->GetSize();
GetMargin(aPresContext, aOuterRS, mInnerTableFrame,
aOuterRS.mComputedWidth, innerMargin);
aOuterRS.ComputedWidth(), innerMargin);
}
nsSize containSize = GetContainingBlockSize(aOuterRS);

View File

@ -73,9 +73,11 @@ void nsTableCellReflowState::FixUp(const nsSize& aAvailSpace)
// fix the mComputed values during a pass 2 reflow since the cell can be a percentage base
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aAvailSpace.width,
"unconstrained available width in reflow");
if (NS_UNCONSTRAINEDSIZE != mComputedWidth) {
mComputedWidth = aAvailSpace.width - mComputedBorderPadding.left - mComputedBorderPadding.right;
mComputedWidth = PR_MAX(0, mComputedWidth);
if (NS_UNCONSTRAINEDSIZE != ComputedWidth()) {
nscoord computedWidth = aAvailSpace.width - mComputedBorderPadding.left -
mComputedBorderPadding.right;
computedWidth = PR_MAX(0, computedWidth);
SetComputedWidth(computedWidth);
}
if (NS_UNCONSTRAINEDSIZE != mComputedHeight) {
if (NS_UNCONSTRAINEDSIZE != aAvailSpace.height) {
@ -785,7 +787,7 @@ GetComputedWidth(const nsHTMLReflowState& aReflowState,
nscoord computedWidth = 0;
while (parentReflow) {
if (parentReflow->frame == &aTableFrame) {
computedWidth = parentReflow->mComputedWidth;
computedWidth = parentReflow->ComputedWidth();
break;
}
parentReflow = parentReflow->parentReflowState;

View File

@ -717,7 +717,7 @@ nsBoxFrame::Reflow(nsPresContext* aPresContext,
DO_GLOBAL_REFLOW_COUNT("nsBoxFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(aReflowState.mComputedWidth >=0 && aReflowState.mComputedHeight >= 0, "Computed Size < 0");
NS_ASSERTION(aReflowState.ComputedWidth() >=0 && aReflowState.ComputedWidth() >= 0, "Computed Size < 0");
#ifdef DO_NOISY_REFLOW
printf("\n-------------Starting BoxFrame Reflow ----------------------------\n");
@ -725,7 +725,7 @@ nsBoxFrame::Reflow(nsPresContext* aPresContext,
printSize("AW", aReflowState.availableWidth);
printSize("AH", aReflowState.availableHeight);
printSize("CW", aReflowState.mComputedWidth);
printSize("CW", aReflowState.ComputedWidth());
printSize("CH", aReflowState.mComputedHeight);
printf(" *\n");
@ -737,7 +737,7 @@ nsBoxFrame::Reflow(nsPresContext* aPresContext,
// create the layout state
nsBoxLayoutState state(aPresContext, aReflowState.rendContext);
nsSize computedSize(aReflowState.mComputedWidth,aReflowState.mComputedHeight);
nsSize computedSize(aReflowState.ComputedWidth(),aReflowState.mComputedHeight);
nsMargin m;
m = aReflowState.mComputedBorderPadding;

View File

@ -252,7 +252,7 @@ nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,
DO_GLOBAL_REFLOW_COUNT("nsLeafBoxFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(aReflowState.mComputedWidth >=0 && aReflowState.mComputedHeight >= 0, "Computed Size < 0");
NS_ASSERTION(aReflowState.ComputedWidth() >=0 && aReflowState.mComputedHeight >= 0, "Computed Size < 0");
#ifdef DO_NOISY_REFLOW
printf("\n-------------Starting LeafBoxFrame Reflow ----------------------------\n");
@ -274,7 +274,7 @@ nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,
printSize("AW", aReflowState.availableWidth);
printSize("AH", aReflowState.availableHeight);
printSize("CW", aReflowState.mComputedWidth);
printSize("CW", aReflowState.ComputedWidth());
printSize("CH", aReflowState.mComputedHeight);
printf(" *\n");
@ -286,7 +286,7 @@ nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,
// create the layout state
nsBoxLayoutState state(aPresContext, aReflowState.rendContext);
nsSize computedSize(aReflowState.mComputedWidth,aReflowState.mComputedHeight);
nsSize computedSize(aReflowState.ComputedWidth(),aReflowState.mComputedHeight);
nsMargin m;
m = aReflowState.mComputedBorderPadding;
@ -310,7 +310,7 @@ nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,
}
// get our desiredSize
if (aReflowState.mComputedWidth == NS_INTRINSICSIZE) {
if (aReflowState.ComputedWidth() == NS_INTRINSICSIZE) {
computedSize.width = prefSize.width;
} else {
computedSize.width += m.left + m.right;