Changed nsReflowState structs to be linked together

This commit is contained in:
troy
1998-05-29 20:36:05 +00:00
parent aba46f0f89
commit 017eaee3fd
42 changed files with 670 additions and 389 deletions

View File

@@ -33,6 +33,7 @@ class nsISpaceManager;
class nsIStyleContext; class nsIStyleContext;
class nsIView; class nsIView;
class nsIWidget; class nsIWidget;
class nsIFrame;
class nsReflowCommand; class nsReflowCommand;
struct nsPoint; struct nsPoint;
@@ -76,33 +77,45 @@ enum nsReflowReason {
}; };
/** /**
* Reflow state passed to a frame during reflow. * Reflow state passed to a frame during reflow. The reflow states are linked
* together. The max size represents the available space on which to reflow
* your frame, and is computed as the parent frame's available content area
* minus any room for margins that your frame requests.
* *
* @see #Reflow() * @see #Reflow()
*/ */
struct nsReflowState { struct nsReflowState {
nsReflowReason reason; // the reason for the reflow nsReflowReason reason; // the reason for the reflow
nsReflowCommand* reflowCommand; // only used for incremental changes nsReflowCommand* reflowCommand; // only used for incremental changes
nsSize maxSize; // the available space in which to reflow nsSize maxSize; // the available space in which to reflow
const nsReflowState* parentReflowState; // pointer to parent's reflow state
nsIFrame* frame; // the frame being reflowed
// Construct a non-incremental reflow state // Constructs an initial reflow state (no parent reflow state) for a
nsReflowState(nsReflowReason aReason, const nsSize& aMaxSize) { // non-incremental reflow command
reason = aReason; reflowCommand = nsnull; maxSize = aMaxSize; nsReflowState(nsIFrame* aFrame,
} nsReflowReason aReason,
// Construct a reflow state for an incremental change const nsSize& aMaxSize);
nsReflowState(nsReflowCommand* aReflowCommand, const nsSize& aMaxSize) {
reason = eReflowReason_Incremental;
reflowCommand = aReflowCommand;
maxSize = aMaxSize;
}
// Construct a reflow state similar to an existing reflow state except that // Constructs an initial reflow state (no parent reflow state) for an
// it has a different max size // incremental reflow command
nsReflowState(const nsReflowState& aReflowState, const nsSize& aMaxSize) { nsReflowState(nsIFrame* aFrame,
reason = aReflowState.reason; nsReflowCommand& aReflowCommand,
reflowCommand = aReflowState.reflowCommand; const nsSize& aMaxSize);
maxSize = aMaxSize;
} // Construct a reflow state for the given frame, parent reflow state, and
// max size. Uses the reflow reason and reflow command from the parent's
// reflow state
nsReflowState(nsIFrame* aFrame,
const nsReflowState& aParentReflowState,
const nsSize& aMaxSize);
// Constructs a reflow state that overrides the reflow reason of the parent
// reflow state. Sets the reflow command to NULL
nsReflowState(nsIFrame* aFrame,
const nsReflowState& aParentReflowState,
const nsSize& aMaxSize,
nsReflowReason aReflowReason);
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -320,28 +333,34 @@ public:
/** /**
* The frame is given a maximum size and asked for its desired size. * The frame is given a maximum size and asked for its desired size.
* size. This is the frame's opportunity to reflow its children. * This is the frame's opportunity to reflow its children.
* *
* @param aDesiredSize <i>out</i> parameter where you should return the * @param aDesiredSize <i>out</i> parameter where you should return the
* desired size and ascent/descent info. You should include any * desired size and ascent/descent info. You should include any
* space you want for border/padding in the desired size you return. * space you want for border/padding in the desired size you return.
* *
* @param aMaxSize the available space in which to lay out. Each
* dimension can either be constrained or unconstrained (a
* value of NS_UNCONSTRAINEDSIZE). If constrained you
* should choose a value that's less than or equal to the
* constrained size. If unconstrained you can choose as
* large a value as you like.
*
* It's okay to return a desired size that exceeds the max * It's okay to return a desired size that exceeds the max
* size if that's the smallest you can be, i.e. it's your * size if that's the smallest you can be, i.e. it's your
* minimum size. * minimum size.
* *
* @param aMaxElementSize an optional parameter for returning your * maxElementSize is an optional parameter for returning your
* maximum element size. If may be null in which case you * maximum element size. If may be null in which case you
* don't have to compute a maximum element size. The * don't have to compute a maximum element size. The
* maximum element size must be less than or equal to your * maximum element size must be less than or equal to your
* desired size. * desired size.
*
* @param aReflowState information about your reflow including the reason
* for the reflow and the available space in which to lay out. Each
* dimension of the available space can either be constrained or
* unconstrained (a value of NS_UNCONSTRAINEDSIZE). If constrained
* you should choose a value that's less than or equal to the
* constrained size. If unconstrained you can choose as
* large a value as you like.
*
* Note that the available space can be negative. In this case you
* still must return an accurate desired size. If you're a container
* you must <b>always</b> reflow at least one frame regardless of the
* available space
*/ */
NS_IMETHOD Reflow(nsIPresContext* aPresContext, NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
@@ -563,4 +582,69 @@ protected:
static NS_LAYOUT PRLogModuleInfo* gLogModule; static NS_LAYOUT PRLogModuleInfo* gLogModule;
}; };
// Constructs an initial reflow state (no parent reflow state) for a
// non-incremental reflow command
inline nsReflowState::nsReflowState(nsIFrame* aFrame,
nsReflowReason aReason,
const nsSize& aMaxSize)
{
NS_PRECONDITION(aReason != eReflowReason_Incremental, "unexpected reflow reason");
#ifdef NS_DEBUG
nsIFrame* parent;
aFrame->GetGeometricParent(parent);
NS_PRECONDITION(nsnull == parent, "not root frame");
#endif
reason = aReason;
reflowCommand = nsnull;
maxSize = aMaxSize;
parentReflowState = nsnull;
frame = aFrame;
}
// Constructs an initial reflow state (no parent reflow state) for an
// incremental reflow command
inline nsReflowState::nsReflowState(nsIFrame* aFrame,
nsReflowCommand& aReflowCommand,
const nsSize& aMaxSize)
{
#ifdef NS_DEBUG
nsIFrame* parent;
aFrame->GetGeometricParent(parent);
NS_PRECONDITION(nsnull == parent, "not root frame");
#endif
reason = eReflowReason_Incremental;
reflowCommand = &aReflowCommand;
maxSize = aMaxSize;
parentReflowState = nsnull;
frame = aFrame;
}
// Construct a reflow state for the given frame, parent reflow state, and
// max size. Uses the reflow reason and reflow command from the parent's
// reflow state
inline nsReflowState::nsReflowState(nsIFrame* aFrame,
const nsReflowState& aParentReflowState,
const nsSize& aMaxSize)
{
reason = aParentReflowState.reason;
reflowCommand = aParentReflowState.reflowCommand;
maxSize = aMaxSize;
parentReflowState = &aParentReflowState;
frame = aFrame;
}
// Constructs a reflow state that overrides the reflow reason of the parent
// reflow state. Sets the reflow command to NULL
inline nsReflowState::nsReflowState(nsIFrame* aFrame,
const nsReflowState& aParentReflowState,
const nsSize& aMaxSize,
nsReflowReason aReflowReason)
{
reason = aReflowReason;
reflowCommand = nsnull;
maxSize = aMaxSize;
parentReflowState = &aParentReflowState;
frame = aFrame;
}
#endif /* nsIFrame_h___ */ #endif /* nsIFrame_h___ */

View File

@@ -448,6 +448,7 @@ nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
{ {
nsReflowStatus status; nsReflowStatus status;
NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state");
#ifdef NS_DEBUG #ifdef NS_DEBUG
nsFrameState kidFrameState; nsFrameState kidFrameState;
@@ -482,16 +483,17 @@ nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
* used to reflow the child; otherwise interface nsIFrame is used. If the * used to reflow the child; otherwise interface nsIFrame is used. If the
* child is splittable then runaround is done using continuing frames. * child is splittable then runaround is done using continuing frames.
*/ */
nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState, nsReflowState& aReflowState,
nsRect& aDesiredRect) nsRect& aDesiredRect)
{ {
nsIRunaround* reflowRunaround; nsIRunaround* reflowRunaround;
nsReflowStatus status; nsReflowStatus status;
NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state");
#ifdef NS_DEBUG #ifdef NS_DEBUG
nsFrameState kidFrameState; nsFrameState kidFrameState;
@@ -509,7 +511,6 @@ nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
nsBandTrapezoid trapezoids[12]; nsBandTrapezoid trapezoids[12];
nsBandTrapezoid* trapezoid = trapezoids; nsBandTrapezoid* trapezoid = trapezoids;
nsRect availBand; nsRect availBand;
nsSize availSize = aReflowState.maxSize;
bandData.trapezoids = trapezoids; bandData.trapezoids = trapezoids;
bandData.size = 12; bandData.size = 12;
@@ -561,15 +562,14 @@ nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
(void**)&reflowRunaround)) { (void**)&reflowRunaround)) {
// Yes, the child frame wants to interact directly with the space // Yes, the child frame wants to interact directly with the space
// manager. // manager.
nsReflowState reflowState(aReflowState, availSize); reflowRunaround->Reflow(aPresContext, aSpaceManager, aDesiredSize, aReflowState,
reflowRunaround->Reflow(aPresContext, aSpaceManager, aDesiredSize, reflowState,
aDesiredRect, status); aDesiredRect, status);
} else { } else {
// No, use interface nsIFrame instead. // No, use interface nsIFrame instead.
if (aReflowState.maxSize.width != NS_UNCONSTRAINEDSIZE) { if (aReflowState.maxSize.width != NS_UNCONSTRAINEDSIZE) {
if ((availBand.x > 0) || (availBand.XMost() < aReflowState.maxSize.width)) { if ((availBand.x > 0) || (availBand.XMost() < aReflowState.maxSize.width)) {
// There are left/right floaters. // There are left/right floaters.
availSize.width = availBand.width; aReflowState.maxSize.width = availBand.width;
} }
} }

View File

@@ -237,12 +237,12 @@ protected:
* *
* @see nsIRunaround * @see nsIRunaround
*/ */
nsReflowStatus ReflowChild(nsIFrame* aKidFrame, nsReflowStatus ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState, nsReflowState& aReflowState,
nsRect& aDesiredRect); nsRect& aDesiredRect);
/** /**
* Moves any frames on both the prev-in-flow's overflow list and the receiver's * Moves any frames on both the prev-in-flow's overflow list and the receiver's

View File

@@ -414,7 +414,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
nsSize maxSize(bounds.width, bounds.height); nsSize maxSize(bounds.width, bounds.height);
nsReflowMetrics desiredSize(nsnull); nsReflowMetrics desiredSize(nsnull);
nsReflowStatus status; nsReflowStatus status;
nsReflowState reflowState(reflowReason, maxSize); nsReflowState reflowState(mRootFrame, reflowReason, maxSize);
mRootFrame->Reflow(mPresContext, desiredSize, reflowState, status); mRootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
mRootFrame->SizeTo(desiredSize.width, desiredSize.height); mRootFrame->SizeTo(desiredSize.width, desiredSize.height);

View File

@@ -76,7 +76,7 @@ void nsReflowCommand::Dispatch(nsReflowMetrics& aDesiredSize,
if (nsnull != root) { if (nsnull != root) {
mPath.RemoveElementAt(mPath.Count() - 1); mPath.RemoveElementAt(mPath.Count() - 1);
nsReflowState reflowState(this, aMaxSize); nsReflowState reflowState(root, *this, aMaxSize);
nsReflowStatus status; nsReflowStatus status;
root->Reflow(mPresContext, aDesiredSize, reflowState, status); root->Reflow(mPresContext, aDesiredSize, reflowState, status);
} }

View File

@@ -101,7 +101,7 @@ nsBlockReflowState::~nsBlockReflowState()
nsresult nsresult
nsBlockReflowState::Initialize(nsIPresContext* aPresContext, nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockFrame* aBlock) nsBlockFrame* aBlock)
{ {
@@ -114,10 +114,11 @@ nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
mListPositionOutside = PR_FALSE; mListPositionOutside = PR_FALSE;
mCurrentLine = nsnull; mCurrentLine = nsnull;
mPrevKidFrame = nsnull; mPrevKidFrame = nsnull;
reflowState = &aReflowState;
mX = 0; mX = 0;
mY = 0; mY = 0;
mAvailSize = aMaxSize; mAvailSize = reflowState->maxSize;
mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE); mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE);
mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE); mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE);
mMaxElementSizePointer = aMaxElementSize; mMaxElementSizePointer = aMaxElementSize;
@@ -447,7 +448,7 @@ nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState, nsReflowState& aReflowState,
nsRect& aDesiredRect, nsRect& aDesiredRect,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
@@ -955,15 +956,15 @@ done:
} }
nsresult nsresult
nsBlockFrame::InitializeState(nsIPresContext* aPresContext, nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockReflowState& aState) nsBlockReflowState& aState)
{ {
nsresult rv; nsresult rv;
rv = aState.Initialize(aPresContext, aSpaceManager, rv = aState.Initialize(aPresContext, aSpaceManager,
aMaxSize, aMaxElementSize, this); aReflowState, aMaxElementSize, this);
// Apply border and padding adjustments for regular frames only // Apply border and padding adjustments for regular frames only
if (!aState.mBlockIsPseudo) { if (!aState.mBlockIsPseudo) {
@@ -1173,7 +1174,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
} }
aStatus = NS_FRAME_COMPLETE; aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize, rv = InitializeState(aPresContext, aSpaceManager, aReflowState,
aDesiredSize.maxElementSize, state); aDesiredSize.maxElementSize, state);
NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d", NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d",

View File

@@ -59,7 +59,7 @@ struct nsBlockReflowState {
nsresult Initialize(nsIPresContext* aPresContext, nsresult Initialize(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockFrame* aBlock); nsBlockFrame* aBlock);
@@ -86,6 +86,7 @@ struct nsBlockReflowState {
PRPackedBool mUnconstrainedHeight; PRPackedBool mUnconstrainedHeight;
nsSize* mMaxElementSizePointer; nsSize* mMaxElementSizePointer;
nscoord mKidXMost; nscoord mKidXMost;
const nsReflowState* reflowState;
// Change in width since last reflow // Change in width since last reflow
nscoord mDeltaWidth; nscoord mDeltaWidth;
@@ -216,7 +217,7 @@ public:
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState, nsReflowState& aReflowState,
nsRect& aDesiredRect, nsRect& aDesiredRect,
nsReflowStatus& aStatus); nsReflowStatus& aStatus);
@@ -234,11 +235,11 @@ protected:
virtual void WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow); virtual void WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow);
nsresult InitializeState(nsIPresContext* aPresContext, nsresult InitializeState(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockReflowState& aState); nsBlockReflowState& aState);
void ComputeDesiredRect(nsBlockReflowState& aState, void ComputeDesiredRect(nsBlockReflowState& aState,
const nsSize& aMaxSize, const nsSize& aMaxSize,

View File

@@ -101,7 +101,7 @@ nsBlockReflowState::~nsBlockReflowState()
nsresult nsresult
nsBlockReflowState::Initialize(nsIPresContext* aPresContext, nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockFrame* aBlock) nsBlockFrame* aBlock)
{ {
@@ -114,10 +114,11 @@ nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
mListPositionOutside = PR_FALSE; mListPositionOutside = PR_FALSE;
mCurrentLine = nsnull; mCurrentLine = nsnull;
mPrevKidFrame = nsnull; mPrevKidFrame = nsnull;
reflowState = &aReflowState;
mX = 0; mX = 0;
mY = 0; mY = 0;
mAvailSize = aMaxSize; mAvailSize = reflowState->maxSize;
mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE); mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE);
mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE); mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE);
mMaxElementSizePointer = aMaxElementSize; mMaxElementSizePointer = aMaxElementSize;
@@ -447,7 +448,7 @@ nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState, nsReflowState& aReflowState,
nsRect& aDesiredRect, nsRect& aDesiredRect,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
@@ -955,15 +956,15 @@ done:
} }
nsresult nsresult
nsBlockFrame::InitializeState(nsIPresContext* aPresContext, nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockReflowState& aState) nsBlockReflowState& aState)
{ {
nsresult rv; nsresult rv;
rv = aState.Initialize(aPresContext, aSpaceManager, rv = aState.Initialize(aPresContext, aSpaceManager,
aMaxSize, aMaxElementSize, this); aReflowState, aMaxElementSize, this);
// Apply border and padding adjustments for regular frames only // Apply border and padding adjustments for regular frames only
if (!aState.mBlockIsPseudo) { if (!aState.mBlockIsPseudo) {
@@ -1173,7 +1174,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
} }
aStatus = NS_FRAME_COMPLETE; aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize, rv = InitializeState(aPresContext, aSpaceManager, aReflowState,
aDesiredSize.maxElementSize, state); aDesiredSize.maxElementSize, state);
NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d", NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d",

View File

@@ -101,7 +101,7 @@ nsBlockReflowState::~nsBlockReflowState()
nsresult nsresult
nsBlockReflowState::Initialize(nsIPresContext* aPresContext, nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockFrame* aBlock) nsBlockFrame* aBlock)
{ {
@@ -114,10 +114,11 @@ nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
mListPositionOutside = PR_FALSE; mListPositionOutside = PR_FALSE;
mCurrentLine = nsnull; mCurrentLine = nsnull;
mPrevKidFrame = nsnull; mPrevKidFrame = nsnull;
reflowState = &aReflowState;
mX = 0; mX = 0;
mY = 0; mY = 0;
mAvailSize = aMaxSize; mAvailSize = reflowState->maxSize;
mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE); mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE);
mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE); mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE);
mMaxElementSizePointer = aMaxElementSize; mMaxElementSizePointer = aMaxElementSize;
@@ -447,7 +448,7 @@ nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState, nsReflowState& aReflowState,
nsRect& aDesiredRect, nsRect& aDesiredRect,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
@@ -955,15 +956,15 @@ done:
} }
nsresult nsresult
nsBlockFrame::InitializeState(nsIPresContext* aPresContext, nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockReflowState& aState) nsBlockReflowState& aState)
{ {
nsresult rv; nsresult rv;
rv = aState.Initialize(aPresContext, aSpaceManager, rv = aState.Initialize(aPresContext, aSpaceManager,
aMaxSize, aMaxElementSize, this); aReflowState, aMaxElementSize, this);
// Apply border and padding adjustments for regular frames only // Apply border and padding adjustments for regular frames only
if (!aState.mBlockIsPseudo) { if (!aState.mBlockIsPseudo) {
@@ -1173,7 +1174,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
} }
aStatus = NS_FRAME_COMPLETE; aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize, rv = InitializeState(aPresContext, aSpaceManager, aReflowState,
aDesiredSize.maxElementSize, state); aDesiredSize.maxElementSize, state);
NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d", NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d",

View File

@@ -33,6 +33,7 @@ class nsISpaceManager;
class nsIStyleContext; class nsIStyleContext;
class nsIView; class nsIView;
class nsIWidget; class nsIWidget;
class nsIFrame;
class nsReflowCommand; class nsReflowCommand;
struct nsPoint; struct nsPoint;
@@ -76,33 +77,45 @@ enum nsReflowReason {
}; };
/** /**
* Reflow state passed to a frame during reflow. * Reflow state passed to a frame during reflow. The reflow states are linked
* together. The max size represents the available space on which to reflow
* your frame, and is computed as the parent frame's available content area
* minus any room for margins that your frame requests.
* *
* @see #Reflow() * @see #Reflow()
*/ */
struct nsReflowState { struct nsReflowState {
nsReflowReason reason; // the reason for the reflow nsReflowReason reason; // the reason for the reflow
nsReflowCommand* reflowCommand; // only used for incremental changes nsReflowCommand* reflowCommand; // only used for incremental changes
nsSize maxSize; // the available space in which to reflow nsSize maxSize; // the available space in which to reflow
const nsReflowState* parentReflowState; // pointer to parent's reflow state
nsIFrame* frame; // the frame being reflowed
// Construct a non-incremental reflow state // Constructs an initial reflow state (no parent reflow state) for a
nsReflowState(nsReflowReason aReason, const nsSize& aMaxSize) { // non-incremental reflow command
reason = aReason; reflowCommand = nsnull; maxSize = aMaxSize; nsReflowState(nsIFrame* aFrame,
} nsReflowReason aReason,
// Construct a reflow state for an incremental change const nsSize& aMaxSize);
nsReflowState(nsReflowCommand* aReflowCommand, const nsSize& aMaxSize) {
reason = eReflowReason_Incremental;
reflowCommand = aReflowCommand;
maxSize = aMaxSize;
}
// Construct a reflow state similar to an existing reflow state except that // Constructs an initial reflow state (no parent reflow state) for an
// it has a different max size // incremental reflow command
nsReflowState(const nsReflowState& aReflowState, const nsSize& aMaxSize) { nsReflowState(nsIFrame* aFrame,
reason = aReflowState.reason; nsReflowCommand& aReflowCommand,
reflowCommand = aReflowState.reflowCommand; const nsSize& aMaxSize);
maxSize = aMaxSize;
} // Construct a reflow state for the given frame, parent reflow state, and
// max size. Uses the reflow reason and reflow command from the parent's
// reflow state
nsReflowState(nsIFrame* aFrame,
const nsReflowState& aParentReflowState,
const nsSize& aMaxSize);
// Constructs a reflow state that overrides the reflow reason of the parent
// reflow state. Sets the reflow command to NULL
nsReflowState(nsIFrame* aFrame,
const nsReflowState& aParentReflowState,
const nsSize& aMaxSize,
nsReflowReason aReflowReason);
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -320,28 +333,34 @@ public:
/** /**
* The frame is given a maximum size and asked for its desired size. * The frame is given a maximum size and asked for its desired size.
* size. This is the frame's opportunity to reflow its children. * This is the frame's opportunity to reflow its children.
* *
* @param aDesiredSize <i>out</i> parameter where you should return the * @param aDesiredSize <i>out</i> parameter where you should return the
* desired size and ascent/descent info. You should include any * desired size and ascent/descent info. You should include any
* space you want for border/padding in the desired size you return. * space you want for border/padding in the desired size you return.
* *
* @param aMaxSize the available space in which to lay out. Each
* dimension can either be constrained or unconstrained (a
* value of NS_UNCONSTRAINEDSIZE). If constrained you
* should choose a value that's less than or equal to the
* constrained size. If unconstrained you can choose as
* large a value as you like.
*
* It's okay to return a desired size that exceeds the max * It's okay to return a desired size that exceeds the max
* size if that's the smallest you can be, i.e. it's your * size if that's the smallest you can be, i.e. it's your
* minimum size. * minimum size.
* *
* @param aMaxElementSize an optional parameter for returning your * maxElementSize is an optional parameter for returning your
* maximum element size. If may be null in which case you * maximum element size. If may be null in which case you
* don't have to compute a maximum element size. The * don't have to compute a maximum element size. The
* maximum element size must be less than or equal to your * maximum element size must be less than or equal to your
* desired size. * desired size.
*
* @param aReflowState information about your reflow including the reason
* for the reflow and the available space in which to lay out. Each
* dimension of the available space can either be constrained or
* unconstrained (a value of NS_UNCONSTRAINEDSIZE). If constrained
* you should choose a value that's less than or equal to the
* constrained size. If unconstrained you can choose as
* large a value as you like.
*
* Note that the available space can be negative. In this case you
* still must return an accurate desired size. If you're a container
* you must <b>always</b> reflow at least one frame regardless of the
* available space
*/ */
NS_IMETHOD Reflow(nsIPresContext* aPresContext, NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
@@ -563,4 +582,69 @@ protected:
static NS_LAYOUT PRLogModuleInfo* gLogModule; static NS_LAYOUT PRLogModuleInfo* gLogModule;
}; };
// Constructs an initial reflow state (no parent reflow state) for a
// non-incremental reflow command
inline nsReflowState::nsReflowState(nsIFrame* aFrame,
nsReflowReason aReason,
const nsSize& aMaxSize)
{
NS_PRECONDITION(aReason != eReflowReason_Incremental, "unexpected reflow reason");
#ifdef NS_DEBUG
nsIFrame* parent;
aFrame->GetGeometricParent(parent);
NS_PRECONDITION(nsnull == parent, "not root frame");
#endif
reason = aReason;
reflowCommand = nsnull;
maxSize = aMaxSize;
parentReflowState = nsnull;
frame = aFrame;
}
// Constructs an initial reflow state (no parent reflow state) for an
// incremental reflow command
inline nsReflowState::nsReflowState(nsIFrame* aFrame,
nsReflowCommand& aReflowCommand,
const nsSize& aMaxSize)
{
#ifdef NS_DEBUG
nsIFrame* parent;
aFrame->GetGeometricParent(parent);
NS_PRECONDITION(nsnull == parent, "not root frame");
#endif
reason = eReflowReason_Incremental;
reflowCommand = &aReflowCommand;
maxSize = aMaxSize;
parentReflowState = nsnull;
frame = aFrame;
}
// Construct a reflow state for the given frame, parent reflow state, and
// max size. Uses the reflow reason and reflow command from the parent's
// reflow state
inline nsReflowState::nsReflowState(nsIFrame* aFrame,
const nsReflowState& aParentReflowState,
const nsSize& aMaxSize)
{
reason = aParentReflowState.reason;
reflowCommand = aParentReflowState.reflowCommand;
maxSize = aMaxSize;
parentReflowState = &aParentReflowState;
frame = aFrame;
}
// Constructs a reflow state that overrides the reflow reason of the parent
// reflow state. Sets the reflow command to NULL
inline nsReflowState::nsReflowState(nsIFrame* aFrame,
const nsReflowState& aParentReflowState,
const nsSize& aMaxSize,
nsReflowReason aReflowReason)
{
reason = aReflowReason;
reflowCommand = nsnull;
maxSize = aMaxSize;
parentReflowState = &aParentReflowState;
frame = aFrame;
}
#endif /* nsIFrame_h___ */ #endif /* nsIFrame_h___ */

View File

@@ -53,31 +53,33 @@ NS_DEF_PTR(nsIContentDelegate);
class nsInlineState class nsInlineState
{ {
public: public:
nsStyleFont* font; // style font nsStyleFont* font; // style font
nsMargin borderPadding; // inner margin nsMargin borderPadding; // inner margin
nsSize mStyleSize; nsSize mStyleSize;
PRIntn mStyleSizeFlags; PRIntn mStyleSizeFlags;
nsSize availSize; // available space in which to reflow (starts as max size minus insets) nsSize availSize; // available space in which to reflow (starts as max size minus insets)
nsSize* maxElementSize; // maximum element size (may be null) nsSize* maxElementSize; // maximum element size (may be null)
nscoord x; // running x-offset (starts at left inner edge) nscoord x; // running x-offset (starts at left inner edge)
const nscoord y; // y-offset (top inner edge) const nscoord y; // y-offset (top inner edge)
nscoord maxAscent; // max child ascent nscoord maxAscent; // max child ascent
nscoord maxDescent; // max child descent nscoord maxDescent; // max child descent
nscoord* ascents; // ascent information for each child nscoord* ascents; // ascent information for each child
PRBool unconstrainedWidth; PRBool unconstrainedWidth;
PRBool unconstrainedHeight; PRBool unconstrainedHeight;
nsLineLayout* lineLayout; nsLineLayout* lineLayout;
PRBool atBreakPoint; PRBool atBreakPoint;
const nsReflowState& reflowState;
// Constructor // Constructor
nsInlineState(nsIPresContext* aPresContext, nsInlineState(nsIPresContext* aPresContext,
nsIFrame* aInlineFrame, nsIFrame* aInlineFrame,
nsStyleFont* aStyleFont, nsStyleFont* aStyleFont,
const nsMargin& aBorderPadding, const nsMargin& aBorderPadding,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize) nsSize* aMaxElementSize)
: x(aBorderPadding.left), // determined by inner edge : x(aBorderPadding.left), // determined by inner edge
y(aBorderPadding.top) // determined by inner edge y(aBorderPadding.top), // determined by inner edge
reflowState(aReflowState)
{ {
nsBlockReflowState* brs = nsBlockReflowState* brs =
nsBlockFrame::FindBlockReflowState(aPresContext, aInlineFrame); nsBlockFrame::FindBlockReflowState(aPresContext, aInlineFrame);
@@ -87,16 +89,16 @@ public:
font = aStyleFont; font = aStyleFont;
borderPadding = aBorderPadding; borderPadding = aBorderPadding;
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE); unconstrainedWidth = PRBool(reflowState.maxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE); unconstrainedHeight = PRBool(reflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
// If we're constrained adjust the available size so it excludes space // If we're constrained adjust the available size so it excludes space
// needed for border/padding // needed for border/padding
availSize.width = aMaxSize.width; availSize.width = reflowState.maxSize.width;
if (PR_FALSE == unconstrainedWidth) { if (PR_FALSE == unconstrainedWidth) {
availSize.width -= aBorderPadding.left + aBorderPadding.right; availSize.width -= aBorderPadding.left + aBorderPadding.right;
} }
availSize.height = aMaxSize.height; availSize.height = reflowState.maxSize.height;
if (PR_FALSE == unconstrainedHeight) { if (PR_FALSE == unconstrainedHeight) {
availSize.height -= aBorderPadding.top + aBorderPadding.bottom; availSize.height -= aBorderPadding.top + aBorderPadding.bottom;
} }
@@ -276,7 +278,8 @@ PRBool nsInlineFrame::ReflowMappedChildrenFrom(nsIPresContext* aPresContext,
for (nsIFrame* kidFrame = aChildFrame; nsnull != kidFrame; ) { for (nsIFrame* kidFrame = aChildFrame; nsnull != kidFrame; ) {
nsReflowMetrics kidSize(pKidMaxElementSize); nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize);
nsReflowStatus status; nsReflowStatus status;
// Reflow the child into the available space // Reflow the child into the available space
@@ -462,7 +465,8 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
} }
#endif #endif
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
@@ -716,7 +720,8 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not // Try to reflow the child into the available space. It might not
// fit or might need continuing. // fit or might need continuing.
nsReflowMetrics kidSize(pKidMaxElementSize); nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame, aPresContext, kidSize, nsReflowStatus status = ReflowChild(kidFrame, aPresContext, kidSize,
kidReflowState); kidReflowState);
@@ -828,7 +833,7 @@ NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
nsMargin borderPadding; nsMargin borderPadding;
styleSpacing->CalcBorderPaddingFor(this, borderPadding); styleSpacing->CalcBorderPaddingFor(this, borderPadding);
nsInlineState state(aPresContext, this, styleFont, borderPadding, nsInlineState state(aPresContext, this, styleFont, borderPadding,
aReflowState.maxSize, aDesiredSize.maxElementSize); aReflowState, aDesiredSize.maxElementSize);
InitializeState(aPresContext, state); InitializeState(aPresContext, state);
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset); state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
@@ -851,7 +856,7 @@ NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
// The command is passing through us. Get the next frame in the reflow chain // The command is passing through us. Get the next frame in the reflow chain
nsIFrame* kidFrame = aReflowState.reflowCommand->GetNext(); nsIFrame* kidFrame = aReflowState.reflowCommand->GetNext();
nsReflowMetrics kidSize(aDesiredSize.maxElementSize); nsReflowMetrics kidSize(aDesiredSize.maxElementSize);
nsReflowState kidReflowState(aReflowState.reflowCommand, state.availSize); nsReflowState kidReflowState(kidFrame, aReflowState, state.availSize);
// Restore our state as if nextFrame is the next frame to reflow // Restore our state as if nextFrame is the next frame to reflow
PRInt32 kidIndex = RecoverState(aPresContext, state, kidFrame); PRInt32 kidIndex = RecoverState(aPresContext, state, kidFrame);

View File

@@ -677,7 +677,8 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand,
} }
} }
nsReflowState kidReflowState(kidReason, kidAvailSize); nsReflowState kidReflowState(kidFrame, *mBlockReflowState.reflowState,
kidAvailSize, kidReason);
kidReflowState.reflowCommand = aReflowCommand; kidReflowState.reflowCommand = aReflowCommand;
mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE; mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE;
nscoord dx = mState.mX + kidMargin.left; nscoord dx = mState.mX + kidMargin.left;

View File

@@ -78,9 +78,9 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext* aPresContext,
// Dispatch the reflow command to our content child. Allow it to be as high // Dispatch the reflow command to our content child. Allow it to be as high
// as it wants // as it wants
nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE); nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE);
nsReflowState reflowState(aReflowState.reflowCommand, maxSize); nsReflowState kidReflowState(mFirstChild, aReflowState, maxSize);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState); aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState);
// Place and size the child. Make sure the child is at least as // Place and size the child. Make sure the child is at least as
// tall as our max size (the containing window) // tall as our max size (the containing window)
@@ -119,9 +119,11 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext* aPresContext,
// Resize our frame allowing it only to be as big as we are // Resize our frame allowing it only to be as big as we are
// XXX Pay attention to the page's border and padding... // XXX Pay attention to the page's border and padding...
if (nsnull != mFirstChild) { if (nsnull != mFirstChild) {
nsReflowState kidReflowState(mFirstChild, aReflowState, aReflowState.maxSize);
// Get the child's desired size // Get the child's desired size
mFirstChild->WillReflow(*aPresContext); mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, aReflowState); aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState);
mLastContentIsComplete = NS_FRAME_IS_COMPLETE(aStatus); mLastContentIsComplete = NS_FRAME_IS_COMPLETE(aStatus);
// Make sure the child is at least as tall as our max size (the containing window) // Make sure the child is at least as tall as our max size (the containing window)

View File

@@ -79,7 +79,8 @@ NS_METHOD nsPlaceholderFrame::Reflow(nsIPresContext* aPresContext,
// Resize reflow the anchored item into the available space // Resize reflow the anchored item into the available space
// XXX Check for complete? // XXX Check for complete?
nsReflowMetrics desiredSize(nsnull); nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Initial, aReflowState.maxSize); nsReflowState reflowState(mAnchoredItem, aReflowState, aReflowState.maxSize,
eReflowReason_Initial);
mAnchoredItem->WillReflow(*aPresContext); mAnchoredItem->WillReflow(*aPresContext);
mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus); mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus);
mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height); mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height);
@@ -94,7 +95,8 @@ NS_METHOD nsPlaceholderFrame::Reflow(nsIPresContext* aPresContext,
// of the incremental reflow methods and propagating things down // of the incremental reflow methods and propagating things down
// properly to the contained frame. // properly to the contained frame.
nsReflowMetrics desiredSize(nsnull); nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aReflowState.maxSize); nsReflowState reflowState(mAnchoredItem, aReflowState, aReflowState.maxSize,
eReflowReason_Resize);
mAnchoredItem->WillReflow(*aPresContext); mAnchoredItem->WillReflow(*aPresContext);
mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus); mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus);
mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height); mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height);

View File

@@ -325,7 +325,7 @@ NS_METHOD nsAbsoluteFrame::Reflow(nsIPresContext* aPresContext,
} }
nsReflowMetrics desiredSize(nsnull); nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Initial, availSize); nsReflowState reflowState(mFrame, aReflowState, availSize, eReflowReason_Initial);
mFrame->WillReflow(*aPresContext); mFrame->WillReflow(*aPresContext);
mFrame->Reflow(aPresContext, desiredSize, reflowState, aStatus); mFrame->Reflow(aPresContext, desiredSize, reflowState, aStatus);

View File

@@ -101,7 +101,7 @@ nsBlockReflowState::~nsBlockReflowState()
nsresult nsresult
nsBlockReflowState::Initialize(nsIPresContext* aPresContext, nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockFrame* aBlock) nsBlockFrame* aBlock)
{ {
@@ -114,10 +114,11 @@ nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
mListPositionOutside = PR_FALSE; mListPositionOutside = PR_FALSE;
mCurrentLine = nsnull; mCurrentLine = nsnull;
mPrevKidFrame = nsnull; mPrevKidFrame = nsnull;
reflowState = &aReflowState;
mX = 0; mX = 0;
mY = 0; mY = 0;
mAvailSize = aMaxSize; mAvailSize = reflowState->maxSize;
mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE); mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE);
mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE); mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE);
mMaxElementSizePointer = aMaxElementSize; mMaxElementSizePointer = aMaxElementSize;
@@ -447,7 +448,7 @@ nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState, nsReflowState& aReflowState,
nsRect& aDesiredRect, nsRect& aDesiredRect,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
@@ -955,15 +956,15 @@ done:
} }
nsresult nsresult
nsBlockFrame::InitializeState(nsIPresContext* aPresContext, nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockReflowState& aState) nsBlockReflowState& aState)
{ {
nsresult rv; nsresult rv;
rv = aState.Initialize(aPresContext, aSpaceManager, rv = aState.Initialize(aPresContext, aSpaceManager,
aMaxSize, aMaxElementSize, this); aReflowState, aMaxElementSize, this);
// Apply border and padding adjustments for regular frames only // Apply border and padding adjustments for regular frames only
if (!aState.mBlockIsPseudo) { if (!aState.mBlockIsPseudo) {
@@ -1173,7 +1174,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
} }
aStatus = NS_FRAME_COMPLETE; aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize, rv = InitializeState(aPresContext, aSpaceManager, aReflowState,
aDesiredSize.maxElementSize, state); aDesiredSize.maxElementSize, state);
NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d", NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d",

View File

@@ -59,7 +59,7 @@ struct nsBlockReflowState {
nsresult Initialize(nsIPresContext* aPresContext, nsresult Initialize(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockFrame* aBlock); nsBlockFrame* aBlock);
@@ -86,6 +86,7 @@ struct nsBlockReflowState {
PRPackedBool mUnconstrainedHeight; PRPackedBool mUnconstrainedHeight;
nsSize* mMaxElementSizePointer; nsSize* mMaxElementSizePointer;
nscoord mKidXMost; nscoord mKidXMost;
const nsReflowState* reflowState;
// Change in width since last reflow // Change in width since last reflow
nscoord mDeltaWidth; nscoord mDeltaWidth;
@@ -216,7 +217,7 @@ public:
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState, nsReflowState& aReflowState,
nsRect& aDesiredRect, nsRect& aDesiredRect,
nsReflowStatus& aStatus); nsReflowStatus& aStatus);
@@ -234,11 +235,11 @@ protected:
virtual void WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow); virtual void WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow);
nsresult InitializeState(nsIPresContext* aPresContext, nsresult InitializeState(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockReflowState& aState); nsBlockReflowState& aState);
void ComputeDesiredRect(nsBlockReflowState& aState, void ComputeDesiredRect(nsBlockReflowState& aState,
const nsSize& aMaxSize, const nsSize& aMaxSize,

View File

@@ -101,7 +101,7 @@ nsBlockReflowState::~nsBlockReflowState()
nsresult nsresult
nsBlockReflowState::Initialize(nsIPresContext* aPresContext, nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockFrame* aBlock) nsBlockFrame* aBlock)
{ {
@@ -114,10 +114,11 @@ nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
mListPositionOutside = PR_FALSE; mListPositionOutside = PR_FALSE;
mCurrentLine = nsnull; mCurrentLine = nsnull;
mPrevKidFrame = nsnull; mPrevKidFrame = nsnull;
reflowState = &aReflowState;
mX = 0; mX = 0;
mY = 0; mY = 0;
mAvailSize = aMaxSize; mAvailSize = reflowState->maxSize;
mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE); mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE);
mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE); mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE);
mMaxElementSizePointer = aMaxElementSize; mMaxElementSizePointer = aMaxElementSize;
@@ -447,7 +448,7 @@ nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState, nsReflowState& aReflowState,
nsRect& aDesiredRect, nsRect& aDesiredRect,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
@@ -955,15 +956,15 @@ done:
} }
nsresult nsresult
nsBlockFrame::InitializeState(nsIPresContext* aPresContext, nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockReflowState& aState) nsBlockReflowState& aState)
{ {
nsresult rv; nsresult rv;
rv = aState.Initialize(aPresContext, aSpaceManager, rv = aState.Initialize(aPresContext, aSpaceManager,
aMaxSize, aMaxElementSize, this); aReflowState, aMaxElementSize, this);
// Apply border and padding adjustments for regular frames only // Apply border and padding adjustments for regular frames only
if (!aState.mBlockIsPseudo) { if (!aState.mBlockIsPseudo) {
@@ -1173,7 +1174,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
} }
aStatus = NS_FRAME_COMPLETE; aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize, rv = InitializeState(aPresContext, aSpaceManager, aReflowState,
aDesiredSize.maxElementSize, state); aDesiredSize.maxElementSize, state);
NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d", NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d",

View File

@@ -101,7 +101,7 @@ nsBlockReflowState::~nsBlockReflowState()
nsresult nsresult
nsBlockReflowState::Initialize(nsIPresContext* aPresContext, nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockFrame* aBlock) nsBlockFrame* aBlock)
{ {
@@ -114,10 +114,11 @@ nsBlockReflowState::Initialize(nsIPresContext* aPresContext,
mListPositionOutside = PR_FALSE; mListPositionOutside = PR_FALSE;
mCurrentLine = nsnull; mCurrentLine = nsnull;
mPrevKidFrame = nsnull; mPrevKidFrame = nsnull;
reflowState = &aReflowState;
mX = 0; mX = 0;
mY = 0; mY = 0;
mAvailSize = aMaxSize; mAvailSize = reflowState->maxSize;
mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE); mUnconstrainedWidth = PRBool(mAvailSize.width == NS_UNCONSTRAINEDSIZE);
mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE); mUnconstrainedHeight = PRBool(mAvailSize.height == NS_UNCONSTRAINEDSIZE);
mMaxElementSizePointer = aMaxElementSize; mMaxElementSizePointer = aMaxElementSize;
@@ -447,7 +448,7 @@ nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState, nsReflowState& aReflowState,
nsRect& aDesiredRect, nsRect& aDesiredRect,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
@@ -955,15 +956,15 @@ done:
} }
nsresult nsresult
nsBlockFrame::InitializeState(nsIPresContext* aPresContext, nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager, nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nsBlockReflowState& aState) nsBlockReflowState& aState)
{ {
nsresult rv; nsresult rv;
rv = aState.Initialize(aPresContext, aSpaceManager, rv = aState.Initialize(aPresContext, aSpaceManager,
aMaxSize, aMaxElementSize, this); aReflowState, aMaxElementSize, this);
// Apply border and padding adjustments for regular frames only // Apply border and padding adjustments for regular frames only
if (!aState.mBlockIsPseudo) { if (!aState.mBlockIsPseudo) {
@@ -1173,7 +1174,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
} }
aStatus = NS_FRAME_COMPLETE; aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize, rv = InitializeState(aPresContext, aSpaceManager, aReflowState,
aDesiredSize.maxElementSize, state); aDesiredSize.maxElementSize, state);
NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d", NS_FRAME_TRACE_MSG(("enter nsBlockFrame::Reflow: reason=%d deltaWidth=%d",

View File

@@ -181,7 +181,7 @@ NS_METHOD nsBodyFrame::Reflow(nsIPresContext* aPresContext,
// It's a floating frame that's the target. Reflow the body making it // It's a floating frame that's the target. Reflow the body making it
// look like a resize occured. This will reflow the placeholder which will // look like a resize occured. This will reflow the placeholder which will
// resize the floating frame... // resize the floating frame...
nsReflowState reflowState(eReflowReason_Resize, aReflowState.maxSize); nsReflowState reflowState(next, aReflowState, aReflowState.maxSize, eReflowReason_Resize);
return Reflow(aPresContext, aDesiredSize, reflowState, aStatus); return Reflow(aPresContext, aDesiredSize, reflowState, aStatus);
} }
} }
@@ -207,7 +207,7 @@ NS_METHOD nsBodyFrame::Reflow(nsIPresContext* aPresContext,
// Get the column's desired rect // Get the column's desired rect
nsIRunaround* reflowRunaround; nsIRunaround* reflowRunaround;
nsReflowState reflowState(aReflowState, kidMaxSize); nsReflowState reflowState(mFirstChild, aReflowState, kidMaxSize);
nsRect desiredRect; nsRect desiredRect;
mFirstChild->WillReflow(*aPresContext); mFirstChild->WillReflow(*aPresContext);

View File

@@ -53,31 +53,33 @@ NS_DEF_PTR(nsIContentDelegate);
class nsInlineState class nsInlineState
{ {
public: public:
nsStyleFont* font; // style font nsStyleFont* font; // style font
nsMargin borderPadding; // inner margin nsMargin borderPadding; // inner margin
nsSize mStyleSize; nsSize mStyleSize;
PRIntn mStyleSizeFlags; PRIntn mStyleSizeFlags;
nsSize availSize; // available space in which to reflow (starts as max size minus insets) nsSize availSize; // available space in which to reflow (starts as max size minus insets)
nsSize* maxElementSize; // maximum element size (may be null) nsSize* maxElementSize; // maximum element size (may be null)
nscoord x; // running x-offset (starts at left inner edge) nscoord x; // running x-offset (starts at left inner edge)
const nscoord y; // y-offset (top inner edge) const nscoord y; // y-offset (top inner edge)
nscoord maxAscent; // max child ascent nscoord maxAscent; // max child ascent
nscoord maxDescent; // max child descent nscoord maxDescent; // max child descent
nscoord* ascents; // ascent information for each child nscoord* ascents; // ascent information for each child
PRBool unconstrainedWidth; PRBool unconstrainedWidth;
PRBool unconstrainedHeight; PRBool unconstrainedHeight;
nsLineLayout* lineLayout; nsLineLayout* lineLayout;
PRBool atBreakPoint; PRBool atBreakPoint;
const nsReflowState& reflowState;
// Constructor // Constructor
nsInlineState(nsIPresContext* aPresContext, nsInlineState(nsIPresContext* aPresContext,
nsIFrame* aInlineFrame, nsIFrame* aInlineFrame,
nsStyleFont* aStyleFont, nsStyleFont* aStyleFont,
const nsMargin& aBorderPadding, const nsMargin& aBorderPadding,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize) nsSize* aMaxElementSize)
: x(aBorderPadding.left), // determined by inner edge : x(aBorderPadding.left), // determined by inner edge
y(aBorderPadding.top) // determined by inner edge y(aBorderPadding.top), // determined by inner edge
reflowState(aReflowState)
{ {
nsBlockReflowState* brs = nsBlockReflowState* brs =
nsBlockFrame::FindBlockReflowState(aPresContext, aInlineFrame); nsBlockFrame::FindBlockReflowState(aPresContext, aInlineFrame);
@@ -87,16 +89,16 @@ public:
font = aStyleFont; font = aStyleFont;
borderPadding = aBorderPadding; borderPadding = aBorderPadding;
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE); unconstrainedWidth = PRBool(reflowState.maxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE); unconstrainedHeight = PRBool(reflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
// If we're constrained adjust the available size so it excludes space // If we're constrained adjust the available size so it excludes space
// needed for border/padding // needed for border/padding
availSize.width = aMaxSize.width; availSize.width = reflowState.maxSize.width;
if (PR_FALSE == unconstrainedWidth) { if (PR_FALSE == unconstrainedWidth) {
availSize.width -= aBorderPadding.left + aBorderPadding.right; availSize.width -= aBorderPadding.left + aBorderPadding.right;
} }
availSize.height = aMaxSize.height; availSize.height = reflowState.maxSize.height;
if (PR_FALSE == unconstrainedHeight) { if (PR_FALSE == unconstrainedHeight) {
availSize.height -= aBorderPadding.top + aBorderPadding.bottom; availSize.height -= aBorderPadding.top + aBorderPadding.bottom;
} }
@@ -276,7 +278,8 @@ PRBool nsInlineFrame::ReflowMappedChildrenFrom(nsIPresContext* aPresContext,
for (nsIFrame* kidFrame = aChildFrame; nsnull != kidFrame; ) { for (nsIFrame* kidFrame = aChildFrame; nsnull != kidFrame; ) {
nsReflowMetrics kidSize(pKidMaxElementSize); nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize);
nsReflowStatus status; nsReflowStatus status;
// Reflow the child into the available space // Reflow the child into the available space
@@ -462,7 +465,8 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
} }
#endif #endif
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
@@ -716,7 +720,8 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not // Try to reflow the child into the available space. It might not
// fit or might need continuing. // fit or might need continuing.
nsReflowMetrics kidSize(pKidMaxElementSize); nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame, aPresContext, kidSize, nsReflowStatus status = ReflowChild(kidFrame, aPresContext, kidSize,
kidReflowState); kidReflowState);
@@ -828,7 +833,7 @@ NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
nsMargin borderPadding; nsMargin borderPadding;
styleSpacing->CalcBorderPaddingFor(this, borderPadding); styleSpacing->CalcBorderPaddingFor(this, borderPadding);
nsInlineState state(aPresContext, this, styleFont, borderPadding, nsInlineState state(aPresContext, this, styleFont, borderPadding,
aReflowState.maxSize, aDesiredSize.maxElementSize); aReflowState, aDesiredSize.maxElementSize);
InitializeState(aPresContext, state); InitializeState(aPresContext, state);
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset); state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
@@ -851,7 +856,7 @@ NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
// The command is passing through us. Get the next frame in the reflow chain // The command is passing through us. Get the next frame in the reflow chain
nsIFrame* kidFrame = aReflowState.reflowCommand->GetNext(); nsIFrame* kidFrame = aReflowState.reflowCommand->GetNext();
nsReflowMetrics kidSize(aDesiredSize.maxElementSize); nsReflowMetrics kidSize(aDesiredSize.maxElementSize);
nsReflowState kidReflowState(aReflowState.reflowCommand, state.availSize); nsReflowState kidReflowState(kidFrame, aReflowState, state.availSize);
// Restore our state as if nextFrame is the next frame to reflow // Restore our state as if nextFrame is the next frame to reflow
PRInt32 kidIndex = RecoverState(aPresContext, state, kidFrame); PRInt32 kidIndex = RecoverState(aPresContext, state, kidFrame);

View File

@@ -677,7 +677,8 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand,
} }
} }
nsReflowState kidReflowState(kidReason, kidAvailSize); nsReflowState kidReflowState(kidFrame, *mBlockReflowState.reflowState,
kidAvailSize, kidReason);
kidReflowState.reflowCommand = aReflowCommand; kidReflowState.reflowCommand = aReflowCommand;
mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE; mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE;
nscoord dx = mState.mX + kidMargin.left; nscoord dx = mState.mX + kidMargin.left;

View File

@@ -78,9 +78,9 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext* aPresContext,
// Dispatch the reflow command to our content child. Allow it to be as high // Dispatch the reflow command to our content child. Allow it to be as high
// as it wants // as it wants
nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE); nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE);
nsReflowState reflowState(aReflowState.reflowCommand, maxSize); nsReflowState kidReflowState(mFirstChild, aReflowState, maxSize);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState); aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState);
// Place and size the child. Make sure the child is at least as // Place and size the child. Make sure the child is at least as
// tall as our max size (the containing window) // tall as our max size (the containing window)
@@ -119,9 +119,11 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext* aPresContext,
// Resize our frame allowing it only to be as big as we are // Resize our frame allowing it only to be as big as we are
// XXX Pay attention to the page's border and padding... // XXX Pay attention to the page's border and padding...
if (nsnull != mFirstChild) { if (nsnull != mFirstChild) {
nsReflowState kidReflowState(mFirstChild, aReflowState, aReflowState.maxSize);
// Get the child's desired size // Get the child's desired size
mFirstChild->WillReflow(*aPresContext); mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, aReflowState); aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState);
mLastContentIsComplete = NS_FRAME_IS_COMPLETE(aStatus); mLastContentIsComplete = NS_FRAME_IS_COMPLETE(aStatus);
// Make sure the child is at least as tall as our max size (the containing window) // Make sure the child is at least as tall as our max size (the containing window)

View File

@@ -79,7 +79,8 @@ NS_METHOD nsPlaceholderFrame::Reflow(nsIPresContext* aPresContext,
// Resize reflow the anchored item into the available space // Resize reflow the anchored item into the available space
// XXX Check for complete? // XXX Check for complete?
nsReflowMetrics desiredSize(nsnull); nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Initial, aReflowState.maxSize); nsReflowState reflowState(mAnchoredItem, aReflowState, aReflowState.maxSize,
eReflowReason_Initial);
mAnchoredItem->WillReflow(*aPresContext); mAnchoredItem->WillReflow(*aPresContext);
mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus); mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus);
mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height); mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height);
@@ -94,7 +95,8 @@ NS_METHOD nsPlaceholderFrame::Reflow(nsIPresContext* aPresContext,
// of the incremental reflow methods and propagating things down // of the incremental reflow methods and propagating things down
// properly to the contained frame. // properly to the contained frame.
nsReflowMetrics desiredSize(nsnull); nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aReflowState.maxSize); nsReflowState reflowState(mAnchoredItem, aReflowState, aReflowState.maxSize,
eReflowReason_Resize);
mAnchoredItem->WillReflow(*aPresContext); mAnchoredItem->WillReflow(*aPresContext);
mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus); mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus);
mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height); mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height);

View File

@@ -112,11 +112,12 @@ NS_METHOD RootFrame::Reflow(nsIPresContext* aPresContext,
// Reflow our pseudo frame. It will choose whetever height its child frame // Reflow our pseudo frame. It will choose whetever height its child frame
// wants // wants
nsReflowMetrics desiredSize(nsnull);
if (nsnull != mFirstChild) { if (nsnull != mFirstChild) {
nsReflowMetrics desiredSize(nsnull);
nsReflowState kidReflowState(mFirstChild, aReflowState, aReflowState.maxSize);
mFirstChild->WillReflow(*aPresContext); mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, desiredSize, aReflowState); aStatus = ReflowChild(mFirstChild, aPresContext, desiredSize, kidReflowState);
// Place and size the child // Place and size the child
nsRect rect(0, 0, desiredSize.width, desiredSize.height); nsRect rect(0, 0, desiredSize.width, desiredSize.height);
@@ -279,17 +280,17 @@ NS_METHOD RootContentFrame::Reflow(nsIPresContext* aPresContext,
NS_ASSERTION(aReflowState.reflowCommand->GetTarget() != this, NS_ASSERTION(aReflowState.reflowCommand->GetTarget() != this,
"root content frame is reflow command target"); "root content frame is reflow command target");
nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE);
nsReflowState reflowState(aReflowState.reflowCommand, maxSize);
// Verify the next frame in the reflow chain is our child frame // Verify the next frame in the reflow chain is our child frame
nsIFrame* next = aReflowState.reflowCommand->GetNext(); nsIFrame* next = aReflowState.reflowCommand->GetNext();
NS_ASSERTION(next == mFirstChild, "unexpected next reflow command frame"); NS_ASSERTION(next == mFirstChild, "unexpected next reflow command frame");
nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE);
nsReflowState kidReflowState(next, aReflowState, maxSize);
// Dispatch the reflow command to our child frame. Allow it to be as high // Dispatch the reflow command to our child frame. Allow it to be as high
// as it wants // as it wants
mFirstChild->WillReflow(*aPresContext); mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState); aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState);
// Place and size the child. Make sure the child is at least as // Place and size the child. Make sure the child is at least as
// tall as our max size (the containing window) // tall as our max size (the containing window)
@@ -315,11 +316,11 @@ NS_METHOD RootContentFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics kidSize(aDesiredSize.maxElementSize); nsReflowMetrics kidSize(aDesiredSize.maxElementSize);
nsSize pageSize(aPresContext->GetPageWidth(), nsSize pageSize(aPresContext->GetPageWidth(),
aPresContext->GetPageHeight()); aPresContext->GetPageHeight());
nsReflowState reflowState(aReflowState.reason, pageSize);
// Tile the pages vertically // Tile the pages vertically
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) { for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
// Reflow the page // Reflow the page
nsReflowState kidReflowState(kidFrame, aReflowState, pageSize);
nsReflowStatus status; nsReflowStatus status;
// Place and size the page. If the page is narrower than our max width then // Place and size the page. If the page is narrower than our max width then
@@ -332,7 +333,7 @@ NS_METHOD RootContentFrame::Reflow(nsIPresContext* aPresContext,
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
kidFrame->MoveTo(x, y); kidFrame->MoveTo(x, y);
status = ReflowChild(kidFrame, aPresContext, kidSize, reflowState); status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
kidFrame->SetRect(nsRect(x, y, kidSize.width, kidSize.height)); kidFrame->SetRect(nsRect(x, y, kidSize.width, kidSize.height));
kidFrame->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED); kidFrame->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
@@ -380,12 +381,12 @@ NS_METHOD RootContentFrame::Reflow(nsIPresContext* aPresContext,
// Allow the frame to be as wide as our max width, and as high // Allow the frame to be as wide as our max width, and as high
// as it wants to be. // as it wants to be.
nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE); nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE);
nsReflowState reflowState(aReflowState.reason, maxSize); nsReflowState kidReflowState(mFirstChild, aReflowState, maxSize);
// Get the child's desired size. Our child's desired height is our // Get the child's desired size. Our child's desired height is our
// desired size // desired size
mFirstChild->WillReflow(*aPresContext); mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState); aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState);
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
// Place and size the child. Make sure the child is at least as // Place and size the child. Make sure the child is at least as

View File

@@ -181,7 +181,7 @@ NS_IMETHODIMP nsInputFileFrame::Reflow(nsIPresContext* aCX,
aDesiredSize.height = 0; aDesiredSize.height = 0;
childFrame = mFirstChild; childFrame = mFirstChild;
while (nsnull != childFrame) { while (nsnull != childFrame) {
nsReflowState reflowState(aReflowState, maxSize); nsReflowState reflowState(childFrame, aReflowState, maxSize);
nsresult result = childFrame->Reflow(aCX, desiredSize, reflowState, aStatus); nsresult result = childFrame->Reflow(aCX, desiredSize, reflowState, aStatus);
// XXX check aStatus ?? // XXX check aStatus ??
if (NS_OK != result) { if (NS_OK != result) {

View File

@@ -300,7 +300,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
printf(" nsTableCellFrame::ResizeReflow calling ReflowChild with availSize=%d,%d\n", printf(" nsTableCellFrame::ResizeReflow calling ReflowChild with availSize=%d,%d\n",
availSize.width, availSize.height); availSize.width, availSize.height);
nsReflowMetrics kidSize(pMaxElementSize); nsReflowMetrics kidSize(pMaxElementSize);
nsReflowState kidReflowState(aReflowState, availSize); nsReflowState kidReflowState(mFirstChild, aReflowState, availSize);
mFirstChild->WillReflow(*aPresContext); mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState); aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);

View File

@@ -89,7 +89,7 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext* aPresContext,
// give the child frame a chance to reflow, even though we know it'll have 0 size // give the child frame a chance to reflow, even though we know it'll have 0 size
nsReflowMetrics kidSize(nsnull); nsReflowMetrics kidSize(nsnull);
nsReflowState kidReflowState(eReflowReason_Initial, nsSize(0,0)); nsReflowState kidReflowState(kidFrame, aReflowState, nsSize(0,0), eReflowReason_Initial);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize, nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize,
kidReflowState); kidReflowState);

View File

@@ -73,6 +73,9 @@ struct InnerTableReflowState {
// The body's style molecule // The body's style molecule
// Our reflow state
const nsReflowState& reflowState;
// The body's available size (computed from the body's parent) // The body's available size (computed from the body's parent)
nsSize availSize; nsSize availSize;
@@ -98,23 +101,24 @@ struct InnerTableReflowState {
// cache the total height of the footers for placing body rows // cache the total height of the footers for placing body rows
nscoord footerHeight; nscoord footerHeight;
InnerTableReflowState(nsIPresContext* aPresContext, InnerTableReflowState(nsIPresContext* aPresContext,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
const nsMargin& aBorderPadding) const nsMargin& aBorderPadding)
: reflowState(aReflowState)
{ {
prevMaxPosBottomMargin = 0; prevMaxPosBottomMargin = 0;
prevMaxNegBottomMargin = 0; prevMaxNegBottomMargin = 0;
y=0; // border/padding/margin??? y=0; // border/padding/margin???
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE); unconstrainedWidth = PRBool(aReflowState.maxSize.width == NS_UNCONSTRAINEDSIZE);
availSize.width = aMaxSize.width; availSize.width = aReflowState.maxSize.width;
if (!unconstrainedWidth) { if (!unconstrainedWidth) {
availSize.width -= aBorderPadding.left + aBorderPadding.right; availSize.width -= aBorderPadding.left + aBorderPadding.right;
} }
leftInset = aBorderPadding.left; leftInset = aBorderPadding.left;
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE); unconstrainedHeight = PRBool(aReflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
availSize.height = aMaxSize.height; availSize.height = aReflowState.maxSize.height;
if (!unconstrainedHeight) { if (!unconstrainedHeight) {
availSize.height -= aBorderPadding.top + aBorderPadding.bottom; availSize.height -= aBorderPadding.top + aBorderPadding.bottom;
} }
@@ -518,8 +522,8 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
if (PR_FALSE==IsFirstPassValid()) if (PR_FALSE==IsFirstPassValid())
{ // we treat the table as if we've never seen the layout data before { // we treat the table as if we've never seen the layout data before
mPass = kPASS_FIRST; mPass = kPASS_FIRST;
aStatus = ResizeReflowPass1(aPresContext, aDesiredSize, aStatus = ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState,
aReflowState.maxSize, aDesiredSize.maxElementSize); aDesiredSize.maxElementSize);
// check result // check result
} }
mPass = kPASS_SECOND; mPass = kPASS_SECOND;
@@ -530,7 +534,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
// assign table width // assign table width
SetTableWidth(aPresContext); SetTableWidth(aPresContext);
aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aReflowState.maxSize, aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aReflowState,
aDesiredSize.maxElementSize, 0, 0); aDesiredSize.maxElementSize, 0, 0);
if (gsTiming) { if (gsTiming) {
@@ -563,14 +567,17 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
*/ */
nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize) nsSize* aMaxElementSize)
{ {
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
NS_PRECONDITION(aReflowState.parentReflowState->frame == mGeometricParent,
"bad parent reflow state");
NS_ASSERTION(nsnull!=aPresContext, "bad pres context param"); NS_ASSERTION(nsnull!=aPresContext, "bad pres context param");
NS_ASSERTION(nsnull==mPrevInFlow, "illegal call, cannot call pass 1 on a continuing frame."); NS_ASSERTION(nsnull==mPrevInFlow, "illegal call, cannot call pass 1 on a continuing frame.");
if (gsDebug==PR_TRUE) printf("nsTableFrame::ResizeReflow Pass1: maxSize=%d,%d\n", if (gsDebug==PR_TRUE) printf("nsTableFrame::ResizeReflow Pass1: maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height); aReflowState.maxSize.width, aReflowState.maxSize.height);
if (PR_TRUE==gsDebug) printf ("*** tableframe reflow pass1\t\t%d\n", this); if (PR_TRUE==gsDebug) printf ("*** tableframe reflow pass1\t\t%d\n", this);
nsReflowStatus result = NS_FRAME_COMPLETE; nsReflowStatus result = NS_FRAME_COMPLETE;
@@ -684,7 +691,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
} }
nsSize maxKidElementSize; nsSize maxKidElementSize;
nsReflowState kidReflowState(eReflowReason_Resize, availSize); nsReflowState kidReflowState(kidFrame, aReflowState, availSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
@@ -763,15 +771,18 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
*/ */
nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext, nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
PRInt32 aMinCaptionWidth, PRInt32 aMinCaptionWidth,
PRInt32 mMaxCaptionWidth) PRInt32 mMaxCaptionWidth)
{ {
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
NS_PRECONDITION(aReflowState.parentReflowState->frame == mGeometricParent,
"bad parent reflow state");
if (PR_TRUE==gsDebug) printf ("***tableframe reflow pass2\t\t%d\n", this); if (PR_TRUE==gsDebug) printf ("***tableframe reflow pass2\t\t%d\n", this);
if (gsDebug==PR_TRUE) if (gsDebug==PR_TRUE)
printf("nsTableFrame::ResizeReflow Pass2: maxSize=%d,%d\n", printf("nsTableFrame::ResizeReflow Pass2: maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height); aReflowState.maxSize.width, aReflowState.maxSize.height);
nsReflowStatus result = NS_FRAME_COMPLETE; nsReflowStatus result = NS_FRAME_COMPLETE;
@@ -805,7 +816,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
nsMargin myBorderPadding; nsMargin myBorderPadding;
mySpacing->CalcBorderPaddingFor(this, myBorderPadding); mySpacing->CalcBorderPaddingFor(this, myBorderPadding);
InnerTableReflowState state(aPresContext, aMaxSize, myBorderPadding); InnerTableReflowState state(aPresContext, aReflowState, myBorderPadding);
// Reflow the existing frames // Reflow the existing frames
if (nsnull != mFirstChild) { if (nsnull != mFirstChild) {
@@ -852,7 +863,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
// Return our desired rect // Return our desired rect
//NS_ASSERTION(0<state.y, "illegal height after reflow"); //NS_ASSERTION(0<state.y, "illegal height after reflow");
aDesiredSize.width = aMaxSize.width; aDesiredSize.width = aReflowState.maxSize.width;
aDesiredSize.height = state.y; aDesiredSize.height = state.y;
// shrink wrap rows to height of tallest cell in that row // shrink wrap rows to height of tallest cell in that row
@@ -1060,7 +1071,8 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
} }
// Reflow the child into the available space // Reflow the child into the available space
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
@@ -1279,7 +1291,8 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
mLastContentIsComplete = prevLastContentIsComplete; mLastContentIsComplete = prevLastContentIsComplete;
break; break;
} }
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
@@ -1494,7 +1507,8 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not // Try to reflow the child into the available space. It might not
// fit or might need continuing. // fit or might need continuing.
nsReflowMetrics kidSize(pKidMaxElementSize); nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Initial, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Initial);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize, kidReflowState); nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize, kidReflowState);

View File

@@ -183,10 +183,10 @@ protected:
* *
* @see ResizeReflow * @see ResizeReflow
*/ */
virtual nsReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext, virtual nsReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize); nsSize* aMaxElementSize);
/** second pass of ResizeReflow. /** second pass of ResizeReflow.
* lays out all table content with aMaxSize(computed_table_width, given_table_height) * lays out all table content with aMaxSize(computed_table_width, given_table_height)
@@ -201,7 +201,7 @@ protected:
*/ */
virtual nsReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext, virtual nsReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
PRInt32 aMinCaptionWidth, PRInt32 aMinCaptionWidth,
PRInt32 mMaxCaptionWidth); PRInt32 mMaxCaptionWidth);

View File

@@ -53,6 +53,9 @@ struct OuterTableReflowState {
// The presentation context // The presentation context
nsIPresContext *pc; nsIPresContext *pc;
// Our reflow state
const nsReflowState& reflowState;
// The total available size (computed from the parent) // The total available size (computed from the parent)
nsSize availSize; nsSize availSize;
// The available size for the inner table frame // The available size for the inner table frame
@@ -73,17 +76,18 @@ struct OuterTableReflowState {
PRBool firstRowGroup; PRBool firstRowGroup;
PRBool processingCaption; PRBool processingCaption;
OuterTableReflowState(nsIPresContext* aPresContext, OuterTableReflowState(nsIPresContext* aPresContext,
const nsSize& aMaxSize) const nsReflowState& aReflowState)
: reflowState(aReflowState)
{ {
pc = aPresContext; pc = aPresContext;
availSize.width = aMaxSize.width; availSize.width = reflowState.maxSize.width;
availSize.height = aMaxSize.height; availSize.height = reflowState.maxSize.height;
prevMaxPosBottomMargin = 0; prevMaxPosBottomMargin = 0;
prevMaxNegBottomMargin = 0; prevMaxNegBottomMargin = 0;
y=0; // border/padding/margin??? y=0; // border/padding/margin???
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE); unconstrainedWidth = PRBool(aReflowState.maxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE); unconstrainedHeight = PRBool(aReflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
firstRowGroup = PR_TRUE; firstRowGroup = PR_TRUE;
processingCaption = PR_FALSE; processingCaption = PR_FALSE;
} }
@@ -206,13 +210,13 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
OuterTableReflowState state(aPresContext, aReflowState.maxSize); OuterTableReflowState state(aPresContext, aReflowState);
// lay out captions pass 1, if necessary // lay out captions pass 1, if necessary
if (PR_FALSE==IsFirstPassValid()) if (PR_FALSE==IsFirstPassValid())
{ {
mFirstPassValid = PR_TRUE; mFirstPassValid = PR_TRUE;
aStatus = ResizeReflowCaptionsPass1(aPresContext); aStatus = ResizeReflowCaptionsPass1(aPresContext, state);
} }
@@ -222,7 +226,9 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
// we treat the table as if we've never seen the layout data before // we treat the table as if we've never seen the layout data before
mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_FIRST); mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_FIRST);
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState.maxSize, nsReflowState innerTableReflowState(mInnerTableFrame, aReflowState, aReflowState.maxSize);
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize,
innerTableReflowState,
&innerTableMaxElementSize); &innerTableMaxElementSize);
mInnerTableFrame->RecalcLayoutData(); mInnerTableFrame->RecalcLayoutData();
@@ -897,20 +903,21 @@ nsTableOuterFrame::ReflowChild( nsIFrame* aKidFrame,
if (PR_TRUE==gsDebug) printf("reflowChild called with a bottom caption\n"); if (PR_TRUE==gsDebug) printf("reflowChild called with a bottom caption\n");
status = ResizeReflowBottomCaptionsPass2(aPresContext, aDesiredSize, status = ResizeReflowBottomCaptionsPass2(aPresContext, aDesiredSize,
aMaxSize, aMaxElementSize, aMaxSize, aMaxElementSize,
aState.y); aState.y, aState);
} }
else else
{ {
if (PR_TRUE==gsDebug) printf("reflowChild called with a top caption\n"); if (PR_TRUE==gsDebug) printf("reflowChild called with a top caption\n");
status = ResizeReflowTopCaptionsPass2(aPresContext, aDesiredSize, status = ResizeReflowTopCaptionsPass2(aPresContext, aDesiredSize,
aMaxSize, aMaxElementSize); aMaxSize, aMaxElementSize, aState);
} }
} }
else else
{ {
if (PR_TRUE==gsDebug) printf("reflowChild called with a table body\n"); if (PR_TRUE==gsDebug) printf("reflowChild called with a table body\n");
status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize, aState.innerTableMaxSize, nsReflowState kidReflowState(aKidFrame, aState.reflowState, aState.innerTableMaxSize);
aMaxElementSize, status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize,
kidReflowState, aMaxElementSize,
mMinCaptionWidth, mMaxCaptionWidth); mMinCaptionWidth, mMaxCaptionWidth);
} }
if (PR_TRUE==gsDebug) if (PR_TRUE==gsDebug)
@@ -1015,7 +1022,8 @@ void nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext)
nsReflowStatus nsReflowStatus
nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext) nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext,
OuterTableReflowState& aState)
{ {
if (nsnull!=mCaptionFrames) if (nsnull!=mCaptionFrames)
{ {
@@ -1027,7 +1035,7 @@ nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext)
nsReflowMetrics desiredSize(&maxElementSize); nsReflowMetrics desiredSize(&maxElementSize);
nsTableCaptionFrame *captionFrame = (nsTableCaptionFrame *)mCaptionFrames->ElementAt(captionIndex); nsTableCaptionFrame *captionFrame = (nsTableCaptionFrame *)mCaptionFrames->ElementAt(captionIndex);
nsReflowStatus status; nsReflowStatus status;
nsReflowState reflowState(eReflowReason_Resize, maxSize); nsReflowState reflowState(captionFrame, aState.reflowState, maxSize, eReflowReason_Resize);
captionFrame->WillReflow(*aPresContext); captionFrame->WillReflow(*aPresContext);
captionFrame->Reflow(aPresContext, desiredSize, reflowState, status); captionFrame->Reflow(aPresContext, desiredSize, reflowState, status);
if (mMinCaptionWidth<maxElementSize.width) if (mMinCaptionWidth<maxElementSize.width)
@@ -1042,10 +1050,11 @@ nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext)
} }
nsReflowStatus nsReflowStatus
nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext, nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsSize& aMaxSize,
nsSize* aMaxElementSize) nsSize* aMaxElementSize,
OuterTableReflowState& aState)
{ {
nsReflowStatus result = NS_FRAME_COMPLETE; nsReflowStatus result = NS_FRAME_COMPLETE;
nscoord topCaptionY = 0; nscoord topCaptionY = 0;
@@ -1076,7 +1085,7 @@ nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
if (NS_FRAME_IS_COMPLETE(result)) if (NS_FRAME_IS_COMPLETE(result))
{ {
nsReflowMetrics desiredSize(nsnull); nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aMaxSize); nsReflowState reflowState(captionFrame, aState.reflowState, aMaxSize, eReflowReason_Resize);
captionFrame->WillReflow(*aPresContext); captionFrame->WillReflow(*aPresContext);
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState); result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);
// place the caption // place the caption
@@ -1114,7 +1123,8 @@ nsTableOuterFrame::ResizeReflowBottomCaptionsPass2(nsIPresContext* aPresContext
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsSize& aMaxSize,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nscoord aYOffset) nscoord aYOffset,
OuterTableReflowState& aState)
{ {
nsReflowStatus result = NS_FRAME_COMPLETE; nsReflowStatus result = NS_FRAME_COMPLETE;
nscoord bottomCaptionY = aYOffset; nscoord bottomCaptionY = aYOffset;
@@ -1137,7 +1147,7 @@ nsTableOuterFrame::ResizeReflowBottomCaptionsPass2(nsIPresContext* aPresContext
*/ */
// reflow the caption // reflow the caption
nsReflowMetrics desiredSize(nsnull); nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aMaxSize); nsReflowState reflowState(captionFrame, aState.reflowState, aMaxSize, eReflowReason_Resize);
captionFrame->WillReflow(*aPresContext); captionFrame->WillReflow(*aPresContext);
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState); result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);

View File

@@ -125,7 +125,8 @@ protected:
/** reflow the captions in an infinite space, caching the min/max sizes for each /** reflow the captions in an infinite space, caching the min/max sizes for each
*/ */
virtual nsReflowStatus ResizeReflowCaptionsPass1(nsIPresContext* aPresContext); virtual nsReflowStatus ResizeReflowCaptionsPass1(nsIPresContext* aPresContext,
OuterTableReflowState& aState);
/** reflow the top captions in a space constrained by the computed table width /** reflow the top captions in a space constrained by the computed table width
* and the heigth given to us by our parent. Top captions are laid down * and the heigth given to us by our parent. Top captions are laid down
@@ -134,7 +135,8 @@ protected:
virtual nsReflowStatus ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext, virtual nsReflowStatus ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsSize& aMaxSize,
nsSize* aMaxElementSize); nsSize* aMaxElementSize,
OuterTableReflowState& aState);
/** reflow the bottom captions in a space constrained by the computed table width /** reflow the bottom captions in a space constrained by the computed table width
* and the heigth given to us by our parent. Bottom captions are laid down * and the heigth given to us by our parent. Bottom captions are laid down
@@ -144,7 +146,8 @@ protected:
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsSize& aMaxSize,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nscoord aYOffset); nscoord aYOffset,
OuterTableReflowState& aState);
nscoord GetTopMarginFor(nsIPresContext* aCX, nscoord GetTopMarginFor(nsIPresContext* aCX,
OuterTableReflowState& aState, OuterTableReflowState& aState,

View File

@@ -41,6 +41,9 @@ static const PRBool gsDebug2 = PR_FALSE;
/* ----------- RowReflowState ---------- */ /* ----------- RowReflowState ---------- */
struct RowReflowState { struct RowReflowState {
// Our reflow state
const nsReflowState& reflowState;
// The body's available size (computed from the body's parent) // The body's available size (computed from the body's parent)
nsSize availSize; nsSize availSize;
@@ -64,16 +67,17 @@ struct RowReflowState {
nsTableFrame *tableFrame; nsTableFrame *tableFrame;
RowReflowState( nsIPresContext* aPresContext, RowReflowState( nsIPresContext* aPresContext,
const nsSize& aMaxSize) const nsReflowState& aReflowState)
: reflowState(aReflowState)
{ {
availSize.width = aMaxSize.width; availSize.width = reflowState.maxSize.width;
availSize.height = aMaxSize.height; availSize.height = reflowState.maxSize.height;
prevMaxPosBottomMargin = 0; prevMaxPosBottomMargin = 0;
prevMaxNegBottomMargin = 0; prevMaxNegBottomMargin = 0;
x=0; x=0;
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE); unconstrainedWidth = PRBool(reflowState.maxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE); unconstrainedHeight = PRBool(reflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
maxCellHeight=0; maxCellHeight=0;
maxCellVertSpace=0; maxCellVertSpace=0;
maxCellHorzSpace=0; maxCellHorzSpace=0;
@@ -343,7 +347,8 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width) if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
{ {
// Reflow the child into the available space // Reflow the child into the available space
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidReflowState); kidReflowState);
@@ -360,7 +365,8 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan); availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
kidAvailSize.width = availWidth; kidAvailSize.width = availWidth;
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
} }
@@ -633,7 +639,8 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan); availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
NS_ASSERTION(0<availWidth, "illegal width for this column"); NS_ASSERTION(0<availWidth, "illegal width for this column");
kidAvailSize.width = availWidth; kidAvailSize.width = availWidth;
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
if (nsnull!=pKidMaxElementSize) if (nsnull!=pKidMaxElementSize)
@@ -897,7 +904,8 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
nsReflowStatus status; nsReflowStatus status;
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width) if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
{ {
nsReflowState kidReflowState(eReflowReason_Initial, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Initial);
// Reflow the child into the available space // Reflow the child into the available space
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
@@ -914,7 +922,7 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan); availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
NS_ASSERTION(0<availWidth, "illegal width for this column"); NS_ASSERTION(0<availWidth, "illegal width for this column");
kidAvailSize.width = availWidth; kidAvailSize.width = availWidth;
nsReflowState kidReflowState(eReflowReason_Initial, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, eReflowReason_Initial);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
} }
@@ -1029,7 +1037,7 @@ nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
// Check for an overflow list // Check for an overflow list
MoveOverflowToChildList(); MoveOverflowToChildList();
RowReflowState state(aPresContext, aReflowState.maxSize); RowReflowState state(aPresContext, aReflowState);
mContentParent->GetContentParent((nsIFrame*&)(state.tableFrame)); mContentParent->GetContentParent((nsIFrame*&)(state.tableFrame));
// Reflow the existing frames // Reflow the existing frames

View File

@@ -43,6 +43,9 @@ NS_DEF_PTR(nsIContent);
/* ----------- RowGroupReflowState ---------- */ /* ----------- RowGroupReflowState ---------- */
struct RowGroupReflowState { struct RowGroupReflowState {
// Our reflow state
const nsReflowState& reflowState;
// The body's available size (computed from the body's parent) // The body's available size (computed from the body's parent)
nsSize availSize; nsSize availSize;
@@ -63,16 +66,17 @@ struct RowGroupReflowState {
// Remember the height of the first row, because it's our maxElementHeight (plus header/footers) // Remember the height of the first row, because it's our maxElementHeight (plus header/footers)
nscoord firstRowHeight; nscoord firstRowHeight;
RowGroupReflowState(nsIPresContext* aPresContext, RowGroupReflowState(nsIPresContext* aPresContext,
const nsSize& aMaxSize) const nsReflowState& aReflowState)
: reflowState(aReflowState)
{ {
availSize.width = aMaxSize.width; availSize.width = reflowState.maxSize.width;
availSize.height = aMaxSize.height; availSize.height = reflowState.maxSize.height;
prevMaxPosBottomMargin = 0; prevMaxPosBottomMargin = 0;
prevMaxNegBottomMargin = 0; prevMaxNegBottomMargin = 0;
y=0; // border/padding/margin??? y=0; // border/padding/margin???
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE); unconstrainedWidth = PRBool(reflowState.maxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE); unconstrainedHeight = PRBool(reflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
firstRow = PR_TRUE; firstRow = PR_TRUE;
firstRowHeight=0; firstRowHeight=0;
} }
@@ -296,7 +300,8 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
} }
// Reflow the child into the available space // Reflow the child into the available space
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
@@ -531,7 +536,8 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
mLastContentIsComplete = prevLastContentIsComplete; mLastContentIsComplete = prevLastContentIsComplete;
break; break;
} }
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
@@ -760,7 +766,8 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not // Try to reflow the child into the available space. It might not
// fit or might need continuing. // fit or might need continuing.
nsReflowMetrics kidSize(pKidMaxElementSize); nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Initial, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Initial);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize, nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize,
kidReflowState); kidReflowState);
@@ -847,7 +854,7 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
// Check for an overflow list // Check for an overflow list
MoveOverflowToChildList(); MoveOverflowToChildList();
RowGroupReflowState state(aPresContext, aReflowState.maxSize); RowGroupReflowState state(aPresContext, aReflowState);
// Reflow the existing frames // Reflow the existing frames
if (nsnull != mFirstChild) { if (nsnull != mFirstChild) {

View File

@@ -300,7 +300,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
printf(" nsTableCellFrame::ResizeReflow calling ReflowChild with availSize=%d,%d\n", printf(" nsTableCellFrame::ResizeReflow calling ReflowChild with availSize=%d,%d\n",
availSize.width, availSize.height); availSize.width, availSize.height);
nsReflowMetrics kidSize(pMaxElementSize); nsReflowMetrics kidSize(pMaxElementSize);
nsReflowState kidReflowState(aReflowState, availSize); nsReflowState kidReflowState(mFirstChild, aReflowState, availSize);
mFirstChild->WillReflow(*aPresContext); mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState); aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);

View File

@@ -89,7 +89,7 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext* aPresContext,
// give the child frame a chance to reflow, even though we know it'll have 0 size // give the child frame a chance to reflow, even though we know it'll have 0 size
nsReflowMetrics kidSize(nsnull); nsReflowMetrics kidSize(nsnull);
nsReflowState kidReflowState(eReflowReason_Initial, nsSize(0,0)); nsReflowState kidReflowState(kidFrame, aReflowState, nsSize(0,0), eReflowReason_Initial);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize, nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize,
kidReflowState); kidReflowState);

View File

@@ -73,6 +73,9 @@ struct InnerTableReflowState {
// The body's style molecule // The body's style molecule
// Our reflow state
const nsReflowState& reflowState;
// The body's available size (computed from the body's parent) // The body's available size (computed from the body's parent)
nsSize availSize; nsSize availSize;
@@ -98,23 +101,24 @@ struct InnerTableReflowState {
// cache the total height of the footers for placing body rows // cache the total height of the footers for placing body rows
nscoord footerHeight; nscoord footerHeight;
InnerTableReflowState(nsIPresContext* aPresContext, InnerTableReflowState(nsIPresContext* aPresContext,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
const nsMargin& aBorderPadding) const nsMargin& aBorderPadding)
: reflowState(aReflowState)
{ {
prevMaxPosBottomMargin = 0; prevMaxPosBottomMargin = 0;
prevMaxNegBottomMargin = 0; prevMaxNegBottomMargin = 0;
y=0; // border/padding/margin??? y=0; // border/padding/margin???
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE); unconstrainedWidth = PRBool(aReflowState.maxSize.width == NS_UNCONSTRAINEDSIZE);
availSize.width = aMaxSize.width; availSize.width = aReflowState.maxSize.width;
if (!unconstrainedWidth) { if (!unconstrainedWidth) {
availSize.width -= aBorderPadding.left + aBorderPadding.right; availSize.width -= aBorderPadding.left + aBorderPadding.right;
} }
leftInset = aBorderPadding.left; leftInset = aBorderPadding.left;
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE); unconstrainedHeight = PRBool(aReflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
availSize.height = aMaxSize.height; availSize.height = aReflowState.maxSize.height;
if (!unconstrainedHeight) { if (!unconstrainedHeight) {
availSize.height -= aBorderPadding.top + aBorderPadding.bottom; availSize.height -= aBorderPadding.top + aBorderPadding.bottom;
} }
@@ -518,8 +522,8 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
if (PR_FALSE==IsFirstPassValid()) if (PR_FALSE==IsFirstPassValid())
{ // we treat the table as if we've never seen the layout data before { // we treat the table as if we've never seen the layout data before
mPass = kPASS_FIRST; mPass = kPASS_FIRST;
aStatus = ResizeReflowPass1(aPresContext, aDesiredSize, aStatus = ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState,
aReflowState.maxSize, aDesiredSize.maxElementSize); aDesiredSize.maxElementSize);
// check result // check result
} }
mPass = kPASS_SECOND; mPass = kPASS_SECOND;
@@ -530,7 +534,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
// assign table width // assign table width
SetTableWidth(aPresContext); SetTableWidth(aPresContext);
aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aReflowState.maxSize, aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aReflowState,
aDesiredSize.maxElementSize, 0, 0); aDesiredSize.maxElementSize, 0, 0);
if (gsTiming) { if (gsTiming) {
@@ -563,14 +567,17 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
*/ */
nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize) nsSize* aMaxElementSize)
{ {
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
NS_PRECONDITION(aReflowState.parentReflowState->frame == mGeometricParent,
"bad parent reflow state");
NS_ASSERTION(nsnull!=aPresContext, "bad pres context param"); NS_ASSERTION(nsnull!=aPresContext, "bad pres context param");
NS_ASSERTION(nsnull==mPrevInFlow, "illegal call, cannot call pass 1 on a continuing frame."); NS_ASSERTION(nsnull==mPrevInFlow, "illegal call, cannot call pass 1 on a continuing frame.");
if (gsDebug==PR_TRUE) printf("nsTableFrame::ResizeReflow Pass1: maxSize=%d,%d\n", if (gsDebug==PR_TRUE) printf("nsTableFrame::ResizeReflow Pass1: maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height); aReflowState.maxSize.width, aReflowState.maxSize.height);
if (PR_TRUE==gsDebug) printf ("*** tableframe reflow pass1\t\t%d\n", this); if (PR_TRUE==gsDebug) printf ("*** tableframe reflow pass1\t\t%d\n", this);
nsReflowStatus result = NS_FRAME_COMPLETE; nsReflowStatus result = NS_FRAME_COMPLETE;
@@ -684,7 +691,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
} }
nsSize maxKidElementSize; nsSize maxKidElementSize;
nsReflowState kidReflowState(eReflowReason_Resize, availSize); nsReflowState kidReflowState(kidFrame, aReflowState, availSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
@@ -763,15 +771,18 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
*/ */
nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext, nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
PRInt32 aMinCaptionWidth, PRInt32 aMinCaptionWidth,
PRInt32 mMaxCaptionWidth) PRInt32 mMaxCaptionWidth)
{ {
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
NS_PRECONDITION(aReflowState.parentReflowState->frame == mGeometricParent,
"bad parent reflow state");
if (PR_TRUE==gsDebug) printf ("***tableframe reflow pass2\t\t%d\n", this); if (PR_TRUE==gsDebug) printf ("***tableframe reflow pass2\t\t%d\n", this);
if (gsDebug==PR_TRUE) if (gsDebug==PR_TRUE)
printf("nsTableFrame::ResizeReflow Pass2: maxSize=%d,%d\n", printf("nsTableFrame::ResizeReflow Pass2: maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height); aReflowState.maxSize.width, aReflowState.maxSize.height);
nsReflowStatus result = NS_FRAME_COMPLETE; nsReflowStatus result = NS_FRAME_COMPLETE;
@@ -805,7 +816,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
nsMargin myBorderPadding; nsMargin myBorderPadding;
mySpacing->CalcBorderPaddingFor(this, myBorderPadding); mySpacing->CalcBorderPaddingFor(this, myBorderPadding);
InnerTableReflowState state(aPresContext, aMaxSize, myBorderPadding); InnerTableReflowState state(aPresContext, aReflowState, myBorderPadding);
// Reflow the existing frames // Reflow the existing frames
if (nsnull != mFirstChild) { if (nsnull != mFirstChild) {
@@ -852,7 +863,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
// Return our desired rect // Return our desired rect
//NS_ASSERTION(0<state.y, "illegal height after reflow"); //NS_ASSERTION(0<state.y, "illegal height after reflow");
aDesiredSize.width = aMaxSize.width; aDesiredSize.width = aReflowState.maxSize.width;
aDesiredSize.height = state.y; aDesiredSize.height = state.y;
// shrink wrap rows to height of tallest cell in that row // shrink wrap rows to height of tallest cell in that row
@@ -1060,7 +1071,8 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
} }
// Reflow the child into the available space // Reflow the child into the available space
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
@@ -1279,7 +1291,8 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
mLastContentIsComplete = prevLastContentIsComplete; mLastContentIsComplete = prevLastContentIsComplete;
break; break;
} }
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
@@ -1494,7 +1507,8 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not // Try to reflow the child into the available space. It might not
// fit or might need continuing. // fit or might need continuing.
nsReflowMetrics kidSize(pKidMaxElementSize); nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Initial, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Initial);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize, kidReflowState); nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize, kidReflowState);

View File

@@ -183,10 +183,10 @@ protected:
* *
* @see ResizeReflow * @see ResizeReflow
*/ */
virtual nsReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext, virtual nsReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize); nsSize* aMaxElementSize);
/** second pass of ResizeReflow. /** second pass of ResizeReflow.
* lays out all table content with aMaxSize(computed_table_width, given_table_height) * lays out all table content with aMaxSize(computed_table_width, given_table_height)
@@ -201,7 +201,7 @@ protected:
*/ */
virtual nsReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext, virtual nsReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsReflowState& aReflowState,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
PRInt32 aMinCaptionWidth, PRInt32 aMinCaptionWidth,
PRInt32 mMaxCaptionWidth); PRInt32 mMaxCaptionWidth);

View File

@@ -53,6 +53,9 @@ struct OuterTableReflowState {
// The presentation context // The presentation context
nsIPresContext *pc; nsIPresContext *pc;
// Our reflow state
const nsReflowState& reflowState;
// The total available size (computed from the parent) // The total available size (computed from the parent)
nsSize availSize; nsSize availSize;
// The available size for the inner table frame // The available size for the inner table frame
@@ -73,17 +76,18 @@ struct OuterTableReflowState {
PRBool firstRowGroup; PRBool firstRowGroup;
PRBool processingCaption; PRBool processingCaption;
OuterTableReflowState(nsIPresContext* aPresContext, OuterTableReflowState(nsIPresContext* aPresContext,
const nsSize& aMaxSize) const nsReflowState& aReflowState)
: reflowState(aReflowState)
{ {
pc = aPresContext; pc = aPresContext;
availSize.width = aMaxSize.width; availSize.width = reflowState.maxSize.width;
availSize.height = aMaxSize.height; availSize.height = reflowState.maxSize.height;
prevMaxPosBottomMargin = 0; prevMaxPosBottomMargin = 0;
prevMaxNegBottomMargin = 0; prevMaxNegBottomMargin = 0;
y=0; // border/padding/margin??? y=0; // border/padding/margin???
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE); unconstrainedWidth = PRBool(aReflowState.maxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE); unconstrainedHeight = PRBool(aReflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
firstRowGroup = PR_TRUE; firstRowGroup = PR_TRUE;
processingCaption = PR_FALSE; processingCaption = PR_FALSE;
} }
@@ -206,13 +210,13 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
OuterTableReflowState state(aPresContext, aReflowState.maxSize); OuterTableReflowState state(aPresContext, aReflowState);
// lay out captions pass 1, if necessary // lay out captions pass 1, if necessary
if (PR_FALSE==IsFirstPassValid()) if (PR_FALSE==IsFirstPassValid())
{ {
mFirstPassValid = PR_TRUE; mFirstPassValid = PR_TRUE;
aStatus = ResizeReflowCaptionsPass1(aPresContext); aStatus = ResizeReflowCaptionsPass1(aPresContext, state);
} }
@@ -222,7 +226,9 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
// we treat the table as if we've never seen the layout data before // we treat the table as if we've never seen the layout data before
mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_FIRST); mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_FIRST);
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState.maxSize, nsReflowState innerTableReflowState(mInnerTableFrame, aReflowState, aReflowState.maxSize);
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize,
innerTableReflowState,
&innerTableMaxElementSize); &innerTableMaxElementSize);
mInnerTableFrame->RecalcLayoutData(); mInnerTableFrame->RecalcLayoutData();
@@ -897,20 +903,21 @@ nsTableOuterFrame::ReflowChild( nsIFrame* aKidFrame,
if (PR_TRUE==gsDebug) printf("reflowChild called with a bottom caption\n"); if (PR_TRUE==gsDebug) printf("reflowChild called with a bottom caption\n");
status = ResizeReflowBottomCaptionsPass2(aPresContext, aDesiredSize, status = ResizeReflowBottomCaptionsPass2(aPresContext, aDesiredSize,
aMaxSize, aMaxElementSize, aMaxSize, aMaxElementSize,
aState.y); aState.y, aState);
} }
else else
{ {
if (PR_TRUE==gsDebug) printf("reflowChild called with a top caption\n"); if (PR_TRUE==gsDebug) printf("reflowChild called with a top caption\n");
status = ResizeReflowTopCaptionsPass2(aPresContext, aDesiredSize, status = ResizeReflowTopCaptionsPass2(aPresContext, aDesiredSize,
aMaxSize, aMaxElementSize); aMaxSize, aMaxElementSize, aState);
} }
} }
else else
{ {
if (PR_TRUE==gsDebug) printf("reflowChild called with a table body\n"); if (PR_TRUE==gsDebug) printf("reflowChild called with a table body\n");
status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize, aState.innerTableMaxSize, nsReflowState kidReflowState(aKidFrame, aState.reflowState, aState.innerTableMaxSize);
aMaxElementSize, status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize,
kidReflowState, aMaxElementSize,
mMinCaptionWidth, mMaxCaptionWidth); mMinCaptionWidth, mMaxCaptionWidth);
} }
if (PR_TRUE==gsDebug) if (PR_TRUE==gsDebug)
@@ -1015,7 +1022,8 @@ void nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext)
nsReflowStatus nsReflowStatus
nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext) nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext,
OuterTableReflowState& aState)
{ {
if (nsnull!=mCaptionFrames) if (nsnull!=mCaptionFrames)
{ {
@@ -1027,7 +1035,7 @@ nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext)
nsReflowMetrics desiredSize(&maxElementSize); nsReflowMetrics desiredSize(&maxElementSize);
nsTableCaptionFrame *captionFrame = (nsTableCaptionFrame *)mCaptionFrames->ElementAt(captionIndex); nsTableCaptionFrame *captionFrame = (nsTableCaptionFrame *)mCaptionFrames->ElementAt(captionIndex);
nsReflowStatus status; nsReflowStatus status;
nsReflowState reflowState(eReflowReason_Resize, maxSize); nsReflowState reflowState(captionFrame, aState.reflowState, maxSize, eReflowReason_Resize);
captionFrame->WillReflow(*aPresContext); captionFrame->WillReflow(*aPresContext);
captionFrame->Reflow(aPresContext, desiredSize, reflowState, status); captionFrame->Reflow(aPresContext, desiredSize, reflowState, status);
if (mMinCaptionWidth<maxElementSize.width) if (mMinCaptionWidth<maxElementSize.width)
@@ -1042,10 +1050,11 @@ nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext)
} }
nsReflowStatus nsReflowStatus
nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext, nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsSize& aMaxSize,
nsSize* aMaxElementSize) nsSize* aMaxElementSize,
OuterTableReflowState& aState)
{ {
nsReflowStatus result = NS_FRAME_COMPLETE; nsReflowStatus result = NS_FRAME_COMPLETE;
nscoord topCaptionY = 0; nscoord topCaptionY = 0;
@@ -1076,7 +1085,7 @@ nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
if (NS_FRAME_IS_COMPLETE(result)) if (NS_FRAME_IS_COMPLETE(result))
{ {
nsReflowMetrics desiredSize(nsnull); nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aMaxSize); nsReflowState reflowState(captionFrame, aState.reflowState, aMaxSize, eReflowReason_Resize);
captionFrame->WillReflow(*aPresContext); captionFrame->WillReflow(*aPresContext);
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState); result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);
// place the caption // place the caption
@@ -1114,7 +1123,8 @@ nsTableOuterFrame::ResizeReflowBottomCaptionsPass2(nsIPresContext* aPresContext
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsSize& aMaxSize,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nscoord aYOffset) nscoord aYOffset,
OuterTableReflowState& aState)
{ {
nsReflowStatus result = NS_FRAME_COMPLETE; nsReflowStatus result = NS_FRAME_COMPLETE;
nscoord bottomCaptionY = aYOffset; nscoord bottomCaptionY = aYOffset;
@@ -1137,7 +1147,7 @@ nsTableOuterFrame::ResizeReflowBottomCaptionsPass2(nsIPresContext* aPresContext
*/ */
// reflow the caption // reflow the caption
nsReflowMetrics desiredSize(nsnull); nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aMaxSize); nsReflowState reflowState(captionFrame, aState.reflowState, aMaxSize, eReflowReason_Resize);
captionFrame->WillReflow(*aPresContext); captionFrame->WillReflow(*aPresContext);
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState); result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);

View File

@@ -125,7 +125,8 @@ protected:
/** reflow the captions in an infinite space, caching the min/max sizes for each /** reflow the captions in an infinite space, caching the min/max sizes for each
*/ */
virtual nsReflowStatus ResizeReflowCaptionsPass1(nsIPresContext* aPresContext); virtual nsReflowStatus ResizeReflowCaptionsPass1(nsIPresContext* aPresContext,
OuterTableReflowState& aState);
/** reflow the top captions in a space constrained by the computed table width /** reflow the top captions in a space constrained by the computed table width
* and the heigth given to us by our parent. Top captions are laid down * and the heigth given to us by our parent. Top captions are laid down
@@ -134,7 +135,8 @@ protected:
virtual nsReflowStatus ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext, virtual nsReflowStatus ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsSize& aMaxSize,
nsSize* aMaxElementSize); nsSize* aMaxElementSize,
OuterTableReflowState& aState);
/** reflow the bottom captions in a space constrained by the computed table width /** reflow the bottom captions in a space constrained by the computed table width
* and the heigth given to us by our parent. Bottom captions are laid down * and the heigth given to us by our parent. Bottom captions are laid down
@@ -144,7 +146,8 @@ protected:
nsReflowMetrics& aDesiredSize, nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize, const nsSize& aMaxSize,
nsSize* aMaxElementSize, nsSize* aMaxElementSize,
nscoord aYOffset); nscoord aYOffset,
OuterTableReflowState& aState);
nscoord GetTopMarginFor(nsIPresContext* aCX, nscoord GetTopMarginFor(nsIPresContext* aCX,
OuterTableReflowState& aState, OuterTableReflowState& aState,

View File

@@ -41,6 +41,9 @@ static const PRBool gsDebug2 = PR_FALSE;
/* ----------- RowReflowState ---------- */ /* ----------- RowReflowState ---------- */
struct RowReflowState { struct RowReflowState {
// Our reflow state
const nsReflowState& reflowState;
// The body's available size (computed from the body's parent) // The body's available size (computed from the body's parent)
nsSize availSize; nsSize availSize;
@@ -64,16 +67,17 @@ struct RowReflowState {
nsTableFrame *tableFrame; nsTableFrame *tableFrame;
RowReflowState( nsIPresContext* aPresContext, RowReflowState( nsIPresContext* aPresContext,
const nsSize& aMaxSize) const nsReflowState& aReflowState)
: reflowState(aReflowState)
{ {
availSize.width = aMaxSize.width; availSize.width = reflowState.maxSize.width;
availSize.height = aMaxSize.height; availSize.height = reflowState.maxSize.height;
prevMaxPosBottomMargin = 0; prevMaxPosBottomMargin = 0;
prevMaxNegBottomMargin = 0; prevMaxNegBottomMargin = 0;
x=0; x=0;
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE); unconstrainedWidth = PRBool(reflowState.maxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE); unconstrainedHeight = PRBool(reflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
maxCellHeight=0; maxCellHeight=0;
maxCellVertSpace=0; maxCellVertSpace=0;
maxCellHorzSpace=0; maxCellHorzSpace=0;
@@ -343,7 +347,8 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width) if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
{ {
// Reflow the child into the available space // Reflow the child into the available space
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidReflowState); kidReflowState);
@@ -360,7 +365,8 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan); availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
kidAvailSize.width = availWidth; kidAvailSize.width = availWidth;
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
} }
@@ -633,7 +639,8 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan); availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
NS_ASSERTION(0<availWidth, "illegal width for this column"); NS_ASSERTION(0<availWidth, "illegal width for this column");
kidAvailSize.width = availWidth; kidAvailSize.width = availWidth;
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
if (nsnull!=pKidMaxElementSize) if (nsnull!=pKidMaxElementSize)
@@ -897,7 +904,8 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
nsReflowStatus status; nsReflowStatus status;
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width) if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
{ {
nsReflowState kidReflowState(eReflowReason_Initial, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Initial);
// Reflow the child into the available space // Reflow the child into the available space
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
@@ -914,7 +922,7 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan); availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
NS_ASSERTION(0<availWidth, "illegal width for this column"); NS_ASSERTION(0<availWidth, "illegal width for this column");
kidAvailSize.width = availWidth; kidAvailSize.width = availWidth;
nsReflowState kidReflowState(eReflowReason_Initial, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, eReflowReason_Initial);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
} }
@@ -1029,7 +1037,7 @@ nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
// Check for an overflow list // Check for an overflow list
MoveOverflowToChildList(); MoveOverflowToChildList();
RowReflowState state(aPresContext, aReflowState.maxSize); RowReflowState state(aPresContext, aReflowState);
mContentParent->GetContentParent((nsIFrame*&)(state.tableFrame)); mContentParent->GetContentParent((nsIFrame*&)(state.tableFrame));
// Reflow the existing frames // Reflow the existing frames

View File

@@ -43,6 +43,9 @@ NS_DEF_PTR(nsIContent);
/* ----------- RowGroupReflowState ---------- */ /* ----------- RowGroupReflowState ---------- */
struct RowGroupReflowState { struct RowGroupReflowState {
// Our reflow state
const nsReflowState& reflowState;
// The body's available size (computed from the body's parent) // The body's available size (computed from the body's parent)
nsSize availSize; nsSize availSize;
@@ -63,16 +66,17 @@ struct RowGroupReflowState {
// Remember the height of the first row, because it's our maxElementHeight (plus header/footers) // Remember the height of the first row, because it's our maxElementHeight (plus header/footers)
nscoord firstRowHeight; nscoord firstRowHeight;
RowGroupReflowState(nsIPresContext* aPresContext, RowGroupReflowState(nsIPresContext* aPresContext,
const nsSize& aMaxSize) const nsReflowState& aReflowState)
: reflowState(aReflowState)
{ {
availSize.width = aMaxSize.width; availSize.width = reflowState.maxSize.width;
availSize.height = aMaxSize.height; availSize.height = reflowState.maxSize.height;
prevMaxPosBottomMargin = 0; prevMaxPosBottomMargin = 0;
prevMaxNegBottomMargin = 0; prevMaxNegBottomMargin = 0;
y=0; // border/padding/margin??? y=0; // border/padding/margin???
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE); unconstrainedWidth = PRBool(reflowState.maxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE); unconstrainedHeight = PRBool(reflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
firstRow = PR_TRUE; firstRow = PR_TRUE;
firstRowHeight=0; firstRowHeight=0;
} }
@@ -296,7 +300,8 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
} }
// Reflow the child into the available space // Reflow the child into the available space
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
@@ -531,7 +536,8 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
mLastContentIsComplete = prevLastContentIsComplete; mLastContentIsComplete = prevLastContentIsComplete;
break; break;
} }
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
@@ -760,7 +766,8 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not // Try to reflow the child into the available space. It might not
// fit or might need continuing. // fit or might need continuing.
nsReflowMetrics kidSize(pKidMaxElementSize); nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Initial, aState.availSize); nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Initial);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize, nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize,
kidReflowState); kidReflowState);
@@ -847,7 +854,7 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
// Check for an overflow list // Check for an overflow list
MoveOverflowToChildList(); MoveOverflowToChildList();
RowGroupReflowState state(aPresContext, aReflowState.maxSize); RowGroupReflowState state(aPresContext, aReflowState);
// Reflow the existing frames // Reflow the existing frames
if (nsnull != mFirstChild) { if (nsnull != mFirstChild) {