Merged ResizeReflow() and IncrementalReflow() into one Reflow() member function

This commit is contained in:
troy 1998-05-25 17:31:49 +00:00
parent b7b1c1cf1d
commit 3ea1d2d8e3
78 changed files with 2155 additions and 3097 deletions

View File

@ -51,21 +51,21 @@ struct PRLogModuleInfo;
* Reflow metrics used to return the frame's desired size and alignment
* information.
*
* @see #ResizeReflow()
* @see #IncrementalReflow()
* @see #Reflow()
* @see #GetReflowMetrics()
*/
struct nsReflowMetrics {
nscoord width, height; // desired width and height
nscoord width, height; // desired width and height
nscoord ascent, descent;
nsSize* maxElementSize;
nsSize* maxElementSize; // null if you don't need to compute the max element size
nsReflowMetrics(nsSize* aMaxElementSize) {maxElementSize = aMaxElementSize;}
};
/**
* Constant used to indicate an unconstrained size.
*
* @see #ResizeReflow()
* @see #IncrementalReflow()
* @see #Reflow()
*/
#define NS_UNCONSTRAINEDSIZE NS_MAXSIZE
@ -84,6 +84,25 @@ struct nsReflowState {
nsReflowReason reason; // the reason for the reflow
nsReflowCommand* reflowCommand; // only used for incremental changes
nsSize maxSize; // the available space in which to reflow
// Construct a non-incremental reflow state
nsReflowState(nsReflowReason aReason, const nsSize& aMaxSize) {
reason = aReason; reflowCommand = nsnull; maxSize = aMaxSize;
}
// Construct a reflow state for an incremental change
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
// it has a different max size
nsReflowState(const nsReflowState& aReflowState, const nsSize& aMaxSize) {
reason = aReflowState.reason;
reflowCommand = aReflowState.reflowCommand;
maxSize = aMaxSize;
}
};
//----------------------------------------------------------------------
@ -100,8 +119,7 @@ struct nsReflowState {
* for a frame that is not complete, i.e. you wouldn't set both
* NS_FRAME_COMPLETE and NS_FRAME_REFLOW_NEXTINFLOW
*
* @see #ResizeReflow()
* @see #IncrementalReflow()
* @see #Reflow()
* @see #CreateContinuingFrame()
*/
typedef PRUint32 nsReflowStatus;
@ -296,28 +314,7 @@ public:
NS_IMETHOD WillReflow(nsIPresContext& aPresContext) = 0;
/**
* Post-reflow hook. After a frame is incrementally reflowed or
* resize-reflowed this method will be called telling the frame of
* the outcome. This call may be invoked many times, while
* NS_FRAME_IN_REFLOW is set, before it is finally called once with
* a NS_FRAME_REFLOW_COMPLETE value. When called with a
* NS_FRAME_REFLOW_COMPLETE value the NS_FRAME_IN_REFLOW bit in the
* frame state will be cleared.
*/
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus) = 0;
/**
*
*
*/
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus) = 0;
/**
* Resize reflow. The frame is given a maximum size and asked for its desired
* The frame is given a maximum size and asked for its desired size.
* size. This is the frame's opportunity to reflow its children.
*
* @param aDesiredSize <i>out</i> parameter where you should return the
@ -341,15 +338,26 @@ public:
* maximum element size must be less than or equal to your
* desired size.
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus) = 0;
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus) = 0;
/**
* Post-reflow hook. After a frame is incrementally reflowed or
* resize-reflowed this method will be called telling the frame of
* the outcome. This call may be invoked many times, while
* NS_FRAME_IN_REFLOW is set, before it is finally called once with
* a NS_FRAME_REFLOW_COMPLETE value. When called with a
* NS_FRAME_REFLOW_COMPLETE value the NS_FRAME_IN_REFLOW bit in the
* frame state will be cleared.
*/
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus) = 0;
/**
* Post-processing reflow method invoked when justification is enabled.
* This is always called after ResizeReflow/IncrementalReflow.
* This is always called after Reflow()
*
* @param aAvailableSpace The amount of available space that the frame
* should distribute internally.
@ -357,34 +365,6 @@ public:
NS_IMETHOD JustifyReflow(nsIPresContext* aPresContext,
nscoord aAvailableSpace) = 0;
/**
* Incremental reflow. The reflow command contains information about the
* type of change. The frame is given a maximum size and asked for its
* desired size.
*
* @param aDesiredSize <i>out</i> parameter where you should return
* the desired size and ascent/descent info. You should
* include any 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 size if that's the
* smallest you can be, i.e. it's your minimum size.
*
* @see nsReflowCommand#GetTarget()
* @see nsReflowCommand#GetType()
*/
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus) = 0;
/**
* This call is invoked when content is appended to the content tree.
*

View File

@ -35,8 +35,8 @@ class nsIRunaround
{
public:
/**
* Resize reflow. The frame is given a maximum size and asked for its
* desired rect. The space manager should be used to do runaround of anchored
* Reflow. The frame is given a maximum size and asked for its desired
* rect. The space manager should be used to do runaround of anchored
* items.
*
* @param aSpaceManager the space manager to use. The caller has translated
@ -65,48 +65,12 @@ public:
*
* @see nsISpaceManager#Translate()
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus) = 0;
/**
* Incremental reflow. The reflow command contains information about the
* type of change. The frame is given a maximum size and asked for its
* desired rect. The space manager should be used to do runaround of anchored
* items.
*
* @param aSpaceManager the space manager to use. The caller has translated
* the coordinate system so the frame has its own local coordinate
* space with an origin of (0, 0). If you translate the coordinate
* space you must restore it before returning.
* @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 size if
* that's the smallest you can be, i.e. it's your minimum size.
*
* @param aDesiredRect <i>out</i> parameter where you should return the desired
* origin and size. You should include any space you want for border
* and padding in the desired size.
*
* The origin of the desired rect is relative to the upper-left of the
* local coordinate space.
*
* @param aReflowCommand the reflow command contains information about the
* type of change.
*/
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus) = 0;
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect, // XXX FIX ME
nsReflowStatus& aStatus) = 0;
};
#endif /* nsIRunaround_h___ */

View File

@ -438,15 +438,14 @@ PRBool nsContainerFrame::ChildIsPseudoFrame(const nsIFrame* aChild) const
* child is complete and it has next-in-flows (it was a splittable child)
* then delete the next-in-flows.
*/
nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize)
nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState)
{
nsReflowStatus status;
aKidFrame->ResizeReflow(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, status);
aKidFrame->Reflow(aPresContext, aDesiredSize, aReflowState, status);
if (NS_FRAME_IS_COMPLETE(status)) {
nsIFrame* kidNextInFlow;
@ -474,12 +473,12 @@ nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
* used to reflow the child; otherwise interface nsIFrame is used. If the
* child is splittable then runaround is done using continuing frames.
*/
nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize)
nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect)
{
nsIRunaround* reflowRunaround;
nsReflowStatus status;
@ -494,11 +493,11 @@ nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
nsBandTrapezoid trapezoids[12];
nsBandTrapezoid* trapezoid = trapezoids;
nsRect availBand;
nsSize availSize = aMaxSize;
nsSize availSize = aReflowState.maxSize;
bandData.trapezoids = trapezoids;
bandData.size = 12;
aSpaceManager->GetBandData(0, aMaxSize, bandData);
aSpaceManager->GetBandData(0, aReflowState.maxSize, bandData);
if (bandData.count > 1) {
// If there's more than one trapezoid that means there are floaters
@ -546,28 +545,26 @@ nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
(void**)&reflowRunaround)) {
// Yes, the child frame wants to interact directly with the space
// manager.
reflowRunaround->ResizeReflow(aPresContext, aSpaceManager, availSize,
aDesiredRect, aMaxElementSize, status);
nsReflowState reflowState(aReflowState, availSize);
reflowRunaround->Reflow(aPresContext, aSpaceManager, aDesiredSize, reflowState,
aDesiredRect, status);
} else {
// No, use interface nsIFrame instead.
nsReflowMetrics desiredSize;
// Hide the floaters from the child frame
if (aMaxSize.width != NS_UNCONSTRAINEDSIZE) {
if ((availBand.x > 0) || (availBand.XMost() < aMaxSize.width)) {
if (aReflowState.maxSize.width != NS_UNCONSTRAINEDSIZE) {
if ((availBand.x > 0) || (availBand.XMost() < aReflowState.maxSize.width)) {
// There are left/right floaters.
availSize.width = availBand.width;
}
}
aKidFrame->ResizeReflow(aPresContext, desiredSize, availSize,
aMaxElementSize, status);
// XXX FIX ME
aKidFrame->Reflow(aPresContext, aDesiredSize, aReflowState, status);
// Return the desired rect
aDesiredRect.x = availBand.x;
aDesiredRect.y = 0;
aDesiredRect.width = desiredSize.width;
aDesiredRect.height = desiredSize.height;
aDesiredRect.width = aDesiredSize.width;
aDesiredRect.height = aDesiredSize.height;
}
if (NS_FRAME_IS_COMPLETE(status)) {

View File

@ -217,11 +217,10 @@ protected:
* Reflow a child frame and return the status of the reflow. If the child
* is complete and it has next-in-flows, then delete the next-in-flows.
*/
nsReflowStatus ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
nsReflowStatus ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState);
/**
* Reflow a child frame and return the status of the reflow. If the child
@ -238,12 +237,12 @@ protected:
*
* @see nsIRunaround
*/
nsReflowStatus ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize);
nsReflowStatus ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect);
/**
* Moves any frames on both the prev-in-flow's overflow list and the receiver's

View File

@ -1007,25 +1007,21 @@ NS_METHOD nsFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
return NS_OK;
}
NS_METHOD nsFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
{
aDesiredSize.width = 0;
aDesiredSize.height = 0;
aDesiredSize.ascent = 0;
aDesiredSize.descent = 0;
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = 0;
aMaxElementSize->height = 0;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = 0;
aDesiredSize.maxElementSize->height = 0;
}
aStatus = NS_FRAME_COMPLETE;
if (eReflowReason_Incremental == aReflowState.reason) {
return NS_ERROR_NOT_IMPLEMENTED;
}
return NS_OK;
}
@ -1035,32 +1031,6 @@ NS_METHOD nsFrame::JustifyReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_PRECONDITION(aReflowCommand.GetTarget() == this, "bad target");
// The only type of incremental reflow command we expect to get is a
// content changed reflow command
if (aReflowCommand.GetType() == nsReflowCommand::ContentChanged) {
// Generic response is to reflow the child
return ResizeReflow(aPresContext, aDesiredSize, aMaxSize, nsnull, aStatus);
} else {
NS_ERROR("not a container reflow command handler");
aDesiredSize.width = 0;
aDesiredSize.height = 0;
aDesiredSize.ascent = 0;
aDesiredSize.descent = 0;
aStatus = NS_FRAME_COMPLETE;
return NS_ERROR_NOT_IMPLEMENTED;
}
}
NS_METHOD nsFrame::ContentAppended(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aContainer)

View File

@ -139,18 +139,8 @@ public:
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD JustifyReflow(nsIPresContext* aPresContext,
nscoord aAvailableSpace);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD ContentAppended(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aContainer);

View File

@ -374,6 +374,8 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
mPresContext->SetVisibleArea(r);
}
nsReflowReason reflowReason = eReflowReason_Resize;
if (nsnull == mRootFrame) {
if (nsnull != mDocument) {
nsIContent* root = mDocument->GetRootContent();
@ -386,6 +388,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
rootSC, mRootFrame);
NS_RELEASE(rootSC);
NS_RELEASE(cd);
reflowReason = eReflowReason_Initial;
// Bind root frame to root view (and root window)
nsIView* rootView = mViewManager->GetRootView();
@ -409,10 +412,11 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
nsRect bounds;
mPresContext->GetVisibleArea(bounds);
nsSize maxSize(bounds.width, bounds.height);
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(nsnull);
nsReflowStatus status;
mRootFrame->ResizeReflow(mPresContext, desiredSize, maxSize,
nsnull, status);
nsReflowState reflowState(reflowReason, maxSize);
mRootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
mRootFrame->SizeTo(desiredSize.width, desiredSize.height);
#ifdef NS_DEBUG
if (nsIFrame::GetVerifyTreeEnable()) {
@ -480,7 +484,7 @@ void
PresShell::ProcessReflowCommands()
{
if (0 != mReflowCommands.Count()) {
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(nsnull);
while (0 != mReflowCommands.Count()) {
nsReflowCommand* rc = (nsReflowCommand*) mReflowCommands.ElementAt(0);

View File

@ -76,80 +76,19 @@ void nsReflowCommand::Dispatch(nsReflowMetrics& aDesiredSize,
if (nsnull != root) {
mPath.RemoveElementAt(mPath.Count() - 1);
nsReflowState reflowState(this, aMaxSize);
nsReflowStatus status;
root->IncrementalReflow(mPresContext, aDesiredSize, aMaxSize, *this, status);
root->Reflow(mPresContext, aDesiredSize, reflowState, status);
}
}
// Pass the reflow command to the next frame in the hierarchy
nsReflowStatus nsReflowCommand::Next(nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsIFrame*& aNextFrame)
{
PRInt32 count = mPath.Count();
nsReflowStatus result = NS_FRAME_COMPLETE;
NS_ASSERTION(count > 0, "empty path vector");
if (count > 0) {
aNextFrame = (nsIFrame*)mPath[count - 1];
NS_ASSERTION(nsnull != aNextFrame, "null frame");
mPath.RemoveElementAt(count - 1);
aNextFrame->IncrementalReflow(mPresContext, aDesiredSize, aMaxSize,
*this, result);
} else {
aNextFrame = nsnull;
}
return result;
}
// Pass the reflow command to the next frame in the hierarchy. Check
// whether it wants to use nsIRunaround or nsIFrame
nsReflowStatus nsReflowCommand::Next(nsISpaceManager* aSpaceManager,
nsRect& aDesiredRect,
const nsSize& aMaxSize,
nsIFrame*& aNextFrame)
{
PRInt32 count = mPath.Count();
nsReflowStatus result = NS_FRAME_COMPLETE;
NS_ASSERTION(count > 0, "empty path vector");
if (count > 0) {
aNextFrame = (nsIFrame*)mPath[count - 1];
NS_ASSERTION(nsnull != aNextFrame, "null frame");
mPath.RemoveElementAt(count - 1);
// Does the frame support nsIRunaround?
nsIRunaround* reflowRunaround;
if (NS_OK == aNextFrame->QueryInterface(kIRunaroundIID, (void**)&reflowRunaround)) {
reflowRunaround->IncrementalReflow(mPresContext, aSpaceManager, aMaxSize,
aDesiredRect, *this, result);
} else {
nsReflowMetrics desiredSize;
aNextFrame->IncrementalReflow(mPresContext, desiredSize, aMaxSize,
*this, result);
aDesiredRect.x = 0;
aDesiredRect.y = 0;
aDesiredRect.width = desiredSize.width;
aDesiredRect.height = desiredSize.height;
}
} else {
aNextFrame = nsnull;
}
return result;
}
nsIFrame* nsReflowCommand::GetNext() const
nsIFrame* nsReflowCommand::GetNext()
{
PRInt32 count = mPath.Count();
nsIFrame* rv = nsnull;
if (count > 0) {
rv = (nsIFrame*) mPath[count - 1];
mPath.RemoveElementAt(count - 1);
}
return rv;
}

View File

@ -70,37 +70,32 @@ public:
virtual ~nsReflowCommand();
/**
* Dispatch the reflow command. The command is processed and dispatched
* to the appropriate frame's appropriate method.
* Dispatch the reflow command.
*
* Builds a path from the target frame back to the root frame, and then invokes
* the root frame's Reflow() member function.
*/
void Dispatch(nsReflowMetrics& aDesiredSize, const nsSize& aMaxSize);
// Pass the reflow command to the next frame in the hierarchy. Returns the
// status and the next frame to which the command was dispatched
nsReflowStatus Next(nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsIFrame*& aNextFrame);
/**
* Get the next frame in the command chain. Note that this removes the frame
* from the target chain
*/
nsIFrame* GetNext();
// Pass the reflow command to the next frame in the hierarchy. Returns the
// status and the next frame to which the command was dispatched
//
// Use this version if you have a space manager. This function will check if
// the caller supports nsIRunaround and call either the nsIFrame or the
// nsIRunaround IncrementalReflow() function
nsReflowStatus Next(nsISpaceManager* aSpaceManager,
nsRect& aDesiredRect,
const nsSize& aMaxSize,
nsIFrame*& aNextFrame);
nsIFrame* GetNext() const;
// Get the target of the reflow command
/**
* Get the target of the reflow command
*/
nsIFrame* GetTarget() const {return mTargetFrame;}
// Get the type of reflow command
/**
* Get the type of reflow command
*/
ReflowType GetType() const {return mType;}
// Get the child frame associated with the reflow command
/**
* Get the child frame associated with the reflow command
*/
nsIFrame* GetChildFrame() const {return mChildFrame;}
private:

View File

@ -431,29 +431,27 @@ nsBlockFrame::WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow)
}
nsresult
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aMaxSize,
aMaxElementSize);
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aReflowState);
return NS_OK;
}
nsresult
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aSpaceManager,
aMaxSize, aDesiredRect, aMaxElementSize);
aDesiredSize, aReflowState, aDesiredRect);
return NS_OK;
}
@ -1209,22 +1207,116 @@ nsBlockFrame::GetReflowMetrics(nsIPresContext* aPresContext,
//----------------------------------------------------------------------
NS_METHOD
nsBlockFrame::ResizeReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::Reflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
aMaxElementSize, state);
if (NS_OK == rv) {
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize,
aDesiredSize.maxElementSize, state);
if (eReflowReason_Incremental == aReflowState.reason) {
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowState.reflowCommand->GetTarget()) {
if (nsReflowCommand::FrameAppended == aReflowState.reflowCommand->GetType()) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowState.reflowCommand->GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowState.reflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aReflowState.maxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
} else {
nsRect desiredRect;
rv = DoResizeReflow(state, aMaxSize, aDesiredRect, aStatus);
rv = DoResizeReflow(state, aReflowState.maxSize, aDesiredRect, aStatus);
}
return rv;
}
@ -1273,127 +1365,6 @@ nsresult nsBlockFrame::IncrementalReflowAfter(nsBlockReflowState& aState,
return ReflowMappedFrom(aState, aLine->mNextLine);
}
NS_METHOD
nsBlockFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsBlockFrame::IncrementalReflow");
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
nsnull, state);
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowCommand.GetTarget()) {
if (aReflowCommand.GetType() == nsReflowCommand::FrameAppended) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
#if 0
} else if (aReflowCommand.GetType() == nsReflowCommand::ContentChanged) {
// Restore our state as if the child that changed is the next frame to reflow
nsLineData* line = FindLine(aReflowCommand.GetChildFrame());
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line, and all the lines that follow...
// XXX Obviously this needs to be more efficient
rv = ReflowMappedFrom(state, line);
#endif
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowCommand.GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aMaxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
NS_FRAME_TRACE_REFLOW_OUT("nsBlockFrame::IncrementalReflow", aStatus);
return rv;
}
void nsBlockFrame::ComputeDesiredRect(nsBlockReflowState& aState,
const nsSize& aMaxSize,
nsRect& aDesiredRect)

View File

@ -189,18 +189,12 @@ public:
NS_IMETHOD VerifyTree() const;
// nsIRunaround
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus);
// nsIFloaterContainer
virtual PRBool AddFloater(nsIPresContext* aPresContext,
@ -211,20 +205,19 @@ public:
PlaceholderFrame* aPlaceholder);
// nsBlockFrame
nsresult ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
nsresult ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
nsresult ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
nsresult ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus);
nsLineData* GetFirstLine();

View File

@ -431,29 +431,27 @@ nsBlockFrame::WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow)
}
nsresult
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aMaxSize,
aMaxElementSize);
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aReflowState);
return NS_OK;
}
nsresult
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aSpaceManager,
aMaxSize, aDesiredRect, aMaxElementSize);
aDesiredSize, aReflowState, aDesiredRect);
return NS_OK;
}
@ -1209,22 +1207,116 @@ nsBlockFrame::GetReflowMetrics(nsIPresContext* aPresContext,
//----------------------------------------------------------------------
NS_METHOD
nsBlockFrame::ResizeReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::Reflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
aMaxElementSize, state);
if (NS_OK == rv) {
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize,
aDesiredSize.maxElementSize, state);
if (eReflowReason_Incremental == aReflowState.reason) {
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowState.reflowCommand->GetTarget()) {
if (nsReflowCommand::FrameAppended == aReflowState.reflowCommand->GetType()) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowState.reflowCommand->GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowState.reflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aReflowState.maxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
} else {
nsRect desiredRect;
rv = DoResizeReflow(state, aMaxSize, aDesiredRect, aStatus);
rv = DoResizeReflow(state, aReflowState.maxSize, aDesiredRect, aStatus);
}
return rv;
}
@ -1273,127 +1365,6 @@ nsresult nsBlockFrame::IncrementalReflowAfter(nsBlockReflowState& aState,
return ReflowMappedFrom(aState, aLine->mNextLine);
}
NS_METHOD
nsBlockFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsBlockFrame::IncrementalReflow");
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
nsnull, state);
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowCommand.GetTarget()) {
if (aReflowCommand.GetType() == nsReflowCommand::FrameAppended) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
#if 0
} else if (aReflowCommand.GetType() == nsReflowCommand::ContentChanged) {
// Restore our state as if the child that changed is the next frame to reflow
nsLineData* line = FindLine(aReflowCommand.GetChildFrame());
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line, and all the lines that follow...
// XXX Obviously this needs to be more efficient
rv = ReflowMappedFrom(state, line);
#endif
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowCommand.GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aMaxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
NS_FRAME_TRACE_REFLOW_OUT("nsBlockFrame::IncrementalReflow", aStatus);
return rv;
}
void nsBlockFrame::ComputeDesiredRect(nsBlockReflowState& aState,
const nsSize& aMaxSize,
nsRect& aDesiredRect)

View File

@ -431,29 +431,27 @@ nsBlockFrame::WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow)
}
nsresult
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aMaxSize,
aMaxElementSize);
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aReflowState);
return NS_OK;
}
nsresult
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aSpaceManager,
aMaxSize, aDesiredRect, aMaxElementSize);
aDesiredSize, aReflowState, aDesiredRect);
return NS_OK;
}
@ -1209,22 +1207,116 @@ nsBlockFrame::GetReflowMetrics(nsIPresContext* aPresContext,
//----------------------------------------------------------------------
NS_METHOD
nsBlockFrame::ResizeReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::Reflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
aMaxElementSize, state);
if (NS_OK == rv) {
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize,
aDesiredSize.maxElementSize, state);
if (eReflowReason_Incremental == aReflowState.reason) {
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowState.reflowCommand->GetTarget()) {
if (nsReflowCommand::FrameAppended == aReflowState.reflowCommand->GetType()) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowState.reflowCommand->GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowState.reflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aReflowState.maxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
} else {
nsRect desiredRect;
rv = DoResizeReflow(state, aMaxSize, aDesiredRect, aStatus);
rv = DoResizeReflow(state, aReflowState.maxSize, aDesiredRect, aStatus);
}
return rv;
}
@ -1273,127 +1365,6 @@ nsresult nsBlockFrame::IncrementalReflowAfter(nsBlockReflowState& aState,
return ReflowMappedFrom(aState, aLine->mNextLine);
}
NS_METHOD
nsBlockFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsBlockFrame::IncrementalReflow");
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
nsnull, state);
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowCommand.GetTarget()) {
if (aReflowCommand.GetType() == nsReflowCommand::FrameAppended) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
#if 0
} else if (aReflowCommand.GetType() == nsReflowCommand::ContentChanged) {
// Restore our state as if the child that changed is the next frame to reflow
nsLineData* line = FindLine(aReflowCommand.GetChildFrame());
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line, and all the lines that follow...
// XXX Obviously this needs to be more efficient
rv = ReflowMappedFrom(state, line);
#endif
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowCommand.GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aMaxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
NS_FRAME_TRACE_REFLOW_OUT("nsBlockFrame::IncrementalReflow", aStatus);
return rv;
}
void nsBlockFrame::ComputeDesiredRect(nsBlockReflowState& aState,
const nsSize& aMaxSize,
nsRect& aDesiredRect)

View File

@ -51,21 +51,21 @@ struct PRLogModuleInfo;
* Reflow metrics used to return the frame's desired size and alignment
* information.
*
* @see #ResizeReflow()
* @see #IncrementalReflow()
* @see #Reflow()
* @see #GetReflowMetrics()
*/
struct nsReflowMetrics {
nscoord width, height; // desired width and height
nscoord width, height; // desired width and height
nscoord ascent, descent;
nsSize* maxElementSize;
nsSize* maxElementSize; // null if you don't need to compute the max element size
nsReflowMetrics(nsSize* aMaxElementSize) {maxElementSize = aMaxElementSize;}
};
/**
* Constant used to indicate an unconstrained size.
*
* @see #ResizeReflow()
* @see #IncrementalReflow()
* @see #Reflow()
*/
#define NS_UNCONSTRAINEDSIZE NS_MAXSIZE
@ -84,6 +84,25 @@ struct nsReflowState {
nsReflowReason reason; // the reason for the reflow
nsReflowCommand* reflowCommand; // only used for incremental changes
nsSize maxSize; // the available space in which to reflow
// Construct a non-incremental reflow state
nsReflowState(nsReflowReason aReason, const nsSize& aMaxSize) {
reason = aReason; reflowCommand = nsnull; maxSize = aMaxSize;
}
// Construct a reflow state for an incremental change
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
// it has a different max size
nsReflowState(const nsReflowState& aReflowState, const nsSize& aMaxSize) {
reason = aReflowState.reason;
reflowCommand = aReflowState.reflowCommand;
maxSize = aMaxSize;
}
};
//----------------------------------------------------------------------
@ -100,8 +119,7 @@ struct nsReflowState {
* for a frame that is not complete, i.e. you wouldn't set both
* NS_FRAME_COMPLETE and NS_FRAME_REFLOW_NEXTINFLOW
*
* @see #ResizeReflow()
* @see #IncrementalReflow()
* @see #Reflow()
* @see #CreateContinuingFrame()
*/
typedef PRUint32 nsReflowStatus;
@ -296,28 +314,7 @@ public:
NS_IMETHOD WillReflow(nsIPresContext& aPresContext) = 0;
/**
* Post-reflow hook. After a frame is incrementally reflowed or
* resize-reflowed this method will be called telling the frame of
* the outcome. This call may be invoked many times, while
* NS_FRAME_IN_REFLOW is set, before it is finally called once with
* a NS_FRAME_REFLOW_COMPLETE value. When called with a
* NS_FRAME_REFLOW_COMPLETE value the NS_FRAME_IN_REFLOW bit in the
* frame state will be cleared.
*/
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus) = 0;
/**
*
*
*/
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus) = 0;
/**
* Resize reflow. The frame is given a maximum size and asked for its desired
* The frame is given a maximum size and asked for its desired size.
* size. This is the frame's opportunity to reflow its children.
*
* @param aDesiredSize <i>out</i> parameter where you should return the
@ -341,15 +338,26 @@ public:
* maximum element size must be less than or equal to your
* desired size.
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus) = 0;
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus) = 0;
/**
* Post-reflow hook. After a frame is incrementally reflowed or
* resize-reflowed this method will be called telling the frame of
* the outcome. This call may be invoked many times, while
* NS_FRAME_IN_REFLOW is set, before it is finally called once with
* a NS_FRAME_REFLOW_COMPLETE value. When called with a
* NS_FRAME_REFLOW_COMPLETE value the NS_FRAME_IN_REFLOW bit in the
* frame state will be cleared.
*/
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus) = 0;
/**
* Post-processing reflow method invoked when justification is enabled.
* This is always called after ResizeReflow/IncrementalReflow.
* This is always called after Reflow()
*
* @param aAvailableSpace The amount of available space that the frame
* should distribute internally.
@ -357,34 +365,6 @@ public:
NS_IMETHOD JustifyReflow(nsIPresContext* aPresContext,
nscoord aAvailableSpace) = 0;
/**
* Incremental reflow. The reflow command contains information about the
* type of change. The frame is given a maximum size and asked for its
* desired size.
*
* @param aDesiredSize <i>out</i> parameter where you should return
* the desired size and ascent/descent info. You should
* include any 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 size if that's the
* smallest you can be, i.e. it's your minimum size.
*
* @see nsReflowCommand#GetTarget()
* @see nsReflowCommand#GetType()
*/
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus) = 0;
/**
* This call is invoked when content is appended to the content tree.
*

View File

@ -222,13 +222,13 @@ PRBool nsInlineFrame::ReflowMappedChildrenFrom(nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
for (nsIFrame* kidFrame = aChildFrame; nsnull != kidFrame; ) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize);
nsReflowStatus status;
// Reflow the child into the available space
kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, aState.availSize,
pKidMaxElementSize);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.width > aState.availSize.width) && (kidFrame != mFirstChild)) {
@ -359,7 +359,7 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
while (nsnull != nextInFlow) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowStatus status;
// Get the next child
@ -399,9 +399,9 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
mLastContentIsComplete = prevLastContentIsComplete;
break;
}
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize);
kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, aState.availSize,
pKidMaxElementSize);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.width > aState.availSize.width) && (nsnull != mFirstChild)) {
@ -637,10 +637,11 @@ nsReflowStatus nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContex
// Try to reflow the child into the available space. It might not
// fit or might need continuing.
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize);
kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame, aPresContext, kidSize,
aState.availSize, pKidMaxElementSize);
kidReflowState);
// Did the child fit?
if ((kidSize.width > aState.availSize.width) && (nsnull != mFirstChild)) {
@ -710,13 +711,12 @@ nsInlineFrame::InitializeState(nsIPresContext* aPresContext,
}
}
NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsInlineFrame::ResizeReflow");
NS_FRAME_TRACE_REFLOW_IN("nsInlineFrame::Reflow");
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
PreReflowCheck();
@ -736,48 +736,147 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
mStyleContext->GetData(eStyleStruct_Spacing);
// Check for an overflow list
MoveOverflowToChildList();
if (eReflowReason_Incremental != aReflowState.reason) {
MoveOverflowToChildList();
}
// Initialize our reflow state. We must wait until after we've processed
// the overflow list, because our first content offset might change
nsMargin borderPadding;
styleSpacing->CalcBorderPaddingFor(this, borderPadding);
nsInlineState state(styleFont, borderPadding, aMaxSize, aMaxElementSize);
nsInlineState state(styleFont, borderPadding, aReflowState.maxSize, aDesiredSize.maxElementSize);
InitializeState(aPresContext, state);
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
// Reflow any existing frames
if (nsnull != mFirstChild) {
reflowMappedOK = ReflowMappedChildrenFrom(aPresContext, state, mFirstChild, 0);
if (PR_FALSE == reflowMappedOK) {
// We didn't successfully reflow our mapped frames; therefore, we're not complete
aStatus = NS_FRAME_NOT_COMPLETE;
}
}
// Did we successfully relow our mapped children?
if (PR_TRUE == reflowMappedOK) {
// Any space left?
if (state.availSize.width <= 0) {
// No space left. Don't try to pull-up children or reflow unmapped
if (NextChildOffset() < mContent->ChildCount()) {
// No room left to map the remaining content; therefore, we're not complete
aStatus = NS_FRAME_NOT_COMPLETE;
if (eReflowReason_Incremental == aReflowState.reason) {
NS_ASSERTION(nsnull != aReflowState.reflowCommand, "null reflow command");
if (aReflowState.reflowCommand->GetTarget() == this) {
switch (aReflowState.reflowCommand->GetType()) {
case nsReflowCommand::FrameAppended:
// Recover our state
RecoverState(aPresContext, state, nsnull);
aStatus = ReflowUnmappedChildren(aPresContext, state);
break;
default:
NS_NOTYETIMPLEMENTED("unexpected reflow command");
break;
}
} else if (NextChildOffset() < mContent->ChildCount()) {
// Try and pull-up some children from a next-in-flow
if (PullUpChildren(aPresContext, state)) {
// If we still have unmapped children then create some new frames
if (NextChildOffset() < mContent->ChildCount()) {
aStatus = ReflowUnmappedChildren(aPresContext, state);
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* kidFrame = aReflowState.reflowCommand->GetNext();
nsReflowMetrics kidSize(aDesiredSize.maxElementSize);
nsReflowState kidReflowState(aReflowState.reflowCommand, state.availSize);
// Restore our state as if nextFrame is the next frame to reflow
PRInt32 kidIndex = RecoverState(aPresContext, state, kidFrame);
// Reflow the child into the available space
aStatus = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.width > state.availSize.width) && (kidFrame != mFirstChild)) {
nsIFrame* prevFrame;
// The child is too wide to fit in the available space, and it's not our
// first child
PrevChild(kidFrame, prevFrame);
PushChildren(kidFrame, prevFrame, mLastContentIsComplete);
SetLastContentOffset(prevFrame);
mChildCount = kidIndex - 1;
aStatus = NS_FRAME_NOT_COMPLETE;
} else {
// We were unable to pull-up all the existing frames from the next in flow;
// therefore, we're not complete
// Place and size the child
PlaceChild(kidFrame, kidIndex, state, kidSize, nsnull);
nsIFrame* kidNextInFlow;
kidFrame->GetNextInFlow(kidNextInFlow);
// Is the child complete?
if (NS_FRAME_IS_COMPLETE(aStatus)) {
// Check whether the frame has next-in-flow(s) that are no longer needed
if (nsnull != kidNextInFlow) {
// Remove the next-in-flow(s)
DeleteChildsNextInFlow(kidFrame);
}
// Adjust the frames that follow
aStatus = IncrementalReflowAfter(aPresContext, state, kidFrame, kidIndex);
} else {
nsIFrame* nextSibling;
// No, the child isn't complete
if (nsnull == kidNextInFlow) {
// The child doesn't have a next-in-flow so create a continuing
// frame.
nsIFrame* continuingFrame;
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame);
// Link the child into the sibling list
kidFrame->GetNextSibling(nextSibling);
continuingFrame->SetNextSibling(nextSibling);
kidFrame->SetNextSibling(continuingFrame);
}
// We've used up all of our available space, so push the remaining
// children to the next-in-flow
kidFrame->GetNextSibling(nextSibling);
if (nsnull != nextSibling) {
PushChildren(nextSibling, kidFrame, mLastContentIsComplete);
}
SetLastContentOffset(kidFrame);
mChildCount = kidIndex;
}
}
}
} else {
// Reflow any existing frames
if (nsnull != mFirstChild) {
reflowMappedOK = ReflowMappedChildrenFrom(aPresContext, state, mFirstChild, 0);
if (PR_FALSE == reflowMappedOK) {
// We didn't successfully reflow our mapped frames; therefore, we're not complete
aStatus = NS_FRAME_NOT_COMPLETE;
}
}
// Did we successfully relow our mapped children?
if (PR_TRUE == reflowMappedOK) {
// Any space left?
if (state.availSize.width <= 0) {
// No space left. Don't try to pull-up children or reflow unmapped
if (NextChildOffset() < mContent->ChildCount()) {
// No room left to map the remaining content; therefore, we're not complete
aStatus = NS_FRAME_NOT_COMPLETE;
}
} else if (NextChildOffset() < mContent->ChildCount()) {
// Try and pull-up some children from a next-in-flow
if (PullUpChildren(aPresContext, state)) {
// If we still have unmapped children then create some new frames
if (NextChildOffset() < mContent->ChildCount()) {
aStatus = ReflowUnmappedChildren(aPresContext, state);
}
} else {
// We were unable to pull-up all the existing frames from the next in flow;
// therefore, we're not complete
aStatus = NS_FRAME_NOT_COMPLETE;
}
}
}
#if 0
// XXX I don't think our return size properly accounts for the lineHeight
// (which may not == state.maxAscent + state.maxDescent)
// Return our size and our status
#endif
}
// Vertically align the children
@ -789,12 +888,6 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
ComputeFinalSize(aPresContext, state, aDesiredSize);
#if 0
// XXX I don't think our return size properly accounts for the lineHeight
// (which may not == state.maxAscent + state.maxDescent)
// Return our size and our status
#endif
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
PostReflowCheck(aStatus);
@ -852,7 +945,8 @@ NS_METHOD nsInlineFrame::GetReflowMetrics(nsIPresContext* aPresContext,
nscoord maxDescent = 0;
nsIFrame* kid = mFirstChild;
while (nsnull != kid) {
nsReflowMetrics kidMetrics;
// XXX Properly handle max element size...
nsReflowMetrics kidMetrics(aMetrics.maxElementSize);
kid->GetReflowMetrics(aPresContext, kidMetrics);
if (kidMetrics.ascent > maxAscent) maxAscent = kidMetrics.ascent;
if (kidMetrics.descent > maxDescent) maxDescent = kidMetrics.descent;
@ -887,7 +981,7 @@ PRInt32 nsInlineFrame::RecoverState(nsIPresContext* aPresContext,
nscoord maxAscent = 0;
nscoord maxDescent = 0;
while ((nsnull != kid) && (kid != aSkipChild)) {
nsReflowMetrics kidMetrics;
nsReflowMetrics kidMetrics(nsnull);
kid->GetReflowMetrics(aPresContext, kidMetrics);
aState.ascents[i] = kidMetrics.ascent;
if (kidMetrics.ascent > maxAscent) maxAscent = kidMetrics.ascent;
@ -977,152 +1071,6 @@ nsInlineFrame::IncrementalReflowAfter(nsIPresContext* aPresContext,
return status;
}
NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsInlineFrame::IncrementalReflow");
aStatus = NS_FRAME_COMPLETE; // initialize out parameter
// Get the style molecule
nsStyleFont* styleFont =
(nsStyleFont*)mStyleContext->GetData(eStyleStruct_Font);
nsStyleSpacing* styleSpacing =
(nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing);
nscoord lineHeight;
PRInt32 kidIndex;
nsMargin borderPadding;
styleSpacing->CalcBorderPaddingFor(this, borderPadding);
nsInlineState state(styleFont, borderPadding, aMaxSize, nsnull);
InitializeState(aPresContext, state);
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
if (aReflowCommand.GetTarget() == this) {
switch (aReflowCommand.GetType()) {
case nsReflowCommand::FrameAppended:
// Recover our state
RecoverState(aPresContext, state, nsnull);
aStatus = ReflowUnmappedChildren(aPresContext, state);
// Vertically align the children
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
styleFont, borderPadding.top, mFirstChild,
mChildCount, state.ascents, state.maxAscent);
ComputeFinalSize(aPresContext, state, aDesiredSize);
break;
#if 0
case nsReflowCommand::ContentChanged:
// Recover our state
kidFrame = aReflowCommand.GetChildFrame();
kidIndex = RecoverState(aPresContext, state, kidFrame);
aStatus = IncrementalReflowFrom(aPresContext, state, kidFrame, kidIndex);
// Vertically align the children
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
styleFont, borderPadding.top, mFirstChild,
mChildCount, state.ascents, state.maxAscent);
ComputeFinalSize(aPresContext, state, aDesiredSize);
break;
#endif
default:
NS_NOTYETIMPLEMENTED("unexpected reflow command");
break;
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* kidFrame = aReflowCommand.GetNext();
nsReflowMetrics kidSize;
// Restore our state as if nextFrame is the next frame to reflow
kidIndex = RecoverState(aPresContext, state, kidFrame);
// Reflow the child into the available space
aStatus = aReflowCommand.Next(kidSize, state.availSize, kidFrame);
// Did the child fit?
if ((kidSize.width > state.availSize.width) && (kidFrame != mFirstChild)) {
nsIFrame* prevFrame;
// The child is too wide to fit in the available space, and it's not our
// first child
PrevChild(kidFrame, prevFrame);
PushChildren(kidFrame, prevFrame, mLastContentIsComplete);
SetLastContentOffset(prevFrame);
mChildCount = kidIndex - 1;
aStatus = NS_FRAME_NOT_COMPLETE;
} else {
// Place and size the child
PlaceChild(kidFrame, kidIndex, state, kidSize, nsnull);
nsIFrame* kidNextInFlow;
kidFrame->GetNextInFlow(kidNextInFlow);
// Is the child complete?
if (NS_FRAME_IS_COMPLETE(aStatus)) {
// Check whether the frame has next-in-flow(s) that are no longer needed
if (nsnull != kidNextInFlow) {
// Remove the next-in-flow(s)
DeleteChildsNextInFlow(kidFrame);
}
// Adjust the frames that follow
aStatus = IncrementalReflowAfter(aPresContext, state, kidFrame, kidIndex);
} else {
nsIFrame* nextSibling;
// No, the child isn't complete
if (nsnull == kidNextInFlow) {
// The child doesn't have a next-in-flow so create a continuing
// frame.
nsIFrame* continuingFrame;
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame);
// Link the child into the sibling list
kidFrame->GetNextSibling(nextSibling);
continuingFrame->SetNextSibling(nextSibling);
kidFrame->SetNextSibling(continuingFrame);
}
// We've used up all of our available space, so push the remaining
// children to the next-in-flow
kidFrame->GetNextSibling(nextSibling);
if (nsnull != nextSibling) {
PushChildren(nextSibling, kidFrame, mLastContentIsComplete);
}
SetLastContentOffset(kidFrame);
mChildCount = kidIndex;
}
}
// Vertically align the children
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
styleFont, borderPadding.top, mFirstChild,
mChildCount, state.ascents, state.maxAscent);
ComputeFinalSize(aPresContext, state, aDesiredSize);
}
NS_FRAME_TRACE_REFLOW_OUT("nsInlineFrame::IncrementalReflow", aStatus);
return NS_OK;
}
// In order to execute the vertical alignment code after incremental
// reflow of the inline frame, we need to reposition any child frames
// that were relatively positioned back to their computed x origin.

View File

@ -43,44 +43,24 @@ NS_METHOD nsLeafFrame::Paint(nsIPresContext& aPresContext,
return NS_OK;
}
NS_METHOD nsLeafFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsLeafFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// XXX add in code to check for width/height being set via css
// and if set use them instead of calling GetDesiredSize.
GetDesiredSize(aPresContext, aDesiredSize, aMaxSize);
GetDesiredSize(aPresContext, aDesiredSize, aReflowState.maxSize);
AddBordersAndPadding(aPresContext, aDesiredSize);
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = aDesiredSize.width;
aMaxElementSize->height = aDesiredSize.height;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height;
}
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
NS_METHOD nsLeafFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
// XXX Unless the reflow command is a style change, we should
// just return the current size, otherwise we should invoke
// GetDesiredSize
// XXX add in code to check for width/height being set via css
// and if set use them instead of calling GetDesiredSize.
GetDesiredSize(aPresContext, aDesiredSize, aMaxSize);
AddBordersAndPadding(aPresContext, aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
// XXX how should border&padding effect baseline alignment?
// => descent = borderPadding.bottom for example
void nsLeafFrame::AddBordersAndPadding(nsIPresContext* aPresContext,

View File

@ -32,17 +32,10 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -326,14 +326,14 @@ nsLineLayout::WordBreakReflow()
mReflowType = NS_LINE_LAYOUT_REFLOW_TYPE_WORD_WRAP;
mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE;
nsSize maxElementSize;
nsReflowMetrics kidSize;
nsReflowStatus kidReflowStatus;
nsSize* kidMaxElementSize = nsnull;
if (nsnull != mMaxElementSizePointer) {
kidMaxElementSize = &maxElementSize;
}
rv = mBlock->ReflowInlineChild(frame, mPresContext, kidSize,
kidAvailSize, kidMaxElementSize,
nsReflowMetrics kidSize(kidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
rv = mBlock->ReflowInlineChild(frame, mPresContext, kidSize, kidReflowState,
kidReflowStatus);
return rv;
@ -502,7 +502,7 @@ nsLineLayout::ReflowMappedChild()
// IncrementalReflow AND GetReflowMetrics by those frames that are
// line layout aware.
mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE;
nsReflowMetrics kidMetrics;
nsReflowMetrics kidMetrics(nsnull);
mKidFrame->GetReflowMetrics(mPresContext, kidMetrics);
nsSize maxElementSize;
@ -612,31 +612,22 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
mFramesReflowed++;
nsRect kidRect;
nsSize maxElementSize;
nsReflowMetrics kidMetrics;
nsSize* kidMaxElementSize = nsnull;
nsReflowStatus kidReflowStatus;
if (nsnull != mMaxElementSizePointer) {
kidMaxElementSize = &maxElementSize;
}
nsReflowMetrics kidMetrics(kidMaxElementSize);
nsReflowState kidReflowState(aReflowCommand ? eReflowReason_Incremental :
eReflowReason_Resize, kidAvailSize);
kidReflowState.reflowCommand = aReflowCommand;
mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE;
nscoord dx = mReflowData.mX + kidMargin.left;
NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW,
("nsLineLayout::ReflowChild: reflowing frame=%p[%d] into %d,%d",
mKidFrame, mKidIndex,
kidAvailSize.width, kidAvailSize.height));
if (aReflowCommand) {
nsIFrame* nextFrame;
mSpaceManager->Translate(dx, mY);
kidReflowStatus = aReflowCommand->Next(mSpaceManager, kidRect, kidAvailSize, nextFrame);
mSpaceManager->Translate(-dx, -mY);
kidRect.x = dx;
kidRect.y = mY;
kidMetrics.width = kidRect.width;
kidMetrics.height = kidRect.height;
kidMetrics.ascent = kidRect.height;
kidMetrics.descent = 0;
} else if (isBlock) {
if (isBlock) {
// Calculate top margin by collapsing with previous bottom margin
nscoord negTopMargin;
nscoord posTopMargin;
@ -672,8 +663,8 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
mSpaceManager->Translate(dx, mY);
mKidFrame->WillReflow(*mPresContext);
rv = mBlock->ReflowBlockChild(mKidFrame, mPresContext,
mSpaceManager, kidAvailSize, kidRect,
kidMaxElementSize, kidReflowStatus);
mSpaceManager, kidMetrics, kidReflowState,
kidRect, kidReflowStatus);
mSpaceManager->Translate(-dx, -mY);
kidRect.x = dx;
kidRect.y = mY;
@ -685,9 +676,8 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
else {
// Reflow the inline child
mKidFrame->WillReflow(*mPresContext);
rv = mBlock->ReflowInlineChild(mKidFrame, mPresContext,
kidMetrics, kidAvailSize, kidMaxElementSize,
kidReflowStatus);
rv = mBlock->ReflowInlineChild(mKidFrame, mPresContext, kidMetrics,
kidReflowState, kidReflowStatus);
// After we reflow the inline child we will know whether or not it
// has any height/width. If it doesn't have any height/width then
// we do not yet apply any previous block bottom margin.
@ -815,7 +805,7 @@ nsLineLayout::PlaceChild(const nsRect& kidRect,
}
nsresult
nsLineLayout::IncrementalReflowFromChild(nsReflowCommand& aReflowCommand,
nsLineLayout::IncrementalReflowFromChild(nsReflowCommand* aReflowCommand,
nsIFrame* aChildFrame)
{
nsresult reflowStatus = NS_LINE_LAYOUT_COMPLETE;
@ -827,7 +817,7 @@ nsLineLayout::IncrementalReflowFromChild(nsReflowCommand& aReflowCommand,
while (kidNum < mLine->mChildCount) {
nsresult childReflowStatus;
if (mKidFrame == aChildFrame) {
childReflowStatus = ReflowChild(&aReflowCommand);
childReflowStatus = ReflowChild(aReflowCommand);
} else {
childReflowStatus = ReflowMappedChild();
}

View File

@ -78,7 +78,7 @@ struct nsLineLayout {
nsresult ReflowLine();
nsresult IncrementalReflowFromChild(nsReflowCommand& aReflowCommand,
nsresult IncrementalReflowFromChild(nsReflowCommand* aReflowCommand,
nsIFrame* aChildFrame);
// The presentation context

View File

@ -54,72 +54,99 @@ void PageFrame::CreateFirstChild(nsIPresContext* aPresContext)
}
}
NS_METHOD PageFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD PageFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
#ifdef NS_DEBUG
PreReflowCheck();
#endif
aStatus = NS_FRAME_COMPLETE; // initialize out parameter
// Do we have any children?
if (nsnull == mFirstChild) {
if (nsnull == mPrevInFlow) {
// Create the first child frame
CreateFirstChild(aPresContext);
} else {
PageFrame* prevPage = (PageFrame*)mPrevInFlow;
// XXX Do something sensible in page mode...
if (eReflowReason_Incremental == aReflowState.reason) {
// We don't expect the target of the reflow command to be page frame
NS_ASSERTION(nsnull != aReflowState.reflowCommand, "null reflow command");
NS_ASSERTION(aReflowState.reflowCommand->GetTarget() != this,
"page frame is reflow command target");
// Verify the next reflow command frame is our one and only child frame
nsIFrame* next = aReflowState.reflowCommand->GetNext();
NS_ASSERTION(next == mFirstChild, "bad reflow frame");
NS_ASSERTION(!prevPage->mLastContentIsComplete, "bad continuing page");
nsIFrame* prevLastChild;
prevPage->LastChild(prevLastChild);
// Create a continuing child of the previous page's last child
nsIStyleContext* kidSC;
prevLastChild->GetStyleContext(aPresContext, kidSC);
nsresult rv = prevLastChild->CreateContinuingFrame(aPresContext, this,
kidSC, mFirstChild);
NS_RELEASE(kidSC);
mChildCount = 1;
mLastContentOffset = mFirstContentOffset;
}
}
// Resize our frame allowing it only to be as big as we are
// XXX Pay attention to the page's border and padding...
if (nsnull != mFirstChild) {
// Get the child's desired size
mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, aMaxSize,
aMaxElementSize);
mLastContentIsComplete = NS_FRAME_IS_COMPLETE(aStatus);
// Make sure the child is at least as tall as our max size (the containing window)
if (aDesiredSize.height < aMaxSize.height) {
aDesiredSize.height = aMaxSize.height;
// Dispatch the reflow command to our content child. Allow it to be as high
// as it wants
nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE);
nsReflowState reflowState(aReflowState.reflowCommand, maxSize);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState);
// Place and size the child. Make sure the child is at least as
// tall as our max size (the containing window)
if (aDesiredSize.height < aReflowState.maxSize.height) {
aDesiredSize.height = aReflowState.maxSize.height;
}
// Place and size the child
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
mFirstChild->SetRect(rect);
mFirstChild->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
// Is the frame complete?
if (NS_FRAME_IS_COMPLETE(aStatus)) {
nsIFrame* childNextInFlow;
mFirstChild->GetNextInFlow(childNextInFlow);
NS_ASSERTION(nsnull == childNextInFlow, "bad child flow list");
} else {
// Do we have any children?
if (nsnull == mFirstChild) {
if (nsnull == mPrevInFlow) {
// Create the first child frame
CreateFirstChild(aPresContext);
} else {
PageFrame* prevPage = (PageFrame*)mPrevInFlow;
NS_ASSERTION(!prevPage->mLastContentIsComplete, "bad continuing page");
nsIFrame* prevLastChild;
prevPage->LastChild(prevLastChild);
// Create a continuing child of the previous page's last child
nsIStyleContext* kidSC;
prevLastChild->GetStyleContext(aPresContext, kidSC);
nsresult rv = prevLastChild->CreateContinuingFrame(aPresContext, this,
kidSC, mFirstChild);
NS_RELEASE(kidSC);
mChildCount = 1;
mLastContentOffset = mFirstContentOffset;
}
}
// Resize our frame allowing it only to be as big as we are
// XXX Pay attention to the page's border and padding...
if (nsnull != mFirstChild) {
// Get the child's desired size
mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, aReflowState);
mLastContentIsComplete = NS_FRAME_IS_COMPLETE(aStatus);
// Make sure the child is at least as tall as our max size (the containing window)
if (aDesiredSize.height < aReflowState.maxSize.height) {
aDesiredSize.height = aReflowState.maxSize.height;
}
// Place and size the child
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
mFirstChild->SetRect(rect);
mFirstChild->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
// Is the frame complete?
if (NS_FRAME_IS_COMPLETE(aStatus)) {
nsIFrame* childNextInFlow;
mFirstChild->GetNextInFlow(childNextInFlow);
NS_ASSERTION(nsnull == childNextInFlow, "bad child flow list");
}
}
}
// Return our desired size
aDesiredSize.width = aMaxSize.width;
aDesiredSize.height = aMaxSize.height;
// Return our desired size
aDesiredSize.width = aReflowState.maxSize.width;
aDesiredSize.height = aReflowState.maxSize.height;
}
#ifdef NS_DEBUG
PostReflowCheck(aStatus);
@ -127,38 +154,6 @@ NS_METHOD PageFrame::ResizeReflow(nsIPresContext* aPresContext,
return NS_OK;
}
// XXX Do something sensible in page mode...
NS_METHOD PageFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
// We don't expect the target of the reflow command to be page frame
NS_ASSERTION(aReflowCommand.GetTarget() != this, "page frame is reflow command target");
nsSize maxSize(aMaxSize.width, NS_UNCONSTRAINEDSIZE);
nsIFrame* child;
// Dispatch the reflow command to our pseudo frame. Allow it to be as high
// as it wants
aStatus = aReflowCommand.Next(aDesiredSize, maxSize, child);
// Place and size the child. Make sure the child is at least as
// tall as our max size (the containing window)
if (nsnull != child) {
NS_ASSERTION(child == mFirstChild, "unexpected reflow command frame");
if (aDesiredSize.height < aMaxSize.height) {
aDesiredSize.height = aMaxSize.height;
}
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
child->SetRect(rect);
}
return NS_OK;
}
NS_METHOD
PageFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -25,17 +25,10 @@ class PageFrame : public nsContainerFrame {
public:
PageFrame(nsIContent* aContent, nsIFrame* aParent);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aMaxSize,
nsReflowStatus& aStatus);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aCX,
nsIFrame* aParent,

View File

@ -49,11 +49,10 @@ PlaceholderFrame::~PlaceholderFrame()
{
}
NS_METHOD PlaceholderFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD PlaceholderFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// Get the floater container in which we're inserted
nsIFloaterContainer* container = nsnull;
@ -79,24 +78,26 @@ NS_METHOD PlaceholderFrame::ResizeReflow(nsIPresContext* aPresContext,
// Resize reflow the anchored item into the available space
// XXX Check for complete?
mAnchoredItem->ResizeReflow(aPresContext, aDesiredSize, aMaxSize,
nsnull, aStatus);
mAnchoredItem->SizeTo(aDesiredSize.width, aDesiredSize.height);
nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Initial, aReflowState.maxSize);
mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus);
mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height);
// Now notify our containing block that there's a new floater
container->AddFloater(aPresContext, mAnchoredItem, this);
} else {
// XXX This causes anchored-items sizes to get fixed up; this is
// not quite right because this class should be implementing one
// of the incremental reflow methods and propogating things down
// of the incremental reflow methods and propagating things down
// properly to the contained frame.
mAnchoredItem->ResizeReflow(aPresContext, aDesiredSize, aMaxSize,
nsnull, aStatus);
mAnchoredItem->SizeTo(aDesiredSize.width, aDesiredSize.height);
nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aReflowState.maxSize);
mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus);
mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height);
container->PlaceFloater(aPresContext, mAnchoredItem, this);
}
return nsFrame::ResizeReflow(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, aStatus);
return nsFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
}
NS_METHOD

View File

@ -42,11 +42,10 @@ public:
NS_IMETHOD NextChild(const nsIFrame* aChild, nsIFrame*& aNextChild) const;
NS_IMETHOD PrevChild(const nsIFrame* aChild, nsIFrame*& aPrevChild) const;
NS_IMETHOD LastChild(nsIFrame*& aLastChild) const;
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
NS_IMETHOD ListTag(FILE* out = stdout) const;

View File

@ -30,17 +30,10 @@ public:
nsIContent* aContent,
nsIFrame* aParent);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD GetReflowMetrics(nsIPresContext* aPresContext,
nsReflowMetrics& aMetrics);

View File

@ -235,11 +235,10 @@ nsIFrame* AbsoluteFrame::GetContainingBlock()
return result;
}
NS_METHOD AbsoluteFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD AbsoluteFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// Have we created the absolutely positioned item yet?
if (nsnull == mFrame) {
@ -301,24 +300,26 @@ NS_METHOD AbsoluteFrame::ResizeReflow(nsIPresContext* aPresContext,
availSize.height = NS_UNCONSTRAINEDSIZE;
}
mFrame->ResizeReflow(aPresContext, aDesiredSize, availSize, nsnull, aStatus);
nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Initial, availSize);
mFrame->Reflow(aPresContext, desiredSize, reflowState, aStatus);
// Figure out what size to actually use. If the position style is 'auto' or
// the container should be enlarged to contain overflowing frames then use
// the desired size
if ((eStyleUnit_Auto == position->mWidth.GetUnit()) ||
((aDesiredSize.width > availSize.width) &&
((desiredSize.width > availSize.width) &&
(NS_STYLE_OVERFLOW_VISIBLE == position->mOverflow))) {
rect.width = aDesiredSize.width;
rect.width = desiredSize.width;
}
if (eStyleUnit_Auto == position->mHeight.GetUnit()) {
rect.height = aDesiredSize.height;
rect.height = desiredSize.height;
}
mFrame->SizeTo(rect.width, rect.height);
}
// Return our desired size as (0, 0)
return nsFrame::ResizeReflow(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, aStatus);
return nsFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
}
NS_METHOD

View File

@ -41,11 +41,10 @@ public:
NS_IMETHOD NextChild(const nsIFrame* aChild, nsIFrame*& aNextChild) const;
NS_IMETHOD PrevChild(const nsIFrame* aChild, nsIFrame*& aPrevChild) const;
NS_IMETHOD LastChild(nsIFrame*& aLastChild) const;
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
protected:

View File

@ -35,11 +35,10 @@ public:
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD GetReflowMetrics(nsIPresContext* aPresContext,
nsReflowMetrics& aMetrics);
@ -105,11 +104,10 @@ NS_METHOD BRFrame::GetReflowMetrics(nsIPresContext* aPresContext, nsReflowMetric
return NS_OK;
}
NS_METHOD BRFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD BRFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aMaxSize,
nsReflowStatus& aStatus)
{
// Get cached state for containing block frame
nsLineLayout* lineLayoutState = nsnull;

View File

@ -431,29 +431,27 @@ nsBlockFrame::WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow)
}
nsresult
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aMaxSize,
aMaxElementSize);
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aReflowState);
return NS_OK;
}
nsresult
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aSpaceManager,
aMaxSize, aDesiredRect, aMaxElementSize);
aDesiredSize, aReflowState, aDesiredRect);
return NS_OK;
}
@ -1209,22 +1207,116 @@ nsBlockFrame::GetReflowMetrics(nsIPresContext* aPresContext,
//----------------------------------------------------------------------
NS_METHOD
nsBlockFrame::ResizeReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::Reflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
aMaxElementSize, state);
if (NS_OK == rv) {
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize,
aDesiredSize.maxElementSize, state);
if (eReflowReason_Incremental == aReflowState.reason) {
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowState.reflowCommand->GetTarget()) {
if (nsReflowCommand::FrameAppended == aReflowState.reflowCommand->GetType()) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowState.reflowCommand->GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowState.reflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aReflowState.maxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
} else {
nsRect desiredRect;
rv = DoResizeReflow(state, aMaxSize, aDesiredRect, aStatus);
rv = DoResizeReflow(state, aReflowState.maxSize, aDesiredRect, aStatus);
}
return rv;
}
@ -1273,127 +1365,6 @@ nsresult nsBlockFrame::IncrementalReflowAfter(nsBlockReflowState& aState,
return ReflowMappedFrom(aState, aLine->mNextLine);
}
NS_METHOD
nsBlockFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsBlockFrame::IncrementalReflow");
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
nsnull, state);
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowCommand.GetTarget()) {
if (aReflowCommand.GetType() == nsReflowCommand::FrameAppended) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
#if 0
} else if (aReflowCommand.GetType() == nsReflowCommand::ContentChanged) {
// Restore our state as if the child that changed is the next frame to reflow
nsLineData* line = FindLine(aReflowCommand.GetChildFrame());
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line, and all the lines that follow...
// XXX Obviously this needs to be more efficient
rv = ReflowMappedFrom(state, line);
#endif
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowCommand.GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aMaxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
NS_FRAME_TRACE_REFLOW_OUT("nsBlockFrame::IncrementalReflow", aStatus);
return rv;
}
void nsBlockFrame::ComputeDesiredRect(nsBlockReflowState& aState,
const nsSize& aMaxSize,
nsRect& aDesiredRect)

View File

@ -189,18 +189,12 @@ public:
NS_IMETHOD VerifyTree() const;
// nsIRunaround
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus);
// nsIFloaterContainer
virtual PRBool AddFloater(nsIPresContext* aPresContext,
@ -211,20 +205,19 @@ public:
PlaceholderFrame* aPlaceholder);
// nsBlockFrame
nsresult ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
nsresult ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
nsresult ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
nsresult ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus);
nsLineData* GetFirstLine();

View File

@ -431,29 +431,27 @@ nsBlockFrame::WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow)
}
nsresult
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aMaxSize,
aMaxElementSize);
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aReflowState);
return NS_OK;
}
nsresult
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aSpaceManager,
aMaxSize, aDesiredRect, aMaxElementSize);
aDesiredSize, aReflowState, aDesiredRect);
return NS_OK;
}
@ -1209,22 +1207,116 @@ nsBlockFrame::GetReflowMetrics(nsIPresContext* aPresContext,
//----------------------------------------------------------------------
NS_METHOD
nsBlockFrame::ResizeReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::Reflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
aMaxElementSize, state);
if (NS_OK == rv) {
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize,
aDesiredSize.maxElementSize, state);
if (eReflowReason_Incremental == aReflowState.reason) {
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowState.reflowCommand->GetTarget()) {
if (nsReflowCommand::FrameAppended == aReflowState.reflowCommand->GetType()) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowState.reflowCommand->GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowState.reflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aReflowState.maxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
} else {
nsRect desiredRect;
rv = DoResizeReflow(state, aMaxSize, aDesiredRect, aStatus);
rv = DoResizeReflow(state, aReflowState.maxSize, aDesiredRect, aStatus);
}
return rv;
}
@ -1273,127 +1365,6 @@ nsresult nsBlockFrame::IncrementalReflowAfter(nsBlockReflowState& aState,
return ReflowMappedFrom(aState, aLine->mNextLine);
}
NS_METHOD
nsBlockFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsBlockFrame::IncrementalReflow");
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
nsnull, state);
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowCommand.GetTarget()) {
if (aReflowCommand.GetType() == nsReflowCommand::FrameAppended) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
#if 0
} else if (aReflowCommand.GetType() == nsReflowCommand::ContentChanged) {
// Restore our state as if the child that changed is the next frame to reflow
nsLineData* line = FindLine(aReflowCommand.GetChildFrame());
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line, and all the lines that follow...
// XXX Obviously this needs to be more efficient
rv = ReflowMappedFrom(state, line);
#endif
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowCommand.GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aMaxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
NS_FRAME_TRACE_REFLOW_OUT("nsBlockFrame::IncrementalReflow", aStatus);
return rv;
}
void nsBlockFrame::ComputeDesiredRect(nsBlockReflowState& aState,
const nsSize& aMaxSize,
nsRect& aDesiredRect)

View File

@ -431,29 +431,27 @@ nsBlockFrame::WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow)
}
nsresult
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowInlineChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aMaxSize,
aMaxElementSize);
aStatus = ReflowChild(aKidFrame, aPresContext, aDesiredSize, aReflowState);
return NS_OK;
}
nsresult
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::ReflowBlockChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
aStatus = ReflowChild(aKidFrame, aPresContext, aSpaceManager,
aMaxSize, aDesiredRect, aMaxElementSize);
aDesiredSize, aReflowState, aDesiredRect);
return NS_OK;
}
@ -1209,22 +1207,116 @@ nsBlockFrame::GetReflowMetrics(nsIPresContext* aPresContext,
//----------------------------------------------------------------------
NS_METHOD
nsBlockFrame::ResizeReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsBlockFrame::Reflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
aMaxElementSize, state);
if (NS_OK == rv) {
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
rv = InitializeState(aPresContext, aSpaceManager, aReflowState.maxSize,
aDesiredSize.maxElementSize, state);
if (eReflowReason_Incremental == aReflowState.reason) {
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowState.reflowCommand->GetTarget()) {
if (nsReflowCommand::FrameAppended == aReflowState.reflowCommand->GetType()) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowState.reflowCommand->GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowState.reflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aReflowState.maxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
} else {
nsRect desiredRect;
rv = DoResizeReflow(state, aMaxSize, aDesiredRect, aStatus);
rv = DoResizeReflow(state, aReflowState.maxSize, aDesiredRect, aStatus);
}
return rv;
}
@ -1273,127 +1365,6 @@ nsresult nsBlockFrame::IncrementalReflowAfter(nsBlockReflowState& aState,
return ReflowMappedFrom(aState, aLine->mNextLine);
}
NS_METHOD
nsBlockFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsBlockFrame::IncrementalReflow");
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PreReflowCheck();
}
#endif
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsBlockReflowState state;
rv = InitializeState(aPresContext, aSpaceManager, aMaxSize,
nsnull, state);
nsIPresShell* shell = state.mPresContext->GetShell();
shell->PutCachedData(this, &state);
// Is the reflow command target at us?
if (this == aReflowCommand.GetTarget()) {
if (aReflowCommand.GetType() == nsReflowCommand::FrameAppended) {
nsLineData* lastLine = LastLine();
// Restore the state
if (nsnull != lastLine) {
state.RecoverState(lastLine);
}
// Reflow unmapped children
PRInt32 kidIndex = NextChildOffset();
PRInt32 contentChildCount = mContent->ChildCount();
if (kidIndex == contentChildCount) {
// There is nothing to do here
if (nsnull != lastLine) {
state.mY = lastLine->mBounds.YMost();
}
}
else {
rv = ReflowUnmapped(state);
}
#if 0
} else if (aReflowCommand.GetType() == nsReflowCommand::ContentChanged) {
// Restore our state as if the child that changed is the next frame to reflow
nsLineData* line = FindLine(aReflowCommand.GetChildFrame());
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line, and all the lines that follow...
// XXX Obviously this needs to be more efficient
rv = ReflowMappedFrom(state, line);
#endif
} else {
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* nextFrame = aReflowCommand.GetNext();
// Restore our state as if nextFrame is the next frame to reflow
nsLineData* line = FindLine(nextFrame);
state.RecoverState(line);
// Get some available space to start reflowing with
GetAvailableSpace(state, state.mY);
// Reflow the affected line
nsLineLayout lineLayout(state);
state.mCurrentLine = &lineLayout;
lineLayout.Initialize(state, line);
// Have the line handle the incremental reflow
nsRect oldBounds = line->mBounds;
rv = lineLayout.IncrementalReflowFromChild(aReflowCommand, nextFrame);
// Now place the line. It's possible it won't fit
rv = PlaceLine(state, lineLayout, line);
// XXX The way NS_LINE_LAYOUT_COMPLETE is being used is very confusing...
if (NS_LINE_LAYOUT_COMPLETE == rv) {
mLastContentOffset = line->mLastContentOffset;
mLastContentIsComplete = PRBool(line->mLastContentIsComplete);
state.mPrevKidFrame = lineLayout.mPrevKidFrame;
// Now figure out what to do with the frames that follow
rv = IncrementalReflowAfter(state, line, rv, oldBounds);
}
}
// Return our desired rect
ComputeDesiredRect(state, aMaxSize, aDesiredRect);
// Set return status
aStatus = NS_FRAME_COMPLETE;
if (NS_LINE_LAYOUT_NOT_COMPLETE == rv) {
rv = NS_OK;
aStatus = NS_FRAME_NOT_COMPLETE;
}
// Now that reflow has finished, remove the cached pointer
shell->RemoveCachedData(this);
NS_RELEASE(shell);
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
VerifyLines(PR_TRUE);
PostReflowCheck(aStatus);
}
#endif
NS_FRAME_TRACE_REFLOW_OUT("nsBlockFrame::IncrementalReflow", aStatus);
return rv;
}
void nsBlockFrame::ComputeDesiredRect(nsBlockReflowState& aState,
const nsSize& aMaxSize,
nsRect& aDesiredRect)

View File

@ -130,47 +130,75 @@ nsSize nsBodyFrame::GetColumnAvailSpace(nsIPresContext* aPresContext,
return result;
}
NS_METHOD nsBodyFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsBodyFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsBodyFrame::ResizeReflow");
NS_FRAME_TRACE_REFLOW_IN("nsBodyFrame::Reflow");
aStatus = NS_FRAME_COMPLETE; // initialize out parameter
// Do we have any children?
// XXX Verify the reason is eReflowReason_Initial...
if (nsnull == mFirstChild) {
// No, create a column frame
// No, create a pseudo block frame
CreateColumnFrame(aPresContext);
}
// Reflow the column
if (nsnull != mFirstChild) {
// Clear any regions that are marked as unavailable
mSpaceManager->ClearRegions();
if (eReflowReason_Incremental == aReflowState.reason) {
// The reflow command should never be target for us
NS_ASSERTION(nsnull != aReflowState.reflowCommand, "null reflow command");
NS_ASSERTION(aReflowState.reflowCommand->GetTarget() != this,
"bad reflow command target");
// Is the next frame in the reflow chain the pseudo block-frame or a
// floating frame?
//
// XXX Do we want the floating frame to be a reflow target or should its
// placeholder frame be the target? The reason this is currently happening
// is that the placeholder frame was changed to return the floating frame
// as a child frame. That's wrong, because the floating frame now appears
// to be both a geometric child of the body and of the placeholder. Yuck...
nsIFrame* next = aReflowState.reflowCommand->GetNext();
if (mFirstChild != next) {
// 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
// resize the floating frame...
nsReflowState reflowState(eReflowReason_Resize, aReflowState.maxSize);
return Reflow(aPresContext, aDesiredSize, reflowState, aStatus);
}
}
// Reflow the child frame
if (nsnull != mFirstChild) {
// Get our border/padding info
nsStyleSpacing* mySpacing =
(nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing);
nsMargin borderPadding;
mySpacing->CalcBorderPaddingFor(this, borderPadding);
// Compute the column's max size
nsSize columnMaxSize = GetColumnAvailSpace(aPresContext, borderPadding,
aMaxSize);
// Compute the child frame's max size
nsSize kidMaxSize = GetColumnAvailSpace(aPresContext, borderPadding,
aReflowState.maxSize);
mSpaceManager->Translate(borderPadding.left, borderPadding.top);
if (eReflowReason_Resize == aReflowState.reason) {
// Clear any regions that are marked as unavailable
// XXX Temporary hack until everything is incremental...
mSpaceManager->ClearRegions();
}
// Get the column's desired rect
nsRect desiredRect;
nsIRunaround* reflowRunaround;
nsReflowState reflowState(aReflowState, kidMaxSize);
nsRect desiredRect;
mFirstChild->WillReflow(*aPresContext);
mSpaceManager->Translate(borderPadding.left, borderPadding.top);
mFirstChild->QueryInterface(kIRunaroundIID, (void**)&reflowRunaround);
reflowRunaround->ResizeReflow(aPresContext, mSpaceManager, columnMaxSize,
desiredRect, aMaxElementSize, aStatus);
mSpaceManager->Translate(-borderPadding.left, -borderPadding.top);
reflowRunaround->Reflow(aPresContext, mSpaceManager, aDesiredSize,
reflowState, desiredRect, aStatus);
// If the frame is complete, then check whether there's a next-in-flow that
// needs to be deleted
@ -184,23 +212,25 @@ NS_METHOD nsBodyFrame::ResizeReflow(nsIPresContext* aPresContext,
}
}
// Place and size the column
mSpaceManager->Translate(-borderPadding.left, -borderPadding.top);
// Place and size the frame
desiredRect.x += borderPadding.left;
desiredRect.y += borderPadding.top;
mFirstChild->SetRect(desiredRect);
mFirstChild->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
// Set our last content offset and whether the last content is complete
// based on the state of the pseudo frame
nsBlockFrame* blockPseudoFrame = (nsBlockFrame*)mFirstChild;
mLastContentOffset = blockPseudoFrame->GetLastContentOffset();
mLastContentIsComplete = blockPseudoFrame->GetLastContentIsComplete();
// Return our desired size
ComputeDesiredSize(desiredRect, aMaxSize, borderPadding, aDesiredSize);
ComputeDesiredSize(desiredRect, aReflowState.maxSize, borderPadding, aDesiredSize);
}
NS_FRAME_TRACE_REFLOW_OUT("nsBodyFrame::ResizeReflow", aStatus);
NS_FRAME_TRACE_REFLOW_OUT("nsBodyFrame::Reflow", aStatus);
return NS_OK;
}
@ -245,59 +275,6 @@ NS_METHOD nsBodyFrame::VerifyTree() const
return NS_OK;
}
NS_METHOD nsBodyFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsBodyFrame::IncrementalReflow");
// Get our border/padding info
nsStyleSpacing* mySpacing =
(nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing);
nsMargin borderPadding;
mySpacing->CalcBorderPaddingFor(this, borderPadding);
mSpaceManager->Translate(borderPadding.left, borderPadding.top);
// The reflow command should never be target for us
NS_ASSERTION(aReflowCommand.GetTarget() != this, "bad reflow command target");
// Compute the child frame's max size
nsSize columnMaxSize = GetColumnAvailSpace(aPresContext, borderPadding,
aMaxSize);
// Pass the command along to our column pseudo frame
nsRect desiredRect;
nsIFrame* nextFrame;
NS_ASSERTION(nsnull != mFirstChild, "no first child");
mFirstChild->WillReflow(*aPresContext);
aStatus = aReflowCommand.Next(mSpaceManager, desiredRect, columnMaxSize,
nextFrame);
// Place and size the frame
desiredRect.x += borderPadding.left;
desiredRect.y += borderPadding.top;
mFirstChild->SetRect(desiredRect);
mFirstChild->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
// Set our last content offset and whether the last content is complete
// based on the state of the pseudo frame
nsBlockFrame* blockPseudoFrame = (nsBlockFrame*)mFirstChild;
mLastContentOffset = blockPseudoFrame->GetLastContentOffset();
mLastContentIsComplete = blockPseudoFrame->GetLastContentIsComplete();
// Return our desired size
ComputeDesiredSize(desiredRect, aMaxSize, borderPadding, aDesiredSize);
mSpaceManager->Translate(-borderPadding.left, -borderPadding.top);
NS_FRAME_TRACE_REFLOW_OUT("nsBodyFrame::IncrementalReflow", aStatus);
return NS_OK;
}
void
nsBodyFrame::ComputeDesiredSize(const nsRect& aDesiredRect,
const nsSize& aMaxSize,

View File

@ -32,17 +32,10 @@ public:
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD ContentAppended(nsIPresShell* aShell,
nsIPresContext* aPresContext,

View File

@ -222,13 +222,13 @@ PRBool nsInlineFrame::ReflowMappedChildrenFrom(nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
for (nsIFrame* kidFrame = aChildFrame; nsnull != kidFrame; ) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize);
nsReflowStatus status;
// Reflow the child into the available space
kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, aState.availSize,
pKidMaxElementSize);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.width > aState.availSize.width) && (kidFrame != mFirstChild)) {
@ -359,7 +359,7 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
while (nsnull != nextInFlow) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowStatus status;
// Get the next child
@ -399,9 +399,9 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
mLastContentIsComplete = prevLastContentIsComplete;
break;
}
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize);
kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, aState.availSize,
pKidMaxElementSize);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.width > aState.availSize.width) && (nsnull != mFirstChild)) {
@ -637,10 +637,11 @@ nsReflowStatus nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContex
// Try to reflow the child into the available space. It might not
// fit or might need continuing.
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize);
kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame, aPresContext, kidSize,
aState.availSize, pKidMaxElementSize);
kidReflowState);
// Did the child fit?
if ((kidSize.width > aState.availSize.width) && (nsnull != mFirstChild)) {
@ -710,13 +711,12 @@ nsInlineFrame::InitializeState(nsIPresContext* aPresContext,
}
}
NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsInlineFrame::ResizeReflow");
NS_FRAME_TRACE_REFLOW_IN("nsInlineFrame::Reflow");
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
PreReflowCheck();
@ -736,48 +736,147 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
mStyleContext->GetData(eStyleStruct_Spacing);
// Check for an overflow list
MoveOverflowToChildList();
if (eReflowReason_Incremental != aReflowState.reason) {
MoveOverflowToChildList();
}
// Initialize our reflow state. We must wait until after we've processed
// the overflow list, because our first content offset might change
nsMargin borderPadding;
styleSpacing->CalcBorderPaddingFor(this, borderPadding);
nsInlineState state(styleFont, borderPadding, aMaxSize, aMaxElementSize);
nsInlineState state(styleFont, borderPadding, aReflowState.maxSize, aDesiredSize.maxElementSize);
InitializeState(aPresContext, state);
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
// Reflow any existing frames
if (nsnull != mFirstChild) {
reflowMappedOK = ReflowMappedChildrenFrom(aPresContext, state, mFirstChild, 0);
if (PR_FALSE == reflowMappedOK) {
// We didn't successfully reflow our mapped frames; therefore, we're not complete
aStatus = NS_FRAME_NOT_COMPLETE;
}
}
// Did we successfully relow our mapped children?
if (PR_TRUE == reflowMappedOK) {
// Any space left?
if (state.availSize.width <= 0) {
// No space left. Don't try to pull-up children or reflow unmapped
if (NextChildOffset() < mContent->ChildCount()) {
// No room left to map the remaining content; therefore, we're not complete
aStatus = NS_FRAME_NOT_COMPLETE;
if (eReflowReason_Incremental == aReflowState.reason) {
NS_ASSERTION(nsnull != aReflowState.reflowCommand, "null reflow command");
if (aReflowState.reflowCommand->GetTarget() == this) {
switch (aReflowState.reflowCommand->GetType()) {
case nsReflowCommand::FrameAppended:
// Recover our state
RecoverState(aPresContext, state, nsnull);
aStatus = ReflowUnmappedChildren(aPresContext, state);
break;
default:
NS_NOTYETIMPLEMENTED("unexpected reflow command");
break;
}
} else if (NextChildOffset() < mContent->ChildCount()) {
// Try and pull-up some children from a next-in-flow
if (PullUpChildren(aPresContext, state)) {
// If we still have unmapped children then create some new frames
if (NextChildOffset() < mContent->ChildCount()) {
aStatus = ReflowUnmappedChildren(aPresContext, state);
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* kidFrame = aReflowState.reflowCommand->GetNext();
nsReflowMetrics kidSize(aDesiredSize.maxElementSize);
nsReflowState kidReflowState(aReflowState.reflowCommand, state.availSize);
// Restore our state as if nextFrame is the next frame to reflow
PRInt32 kidIndex = RecoverState(aPresContext, state, kidFrame);
// Reflow the child into the available space
aStatus = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.width > state.availSize.width) && (kidFrame != mFirstChild)) {
nsIFrame* prevFrame;
// The child is too wide to fit in the available space, and it's not our
// first child
PrevChild(kidFrame, prevFrame);
PushChildren(kidFrame, prevFrame, mLastContentIsComplete);
SetLastContentOffset(prevFrame);
mChildCount = kidIndex - 1;
aStatus = NS_FRAME_NOT_COMPLETE;
} else {
// We were unable to pull-up all the existing frames from the next in flow;
// therefore, we're not complete
// Place and size the child
PlaceChild(kidFrame, kidIndex, state, kidSize, nsnull);
nsIFrame* kidNextInFlow;
kidFrame->GetNextInFlow(kidNextInFlow);
// Is the child complete?
if (NS_FRAME_IS_COMPLETE(aStatus)) {
// Check whether the frame has next-in-flow(s) that are no longer needed
if (nsnull != kidNextInFlow) {
// Remove the next-in-flow(s)
DeleteChildsNextInFlow(kidFrame);
}
// Adjust the frames that follow
aStatus = IncrementalReflowAfter(aPresContext, state, kidFrame, kidIndex);
} else {
nsIFrame* nextSibling;
// No, the child isn't complete
if (nsnull == kidNextInFlow) {
// The child doesn't have a next-in-flow so create a continuing
// frame.
nsIFrame* continuingFrame;
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame);
// Link the child into the sibling list
kidFrame->GetNextSibling(nextSibling);
continuingFrame->SetNextSibling(nextSibling);
kidFrame->SetNextSibling(continuingFrame);
}
// We've used up all of our available space, so push the remaining
// children to the next-in-flow
kidFrame->GetNextSibling(nextSibling);
if (nsnull != nextSibling) {
PushChildren(nextSibling, kidFrame, mLastContentIsComplete);
}
SetLastContentOffset(kidFrame);
mChildCount = kidIndex;
}
}
}
} else {
// Reflow any existing frames
if (nsnull != mFirstChild) {
reflowMappedOK = ReflowMappedChildrenFrom(aPresContext, state, mFirstChild, 0);
if (PR_FALSE == reflowMappedOK) {
// We didn't successfully reflow our mapped frames; therefore, we're not complete
aStatus = NS_FRAME_NOT_COMPLETE;
}
}
// Did we successfully relow our mapped children?
if (PR_TRUE == reflowMappedOK) {
// Any space left?
if (state.availSize.width <= 0) {
// No space left. Don't try to pull-up children or reflow unmapped
if (NextChildOffset() < mContent->ChildCount()) {
// No room left to map the remaining content; therefore, we're not complete
aStatus = NS_FRAME_NOT_COMPLETE;
}
} else if (NextChildOffset() < mContent->ChildCount()) {
// Try and pull-up some children from a next-in-flow
if (PullUpChildren(aPresContext, state)) {
// If we still have unmapped children then create some new frames
if (NextChildOffset() < mContent->ChildCount()) {
aStatus = ReflowUnmappedChildren(aPresContext, state);
}
} else {
// We were unable to pull-up all the existing frames from the next in flow;
// therefore, we're not complete
aStatus = NS_FRAME_NOT_COMPLETE;
}
}
}
#if 0
// XXX I don't think our return size properly accounts for the lineHeight
// (which may not == state.maxAscent + state.maxDescent)
// Return our size and our status
#endif
}
// Vertically align the children
@ -789,12 +888,6 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
ComputeFinalSize(aPresContext, state, aDesiredSize);
#if 0
// XXX I don't think our return size properly accounts for the lineHeight
// (which may not == state.maxAscent + state.maxDescent)
// Return our size and our status
#endif
#ifdef NS_DEBUG
if (GetVerifyTreeEnable()) {
PostReflowCheck(aStatus);
@ -852,7 +945,8 @@ NS_METHOD nsInlineFrame::GetReflowMetrics(nsIPresContext* aPresContext,
nscoord maxDescent = 0;
nsIFrame* kid = mFirstChild;
while (nsnull != kid) {
nsReflowMetrics kidMetrics;
// XXX Properly handle max element size...
nsReflowMetrics kidMetrics(aMetrics.maxElementSize);
kid->GetReflowMetrics(aPresContext, kidMetrics);
if (kidMetrics.ascent > maxAscent) maxAscent = kidMetrics.ascent;
if (kidMetrics.descent > maxDescent) maxDescent = kidMetrics.descent;
@ -887,7 +981,7 @@ PRInt32 nsInlineFrame::RecoverState(nsIPresContext* aPresContext,
nscoord maxAscent = 0;
nscoord maxDescent = 0;
while ((nsnull != kid) && (kid != aSkipChild)) {
nsReflowMetrics kidMetrics;
nsReflowMetrics kidMetrics(nsnull);
kid->GetReflowMetrics(aPresContext, kidMetrics);
aState.ascents[i] = kidMetrics.ascent;
if (kidMetrics.ascent > maxAscent) maxAscent = kidMetrics.ascent;
@ -977,152 +1071,6 @@ nsInlineFrame::IncrementalReflowAfter(nsIPresContext* aPresContext,
return status;
}
NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("nsInlineFrame::IncrementalReflow");
aStatus = NS_FRAME_COMPLETE; // initialize out parameter
// Get the style molecule
nsStyleFont* styleFont =
(nsStyleFont*)mStyleContext->GetData(eStyleStruct_Font);
nsStyleSpacing* styleSpacing =
(nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing);
nscoord lineHeight;
PRInt32 kidIndex;
nsMargin borderPadding;
styleSpacing->CalcBorderPaddingFor(this, borderPadding);
nsInlineState state(styleFont, borderPadding, aMaxSize, nsnull);
InitializeState(aPresContext, state);
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
if (aReflowCommand.GetTarget() == this) {
switch (aReflowCommand.GetType()) {
case nsReflowCommand::FrameAppended:
// Recover our state
RecoverState(aPresContext, state, nsnull);
aStatus = ReflowUnmappedChildren(aPresContext, state);
// Vertically align the children
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
styleFont, borderPadding.top, mFirstChild,
mChildCount, state.ascents, state.maxAscent);
ComputeFinalSize(aPresContext, state, aDesiredSize);
break;
#if 0
case nsReflowCommand::ContentChanged:
// Recover our state
kidFrame = aReflowCommand.GetChildFrame();
kidIndex = RecoverState(aPresContext, state, kidFrame);
aStatus = IncrementalReflowFrom(aPresContext, state, kidFrame, kidIndex);
// Vertically align the children
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
styleFont, borderPadding.top, mFirstChild,
mChildCount, state.ascents, state.maxAscent);
ComputeFinalSize(aPresContext, state, aDesiredSize);
break;
#endif
default:
NS_NOTYETIMPLEMENTED("unexpected reflow command");
break;
}
} else {
// The command is passing through us. Get the next frame in the reflow chain
nsIFrame* kidFrame = aReflowCommand.GetNext();
nsReflowMetrics kidSize;
// Restore our state as if nextFrame is the next frame to reflow
kidIndex = RecoverState(aPresContext, state, kidFrame);
// Reflow the child into the available space
aStatus = aReflowCommand.Next(kidSize, state.availSize, kidFrame);
// Did the child fit?
if ((kidSize.width > state.availSize.width) && (kidFrame != mFirstChild)) {
nsIFrame* prevFrame;
// The child is too wide to fit in the available space, and it's not our
// first child
PrevChild(kidFrame, prevFrame);
PushChildren(kidFrame, prevFrame, mLastContentIsComplete);
SetLastContentOffset(prevFrame);
mChildCount = kidIndex - 1;
aStatus = NS_FRAME_NOT_COMPLETE;
} else {
// Place and size the child
PlaceChild(kidFrame, kidIndex, state, kidSize, nsnull);
nsIFrame* kidNextInFlow;
kidFrame->GetNextInFlow(kidNextInFlow);
// Is the child complete?
if (NS_FRAME_IS_COMPLETE(aStatus)) {
// Check whether the frame has next-in-flow(s) that are no longer needed
if (nsnull != kidNextInFlow) {
// Remove the next-in-flow(s)
DeleteChildsNextInFlow(kidFrame);
}
// Adjust the frames that follow
aStatus = IncrementalReflowAfter(aPresContext, state, kidFrame, kidIndex);
} else {
nsIFrame* nextSibling;
// No, the child isn't complete
if (nsnull == kidNextInFlow) {
// The child doesn't have a next-in-flow so create a continuing
// frame.
nsIFrame* continuingFrame;
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame);
// Link the child into the sibling list
kidFrame->GetNextSibling(nextSibling);
continuingFrame->SetNextSibling(nextSibling);
kidFrame->SetNextSibling(continuingFrame);
}
// We've used up all of our available space, so push the remaining
// children to the next-in-flow
kidFrame->GetNextSibling(nextSibling);
if (nsnull != nextSibling) {
PushChildren(nextSibling, kidFrame, mLastContentIsComplete);
}
SetLastContentOffset(kidFrame);
mChildCount = kidIndex;
}
}
// Vertically align the children
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
styleFont, borderPadding.top, mFirstChild,
mChildCount, state.ascents, state.maxAscent);
ComputeFinalSize(aPresContext, state, aDesiredSize);
}
NS_FRAME_TRACE_REFLOW_OUT("nsInlineFrame::IncrementalReflow", aStatus);
return NS_OK;
}
// In order to execute the vertical alignment code after incremental
// reflow of the inline frame, we need to reposition any child frames
// that were relatively positioned back to their computed x origin.

View File

@ -43,44 +43,24 @@ NS_METHOD nsLeafFrame::Paint(nsIPresContext& aPresContext,
return NS_OK;
}
NS_METHOD nsLeafFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsLeafFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// XXX add in code to check for width/height being set via css
// and if set use them instead of calling GetDesiredSize.
GetDesiredSize(aPresContext, aDesiredSize, aMaxSize);
GetDesiredSize(aPresContext, aDesiredSize, aReflowState.maxSize);
AddBordersAndPadding(aPresContext, aDesiredSize);
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = aDesiredSize.width;
aMaxElementSize->height = aDesiredSize.height;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height;
}
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
NS_METHOD nsLeafFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
// XXX Unless the reflow command is a style change, we should
// just return the current size, otherwise we should invoke
// GetDesiredSize
// XXX add in code to check for width/height being set via css
// and if set use them instead of calling GetDesiredSize.
GetDesiredSize(aPresContext, aDesiredSize, aMaxSize);
AddBordersAndPadding(aPresContext, aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
// XXX how should border&padding effect baseline alignment?
// => descent = borderPadding.bottom for example
void nsLeafFrame::AddBordersAndPadding(nsIPresContext* aPresContext,

View File

@ -32,17 +32,10 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -326,14 +326,14 @@ nsLineLayout::WordBreakReflow()
mReflowType = NS_LINE_LAYOUT_REFLOW_TYPE_WORD_WRAP;
mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE;
nsSize maxElementSize;
nsReflowMetrics kidSize;
nsReflowStatus kidReflowStatus;
nsSize* kidMaxElementSize = nsnull;
if (nsnull != mMaxElementSizePointer) {
kidMaxElementSize = &maxElementSize;
}
rv = mBlock->ReflowInlineChild(frame, mPresContext, kidSize,
kidAvailSize, kidMaxElementSize,
nsReflowMetrics kidSize(kidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
rv = mBlock->ReflowInlineChild(frame, mPresContext, kidSize, kidReflowState,
kidReflowStatus);
return rv;
@ -502,7 +502,7 @@ nsLineLayout::ReflowMappedChild()
// IncrementalReflow AND GetReflowMetrics by those frames that are
// line layout aware.
mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE;
nsReflowMetrics kidMetrics;
nsReflowMetrics kidMetrics(nsnull);
mKidFrame->GetReflowMetrics(mPresContext, kidMetrics);
nsSize maxElementSize;
@ -612,31 +612,22 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
mFramesReflowed++;
nsRect kidRect;
nsSize maxElementSize;
nsReflowMetrics kidMetrics;
nsSize* kidMaxElementSize = nsnull;
nsReflowStatus kidReflowStatus;
if (nsnull != mMaxElementSizePointer) {
kidMaxElementSize = &maxElementSize;
}
nsReflowMetrics kidMetrics(kidMaxElementSize);
nsReflowState kidReflowState(aReflowCommand ? eReflowReason_Incremental :
eReflowReason_Resize, kidAvailSize);
kidReflowState.reflowCommand = aReflowCommand;
mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE;
nscoord dx = mReflowData.mX + kidMargin.left;
NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW,
("nsLineLayout::ReflowChild: reflowing frame=%p[%d] into %d,%d",
mKidFrame, mKidIndex,
kidAvailSize.width, kidAvailSize.height));
if (aReflowCommand) {
nsIFrame* nextFrame;
mSpaceManager->Translate(dx, mY);
kidReflowStatus = aReflowCommand->Next(mSpaceManager, kidRect, kidAvailSize, nextFrame);
mSpaceManager->Translate(-dx, -mY);
kidRect.x = dx;
kidRect.y = mY;
kidMetrics.width = kidRect.width;
kidMetrics.height = kidRect.height;
kidMetrics.ascent = kidRect.height;
kidMetrics.descent = 0;
} else if (isBlock) {
if (isBlock) {
// Calculate top margin by collapsing with previous bottom margin
nscoord negTopMargin;
nscoord posTopMargin;
@ -672,8 +663,8 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
mSpaceManager->Translate(dx, mY);
mKidFrame->WillReflow(*mPresContext);
rv = mBlock->ReflowBlockChild(mKidFrame, mPresContext,
mSpaceManager, kidAvailSize, kidRect,
kidMaxElementSize, kidReflowStatus);
mSpaceManager, kidMetrics, kidReflowState,
kidRect, kidReflowStatus);
mSpaceManager->Translate(-dx, -mY);
kidRect.x = dx;
kidRect.y = mY;
@ -685,9 +676,8 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
else {
// Reflow the inline child
mKidFrame->WillReflow(*mPresContext);
rv = mBlock->ReflowInlineChild(mKidFrame, mPresContext,
kidMetrics, kidAvailSize, kidMaxElementSize,
kidReflowStatus);
rv = mBlock->ReflowInlineChild(mKidFrame, mPresContext, kidMetrics,
kidReflowState, kidReflowStatus);
// After we reflow the inline child we will know whether or not it
// has any height/width. If it doesn't have any height/width then
// we do not yet apply any previous block bottom margin.
@ -815,7 +805,7 @@ nsLineLayout::PlaceChild(const nsRect& kidRect,
}
nsresult
nsLineLayout::IncrementalReflowFromChild(nsReflowCommand& aReflowCommand,
nsLineLayout::IncrementalReflowFromChild(nsReflowCommand* aReflowCommand,
nsIFrame* aChildFrame)
{
nsresult reflowStatus = NS_LINE_LAYOUT_COMPLETE;
@ -827,7 +817,7 @@ nsLineLayout::IncrementalReflowFromChild(nsReflowCommand& aReflowCommand,
while (kidNum < mLine->mChildCount) {
nsresult childReflowStatus;
if (mKidFrame == aChildFrame) {
childReflowStatus = ReflowChild(&aReflowCommand);
childReflowStatus = ReflowChild(aReflowCommand);
} else {
childReflowStatus = ReflowMappedChild();
}

View File

@ -78,7 +78,7 @@ struct nsLineLayout {
nsresult ReflowLine();
nsresult IncrementalReflowFromChild(nsReflowCommand& aReflowCommand,
nsresult IncrementalReflowFromChild(nsReflowCommand* aReflowCommand,
nsIFrame* aChildFrame);
// The presentation context

View File

@ -52,17 +52,10 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
NS_IMETHOD ResizeReflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
void GetBulletSize(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
@ -132,16 +125,15 @@ NS_METHOD BulletFrame::Paint(nsIPresContext& aCX,
return NS_OK;
}
NS_METHOD BulletFrame::ResizeReflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD BulletFrame::Reflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
GetBulletSize(aCX, aDesiredSize, aMaxSize);
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = aDesiredSize.width;
aMaxElementSize->height = aDesiredSize.height;
GetBulletSize(aCX, aDesiredSize, aReflowState.maxSize);
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height;
}
// This is done so that our containers VerifyTree code will work
@ -153,21 +145,6 @@ NS_METHOD BulletFrame::ResizeReflow(nsIPresContext* aCX,
return NS_OK;
}
NS_METHOD BulletFrame::IncrementalReflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
// XXX Unless the reflow command is a style change, we should
// just return the current size, otherwise we should invoke
// GetBulletSize
GetBulletSize(aCX, aDesiredSize, aMaxSize);
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
PRInt32 BulletFrame::GetListItemOrdinal(nsIPresContext* aCX,
nsStyleList& aListStyle)
{
@ -439,10 +416,11 @@ void
nsListItemFrame::PlaceOutsideBullet(nsIFrame* aBullet, nsIPresContext* aCX)
{
nsSize maxSize(0, 0);
nsReflowMetrics bulletSize;
nsReflowMetrics bulletSize(nsnull);
nsReflowState bulletReflowState(eReflowReason_Resize, maxSize);
// Size the bullet
ReflowChild(aBullet, aCX, bulletSize, maxSize, nsnull);
ReflowChild(aBullet, aCX, bulletSize, bulletReflowState);
// We can only back the bullet over so far
@ -574,12 +552,12 @@ nsListItemFrame::InsertBullet(nsIFrame* aBullet)
*/
// XXX we may need to grow to accomodate the bullet
// XXX check for compatability: <LI><H1>dah dah</H1> where is bullet?
NS_METHOD nsListItemFrame::ResizeReflow(nsIPresContext* aCX,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsListItemFrame::Reflow(nsIPresContext* aCX,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus)
{
PRBool insideBullet = PR_FALSE;
@ -623,9 +601,10 @@ NS_METHOD nsListItemFrame::ResizeReflow(nsIPresContext* aCX,
// Let base class do things first
nsBlockReflowState state;
InitializeState(aCX, aSpaceManager, aMaxSize, aMaxElementSize, state);
InitializeState(aCX, aSpaceManager, aReflowState.maxSize,
aDesiredSize.maxElementSize, state);
state.mFirstChildIsInsideBullet = insideBullet;
DoResizeReflow(state, aMaxSize, aDesiredRect, aStatus);
DoResizeReflow(state, aReflowState.maxSize, aDesiredRect, aStatus);
// Now place the bullet and put it at the head of the list of children
if (!insideBullet && (nsnull != bullet)) {

View File

@ -28,12 +28,12 @@ public:
nsIFrame* aParent);
// nsIFrame
NS_IMETHOD ResizeReflow(nsIPresContext* aCX,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aCX,
nsISpaceManager* aSpaceManager,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsRect& aDesiredRect,
nsReflowStatus& aStatus);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aCX,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,

View File

@ -54,72 +54,99 @@ void PageFrame::CreateFirstChild(nsIPresContext* aPresContext)
}
}
NS_METHOD PageFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD PageFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
#ifdef NS_DEBUG
PreReflowCheck();
#endif
aStatus = NS_FRAME_COMPLETE; // initialize out parameter
// Do we have any children?
if (nsnull == mFirstChild) {
if (nsnull == mPrevInFlow) {
// Create the first child frame
CreateFirstChild(aPresContext);
} else {
PageFrame* prevPage = (PageFrame*)mPrevInFlow;
// XXX Do something sensible in page mode...
if (eReflowReason_Incremental == aReflowState.reason) {
// We don't expect the target of the reflow command to be page frame
NS_ASSERTION(nsnull != aReflowState.reflowCommand, "null reflow command");
NS_ASSERTION(aReflowState.reflowCommand->GetTarget() != this,
"page frame is reflow command target");
// Verify the next reflow command frame is our one and only child frame
nsIFrame* next = aReflowState.reflowCommand->GetNext();
NS_ASSERTION(next == mFirstChild, "bad reflow frame");
NS_ASSERTION(!prevPage->mLastContentIsComplete, "bad continuing page");
nsIFrame* prevLastChild;
prevPage->LastChild(prevLastChild);
// Create a continuing child of the previous page's last child
nsIStyleContext* kidSC;
prevLastChild->GetStyleContext(aPresContext, kidSC);
nsresult rv = prevLastChild->CreateContinuingFrame(aPresContext, this,
kidSC, mFirstChild);
NS_RELEASE(kidSC);
mChildCount = 1;
mLastContentOffset = mFirstContentOffset;
}
}
// Resize our frame allowing it only to be as big as we are
// XXX Pay attention to the page's border and padding...
if (nsnull != mFirstChild) {
// Get the child's desired size
mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, aMaxSize,
aMaxElementSize);
mLastContentIsComplete = NS_FRAME_IS_COMPLETE(aStatus);
// Make sure the child is at least as tall as our max size (the containing window)
if (aDesiredSize.height < aMaxSize.height) {
aDesiredSize.height = aMaxSize.height;
// Dispatch the reflow command to our content child. Allow it to be as high
// as it wants
nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE);
nsReflowState reflowState(aReflowState.reflowCommand, maxSize);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState);
// Place and size the child. Make sure the child is at least as
// tall as our max size (the containing window)
if (aDesiredSize.height < aReflowState.maxSize.height) {
aDesiredSize.height = aReflowState.maxSize.height;
}
// Place and size the child
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
mFirstChild->SetRect(rect);
mFirstChild->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
// Is the frame complete?
if (NS_FRAME_IS_COMPLETE(aStatus)) {
nsIFrame* childNextInFlow;
mFirstChild->GetNextInFlow(childNextInFlow);
NS_ASSERTION(nsnull == childNextInFlow, "bad child flow list");
} else {
// Do we have any children?
if (nsnull == mFirstChild) {
if (nsnull == mPrevInFlow) {
// Create the first child frame
CreateFirstChild(aPresContext);
} else {
PageFrame* prevPage = (PageFrame*)mPrevInFlow;
NS_ASSERTION(!prevPage->mLastContentIsComplete, "bad continuing page");
nsIFrame* prevLastChild;
prevPage->LastChild(prevLastChild);
// Create a continuing child of the previous page's last child
nsIStyleContext* kidSC;
prevLastChild->GetStyleContext(aPresContext, kidSC);
nsresult rv = prevLastChild->CreateContinuingFrame(aPresContext, this,
kidSC, mFirstChild);
NS_RELEASE(kidSC);
mChildCount = 1;
mLastContentOffset = mFirstContentOffset;
}
}
// Resize our frame allowing it only to be as big as we are
// XXX Pay attention to the page's border and padding...
if (nsnull != mFirstChild) {
// Get the child's desired size
mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, aReflowState);
mLastContentIsComplete = NS_FRAME_IS_COMPLETE(aStatus);
// Make sure the child is at least as tall as our max size (the containing window)
if (aDesiredSize.height < aReflowState.maxSize.height) {
aDesiredSize.height = aReflowState.maxSize.height;
}
// Place and size the child
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
mFirstChild->SetRect(rect);
mFirstChild->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
// Is the frame complete?
if (NS_FRAME_IS_COMPLETE(aStatus)) {
nsIFrame* childNextInFlow;
mFirstChild->GetNextInFlow(childNextInFlow);
NS_ASSERTION(nsnull == childNextInFlow, "bad child flow list");
}
}
}
// Return our desired size
aDesiredSize.width = aMaxSize.width;
aDesiredSize.height = aMaxSize.height;
// Return our desired size
aDesiredSize.width = aReflowState.maxSize.width;
aDesiredSize.height = aReflowState.maxSize.height;
}
#ifdef NS_DEBUG
PostReflowCheck(aStatus);
@ -127,38 +154,6 @@ NS_METHOD PageFrame::ResizeReflow(nsIPresContext* aPresContext,
return NS_OK;
}
// XXX Do something sensible in page mode...
NS_METHOD PageFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
// We don't expect the target of the reflow command to be page frame
NS_ASSERTION(aReflowCommand.GetTarget() != this, "page frame is reflow command target");
nsSize maxSize(aMaxSize.width, NS_UNCONSTRAINEDSIZE);
nsIFrame* child;
// Dispatch the reflow command to our pseudo frame. Allow it to be as high
// as it wants
aStatus = aReflowCommand.Next(aDesiredSize, maxSize, child);
// Place and size the child. Make sure the child is at least as
// tall as our max size (the containing window)
if (nsnull != child) {
NS_ASSERTION(child == mFirstChild, "unexpected reflow command frame");
if (aDesiredSize.height < aMaxSize.height) {
aDesiredSize.height = aMaxSize.height;
}
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
child->SetRect(rect);
}
return NS_OK;
}
NS_METHOD
PageFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -25,17 +25,10 @@ class PageFrame : public nsContainerFrame {
public:
PageFrame(nsIContent* aContent, nsIFrame* aParent);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aMaxSize,
nsReflowStatus& aStatus);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aCX,
nsIFrame* aParent,

View File

@ -49,11 +49,10 @@ PlaceholderFrame::~PlaceholderFrame()
{
}
NS_METHOD PlaceholderFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD PlaceholderFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// Get the floater container in which we're inserted
nsIFloaterContainer* container = nsnull;
@ -79,24 +78,26 @@ NS_METHOD PlaceholderFrame::ResizeReflow(nsIPresContext* aPresContext,
// Resize reflow the anchored item into the available space
// XXX Check for complete?
mAnchoredItem->ResizeReflow(aPresContext, aDesiredSize, aMaxSize,
nsnull, aStatus);
mAnchoredItem->SizeTo(aDesiredSize.width, aDesiredSize.height);
nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Initial, aReflowState.maxSize);
mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus);
mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height);
// Now notify our containing block that there's a new floater
container->AddFloater(aPresContext, mAnchoredItem, this);
} else {
// XXX This causes anchored-items sizes to get fixed up; this is
// not quite right because this class should be implementing one
// of the incremental reflow methods and propogating things down
// of the incremental reflow methods and propagating things down
// properly to the contained frame.
mAnchoredItem->ResizeReflow(aPresContext, aDesiredSize, aMaxSize,
nsnull, aStatus);
mAnchoredItem->SizeTo(aDesiredSize.width, aDesiredSize.height);
nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aReflowState.maxSize);
mAnchoredItem->Reflow(aPresContext, desiredSize, reflowState, aStatus);
mAnchoredItem->SizeTo(desiredSize.width, desiredSize.height);
container->PlaceFloater(aPresContext, mAnchoredItem, this);
}
return nsFrame::ResizeReflow(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, aStatus);
return nsFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
}
NS_METHOD

View File

@ -42,11 +42,10 @@ public:
NS_IMETHOD NextChild(const nsIFrame* aChild, nsIFrame*& aNextChild) const;
NS_IMETHOD PrevChild(const nsIFrame* aChild, nsIFrame*& aPrevChild) const;
NS_IMETHOD LastChild(nsIFrame*& aLastChild) const;
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
NS_IMETHOD ListTag(FILE* out = stdout) const;

View File

@ -40,17 +40,10 @@ class RootFrame : public nsContainerFrame {
public:
RootFrame(nsIContent* aContent);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
@ -62,17 +55,10 @@ class RootContentFrame : public nsContainerFrame {
public:
RootContentFrame(nsIContent* aContent, nsIFrame* aParent);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
@ -89,93 +75,67 @@ RootFrame::RootFrame(nsIContent* aContent)
{
}
NS_METHOD RootFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD RootFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("RootFrame::ResizeReflow");
NS_FRAME_TRACE_REFLOW_IN("RootFrame::Reflow");
#ifdef NS_DEBUG
PreReflowCheck();
#endif
aStatus = NS_FRAME_COMPLETE;
// Do we have any children?
if (nsnull == mFirstChild) {
// No. Create a pseudo frame
mFirstChild = new RootContentFrame(mContent, this);
mChildCount = 1;
nsIStyleContext* style = aPresContext->ResolvePseudoStyleContextFor(nsHTMLAtoms::rootContentPseudo, this);
mFirstChild->SetStyleContext(aPresContext,style);
NS_RELEASE(style);
if (eReflowReason_Incremental == aReflowState.reason) {
// We don't expect the target of the reflow command to be the root frame
NS_ASSERTION(nsnull != aReflowState.reflowCommand, "no reflow command");
NS_ASSERTION(aReflowState.reflowCommand->GetTarget() != this,
"root frame is reflow command target");
// Verify that the next frame in the reflow chain is our pseudo frame
nsIFrame* next = aReflowState.reflowCommand->GetNext();
NS_ASSERTION(next == mFirstChild, "unexpected next reflow command frame");
} else {
// Do we have any children?
if (nsnull == mFirstChild) {
// No. Create a pseudo frame
NS_ASSERTION(eReflowReason_Initial == aReflowState.reason, "unexpected reflow reason");
mFirstChild = new RootContentFrame(mContent, this);
mChildCount = 1;
nsIStyleContext* style = aPresContext->ResolvePseudoStyleContextFor(nsHTMLAtoms::rootContentPseudo, this);
mFirstChild->SetStyleContext(aPresContext,style);
NS_RELEASE(style);
}
}
// Resize the pseudo frame passing it our max size. It will choose whatever
// height its child frame wants...
// Reflow our pseudo frame. It will choose whetever height its child frame
// wants
nsReflowMetrics desiredSize(nsnull);
if (nsnull != mFirstChild) {
nsReflowMetrics desiredSize;
mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, desiredSize, aMaxSize,
aMaxElementSize);
aStatus = ReflowChild(mFirstChild, aPresContext, desiredSize, aReflowState);
// Place and size the child
nsRect rect(0, 0, desiredSize.width, desiredSize.height);
mFirstChild->SetRect(rect);
mFirstChild->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
}
mLastContentOffset = ((RootContentFrame*)mFirstChild)->GetLastContentOffset();
// Return the max size as our desired size
aDesiredSize.width = aMaxSize.width;
aDesiredSize.height = aMaxSize.height;
aDesiredSize.ascent = aMaxSize.height;
aDesiredSize.descent = 0;
#ifdef NS_DEBUG
PostReflowCheck(aStatus);
#endif
NS_FRAME_TRACE_REFLOW_OUT("RootFrame::ResizeReflow", aStatus);
return NS_OK;
}
NS_METHOD RootFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("RootFrame::IncrementalReflow");
// We don't expect the target of the reflow command to be the root frame
NS_ASSERTION(aReflowCommand.GetTarget() != this, "root frame is reflow command target");
nsReflowMetrics desiredSize;
nsIFrame* child;
// Dispatch the reflow command to our pseudo frame
mFirstChild->WillReflow(*aPresContext);
aStatus = aReflowCommand.Next(desiredSize, aMaxSize, child);
// Place and size the child
if (nsnull != child) {
NS_ASSERTION(child == mFirstChild, "unexpected reflow command frame");
nsRect rect(0, 0, desiredSize.width, desiredSize.height);
child->SetRect(rect);
child->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
mLastContentOffset = ((RootContentFrame*)mFirstChild)->GetLastContentOffset();
}
// Return the max size as our desired size
aDesiredSize.width = aMaxSize.width;
aDesiredSize.height = aMaxSize.height;
aDesiredSize.ascent = aMaxSize.height;
aDesiredSize.width = aReflowState.maxSize.width;
aDesiredSize.height = aReflowState.maxSize.height;
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
NS_FRAME_TRACE_REFLOW_OUT("RootFrame::IncrementalReflow", aStatus);
#ifdef NS_DEBUG
PostReflowCheck(aStatus);
#endif
NS_FRAME_TRACE_REFLOW_OUT("RootFrame::Reflow", aStatus);
return NS_OK;
}
@ -300,155 +260,152 @@ void RootContentFrame::CreateFirstChild(nsIPresContext* aPresContext)
// XXX Hack
#define PAGE_SPACING 100
NS_METHOD RootContentFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD RootContentFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("RootContentFrame::ResizeReflow");
NS_FRAME_TRACE_REFLOW_IN("RootContentFrame::Reflow");
#ifdef NS_DEBUG
PreReflowCheck();
#endif
aStatus = NS_FRAME_COMPLETE;
// Do we have any children?
if (nsnull == mFirstChild) {
// No, create the first child frame
CreateFirstChild(aPresContext);
}
// XXX Incremental reflow code doesn't handle page mode at all...
if (eReflowReason_Incremental == aReflowState.reason) {
// We don't expect the target of the reflow command to be the root
// content frame
NS_ASSERTION(aReflowState.reflowCommand->GetTarget() != this,
"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
nsIFrame* next = aReflowState.reflowCommand->GetNext();
NS_ASSERTION(next == mFirstChild, "unexpected next reflow command frame");
// Resize our frames
if (nsnull != mFirstChild) {
if (aPresContext->IsPaginated()) {
nscoord y = PAGE_SPACING;
nsReflowMetrics kidSize;
nsSize pageSize(aPresContext->GetPageWidth(),
aPresContext->GetPageHeight());
// Tile the pages vertically
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
// Reflow the page
kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame, aPresContext, kidSize,
pageSize, aMaxElementSize);
// Place and size the page. If the page is narrower than our max width then
// center it horizontally
nsIDeviceContext *dx = aPresContext->GetDeviceContext();
PRInt32 extra = aMaxSize.width - kidSize.width - NS_TO_INT_ROUND(dx->GetScrollBarWidth());
NS_RELEASE(dx);
kidFrame->SetRect(nsRect(extra > 0 ? extra / 2 : 0, y, kidSize.width, kidSize.height));
kidFrame->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
y += kidSize.height;
// Leave a slight gap between the pages
y += PAGE_SPACING;
// Is the page complete?
nsIFrame* kidNextInFlow;
kidFrame->GetNextInFlow(kidNextInFlow);
if (NS_FRAME_IS_COMPLETE(status)) {
NS_ASSERTION(nsnull == kidNextInFlow, "bad child flow list");
} else if (nsnull == kidNextInFlow) {
// The page isn't complete and it doesn't have a next-in-flow so
// create a continuing page
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
nsIFrame* continuingPage;
nsresult rv = kidFrame->CreateContinuingFrame(aPresContext, this,
kidSC, continuingPage);
NS_RELEASE(kidSC);
// Add it to our child list
#ifdef NS_DEBUG
nsIFrame* kidNextSibling;
kidFrame->GetNextSibling(kidNextSibling);
NS_ASSERTION(nsnull == kidNextSibling, "unexpected sibling");
#endif
kidFrame->SetNextSibling(continuingPage);
mChildCount++;
}
// Get the next page
kidFrame->GetNextSibling(kidFrame);
// Dispatch the reflow command to our child frame. Allow it to be as high
// as it wants
mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState);
// Place and size the child. Make sure the child is at least as
// tall as our max size (the containing window)
if (nsnull != mFirstChild) {
if (aDesiredSize.height < aReflowState.maxSize.height) {
aDesiredSize.height = aReflowState.maxSize.height;
}
// Return our desired size
aDesiredSize.width = aMaxSize.width;
aDesiredSize.height = y;
} else {
// Allow the frame to be as wide as our max width, and as high
// as it wants to be.
nsSize maxSize(aMaxSize.width, NS_UNCONSTRAINEDSIZE);
// Get the child's desired size. Our child's desired height is our
// desired size
mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, maxSize,
aMaxElementSize);
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
// Place and size the child. Make sure the child is at least as
// tall as our max size (the containing window)
if (aDesiredSize.height < aMaxSize.height) {
aDesiredSize.height = aMaxSize.height;
}
// Place and size the child
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
mFirstChild->SetRect(rect);
mFirstChild->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
}
} else {
// Do we have any children?
if (nsnull == mFirstChild) {
// No, create the first child frame
CreateFirstChild(aPresContext);
}
// Resize our frames
if (nsnull != mFirstChild) {
if (aPresContext->IsPaginated()) {
nscoord y = PAGE_SPACING;
nsReflowMetrics kidSize(aDesiredSize.maxElementSize);
nsSize pageSize(aPresContext->GetPageWidth(),
aPresContext->GetPageHeight());
nsReflowState reflowState(aReflowState.reason, pageSize);
// Tile the pages vertically
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
// Reflow the page
nsReflowStatus status;
kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, reflowState);
// Place and size the page. If the page is narrower than our max width then
// center it horizontally
nsIDeviceContext *dx = aPresContext->GetDeviceContext();
PRInt32 extra = aReflowState.maxSize.width - kidSize.width -
NS_TO_INT_ROUND(dx->GetScrollBarWidth());
NS_RELEASE(dx);
kidFrame->SetRect(nsRect(extra > 0 ? extra / 2 : 0, y, kidSize.width, kidSize.height));
kidFrame->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
y += kidSize.height;
// Leave a slight gap between the pages
y += PAGE_SPACING;
// Is the page complete?
nsIFrame* kidNextInFlow;
kidFrame->GetNextInFlow(kidNextInFlow);
if (NS_FRAME_IS_COMPLETE(status)) {
NS_ASSERTION(nsnull == kidNextInFlow, "bad child flow list");
} else if (nsnull == kidNextInFlow) {
// The page isn't complete and it doesn't have a next-in-flow so
// create a continuing page
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
nsIFrame* continuingPage;
nsresult rv = kidFrame->CreateContinuingFrame(aPresContext, this,
kidSC, continuingPage);
NS_RELEASE(kidSC);
// Add it to our child list
#ifdef NS_DEBUG
nsIFrame* kidNextSibling;
kidFrame->GetNextSibling(kidNextSibling);
NS_ASSERTION(nsnull == kidNextSibling, "unexpected sibling");
#endif
kidFrame->SetNextSibling(continuingPage);
mChildCount++;
}
// Get the next page
kidFrame->GetNextSibling(kidFrame);
}
// Return our desired size
aDesiredSize.width = aReflowState.maxSize.width;
aDesiredSize.height = y;
} else {
// Allow the frame to be as wide as our max width, and as high
// as it wants to be.
nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE);
nsReflowState reflowState(aReflowState.reason, maxSize);
// Get the child's desired size. Our child's desired height is our
// desired size
mFirstChild->WillReflow(*aPresContext);
aStatus = ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState);
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
// Place and size the child. Make sure the child is at least as
// tall as our max size (the containing window)
if (aDesiredSize.height < aReflowState.maxSize.height) {
aDesiredSize.height = aReflowState.maxSize.height;
}
// Place and size the child
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
mFirstChild->SetRect(rect);
mFirstChild->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
}
}
}
#ifdef NS_DEBUG
PostReflowCheck(aStatus);
#endif
NS_FRAME_TRACE_REFLOW_OUT("RootContentFrame::ResizeReflow", aStatus);
return NS_OK;
}
// XXX Do something sensible for page mode...
NS_METHOD RootContentFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_FRAME_TRACE_REFLOW_IN("RootContentFrame::IncrementalReflow");
// We don't expect the target of the reflow command to be the root
// content frame
NS_ASSERTION(aReflowCommand.GetTarget() != this, "root content frame is reflow command target");
nsSize maxSize(aMaxSize.width, NS_UNCONSTRAINEDSIZE);
nsIFrame* child;
// Dispatch the reflow command to our pseudo frame. Allow it to be as high
// as it wants
mFirstChild->WillReflow(*aPresContext);
aStatus = aReflowCommand.Next(aDesiredSize, maxSize, child);
// Place and size the child. Make sure the child is at least as
// tall as our max size (the containing window)
if (nsnull != child) {
NS_ASSERTION(child == mFirstChild, "unexpected reflow command frame");
if (aDesiredSize.height < aMaxSize.height) {
aDesiredSize.height = aMaxSize.height;
}
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
child->SetRect(rect);
child->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
}
NS_FRAME_TRACE_REFLOW_OUT("RootContentFrame::IncrementalReflow", aStatus);
NS_FRAME_TRACE_REFLOW_OUT("RootContentFrame::Reflow", aStatus);
return NS_OK;
}

View File

@ -38,11 +38,10 @@ class SpacerFrame : public nsFrame
public:
SpacerFrame(nsIContent* aContent, nsIFrame* aParentFrame);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
protected:
virtual ~SpacerFrame();
};
@ -81,11 +80,10 @@ SpacerFrame::~SpacerFrame()
{
}
NS_METHOD SpacerFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD SpacerFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// Get cached state for containing block frame
nsBlockReflowState* state = nsnull;

View File

@ -121,11 +121,10 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
NS_IMETHOD ResizeReflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD GetReflowMetrics(nsIPresContext* aPresContext,
nsReflowMetrics& aMetrics);
@ -747,17 +746,16 @@ NS_METHOD TextFrame::GetReflowMetrics(nsIPresContext* aCX,
return NS_OK;
}
NS_METHOD TextFrame::ResizeReflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD TextFrame::Reflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
#ifdef NOISY
ListTag(stdout);
printf(": resize reflow into %g,%g\n",
NS_TWIPS_TO_POINTS_FLOAT(aMaxSize.width),
NS_TWIPS_TO_POINTS_FLOAT(aMaxSize.height));
NS_TWIPS_TO_POINTS_FLOAT(aReflowState.maxSize.width),
NS_TWIPS_TO_POINTS_FLOAT(aReflowState.maxSize.height));
#endif
// Wipe out old justification information since it's going to change
@ -804,14 +802,14 @@ NS_METHOD TextFrame::ResizeReflow(nsIPresContext* aCX,
if (NS_STYLE_WHITESPACE_PRE == text->mWhiteSpace) {
// Use a specialized routine for pre-formatted text
aStatus = ReflowPre(aCX, aDesiredSize, aMaxSize,
aMaxElementSize, *font, startingOffset,
aStatus = ReflowPre(aCX, aDesiredSize, aReflowState.maxSize,
aDesiredSize.maxElementSize, *font, startingOffset,
lineLayoutState);
} else {
// Use normal wrapping routine for non-pre text (this includes
// text that is not wrapping)
aStatus = ReflowNormal(aCX, aDesiredSize, aMaxSize,
aMaxElementSize, *font, *text,
aStatus = ReflowNormal(aCX, aDesiredSize, aReflowState.maxSize,
aDesiredSize.maxElementSize, *font, *text,
startingOffset, lineLayoutState);
}

View File

@ -107,11 +107,10 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
virtual void PostCreateWidget(nsIPresContext* aPresContext, nsIView* aView);
@ -405,27 +404,26 @@ nsInputButtonFrame::MouseClicked(nsIPresContext* aPresContext)
}
NS_METHOD
nsInputButtonFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsInputButtonFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if ((kButtonTag_Input == GetButtonTagType()) &&
(kButton_Image == GetButtonType())) {
nsSize ignore;
GetDesiredSize(aPresContext, aMaxSize, aDesiredSize, ignore);
GetDesiredSize(aPresContext, aReflowState.maxSize, aDesiredSize, ignore);
AddBordersAndPadding(aPresContext, aDesiredSize);
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = aDesiredSize.width;
aMaxElementSize->height = aDesiredSize.height;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height;
}
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
else {
return nsInputButtonFrameSuper::
ResizeReflow(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, aStatus);
Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
}
}

View File

@ -139,11 +139,10 @@ nsInputFileFrame::SizeTo(nscoord aWidth, nscoord aHeight)
return NS_OK;
}
NS_IMETHODIMP nsInputFileFrame::ResizeReflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_IMETHODIMP nsInputFileFrame::Reflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsIFrame* childFrame;
PRInt32 numChildren;
@ -174,13 +173,14 @@ NS_IMETHODIMP nsInputFileFrame::ResizeReflow(nsIPresContext* aCX,
}
}
nsSize maxSize = aMaxSize;
nsSize maxSize = aReflowState.maxSize;
nsReflowMetrics desiredSize = aDesiredSize;
aDesiredSize.width = gSpacing;
aDesiredSize.height = 0;
childFrame = mFirstChild;
while (nsnull != childFrame) {
nsresult result = childFrame->ResizeReflow(aCX, desiredSize, maxSize, nsnull, aStatus);
nsReflowState reflowState(aReflowState, maxSize);
nsresult result = childFrame->Reflow(aCX, desiredSize, reflowState, aStatus);
// XXX check aStatus ??
if (NS_OK != result) {
break;
@ -194,9 +194,9 @@ NS_IMETHODIMP nsInputFileFrame::ResizeReflow(nsIPresContext* aCX,
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = aDesiredSize.width;
aMaxElementSize->height = aDesiredSize.height;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height;
}
aStatus = NS_FRAME_COMPLETE;

View File

@ -31,11 +31,10 @@ class nsString;
class nsInputFileFrame : public nsInlineFrame {
public:
nsInputFileFrame(nsIContent* aContent, nsIFrame* aParentFrame);
NS_IMETHOD ResizeReflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
virtual void MouseClicked(nsIPresContext* aPresContext);
NS_IMETHOD MoveTo(nscoord aX, nscoord aY);
NS_IMETHOD SizeTo(nscoord aWidth, nscoord aHeight);

View File

@ -213,11 +213,10 @@ nsInputFrame::GetDesiredSize(nsIPresContext* aPresContext,
}
NS_METHOD
nsInputFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsInputFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsIView* view = nsnull;
GetView(view);
@ -240,7 +239,7 @@ nsInputFrame::ResizeReflow(nsIPresContext* aPresContext,
nsIPresShell *presShell = aPresContext->GetShell(); // need to release
nsIViewManager *viewMan = presShell->GetViewManager(); // need to release
GetDesiredSize(aPresContext, aMaxSize, aDesiredSize, mWidgetSize);
GetDesiredSize(aPresContext, aReflowState.maxSize, aDesiredSize, mWidgetSize);
//nsRect boundBox(0, 0, mWidgetSize.width, mWidgetSize.height);
nsRect boundBox(0, 0, aDesiredSize.width, aDesiredSize.height);
@ -287,7 +286,7 @@ nsInputFrame::ResizeReflow(nsIPresContext* aPresContext,
NS_IF_RELEASE(presShell);
}
else {
GetDesiredSize(aPresContext, aMaxSize, aDesiredSize, mWidgetSize);
GetDesiredSize(aPresContext, aReflowState.maxSize, aDesiredSize, mWidgetSize);
// If we are being reflowed and have a view, hide the view until
// we are told to paint (which is when our location will have
@ -298,9 +297,9 @@ nsInputFrame::ResizeReflow(nsIPresContext* aPresContext,
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = aDesiredSize.width;
aMaxElementSize->height = aDesiredSize.height;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height;
}
aStatus = NS_FRAME_COMPLETE;

View File

@ -108,13 +108,12 @@ public:
/**
* Respond to the request to resize and/or reflow
* @see nsIFrame::ResizeReflow
* @see nsIFrame::Reflow
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
// new behavior

View File

@ -28,7 +28,7 @@
nsCellLayoutData::nsCellLayoutData(nsTableCellFrame *aCellFrame,
nsReflowMetrics * aDesiredSize, nsSize * aMaxElementSize)
: mDesiredSize(nsnull)
{
// IMPORTANT: Always intialize instance variables to null
mCellFrame = nsnull;

View File

@ -227,11 +227,10 @@ nsTableFrame* nsTableCellFrame::GetTableFrame()
/**
*/
NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_PRECONDITION(nsnull!=aPresContext, "bad arg");
@ -242,16 +241,15 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
aStatus = NS_FRAME_COMPLETE;
if (gsDebug==PR_TRUE)
printf("nsTableCellFrame::ResizeReflow: maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height);
aReflowState.maxSize.width, aReflowState.maxSize.height);
mFirstContentOffset = mLastContentOffset = 0;
nsSize availSize(aMaxSize);
nsSize availSize(aReflowState.maxSize);
nsSize maxElementSize;
nsSize *pMaxElementSize = aMaxElementSize;
if (NS_UNCONSTRAINEDSIZE==aMaxSize.width)
nsSize *pMaxElementSize = aDesiredSize.maxElementSize;
if (NS_UNCONSTRAINEDSIZE==aReflowState.maxSize.width)
pMaxElementSize = &maxElementSize;
nsReflowMetrics kidSize;
nscoord x = 0;
// SEC: what about ascent and decent???
@ -296,7 +294,9 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
if (gsDebug==PR_TRUE)
printf(" nsTableCellFrame::ResizeReflow calling ReflowChild with availSize=%d,%d\n",
availSize.width, availSize.height);
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, availSize, pMaxElementSize);
nsReflowMetrics kidSize(pMaxElementSize);
nsReflowState kidReflowState(aReflowState, availSize);
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);
if (gsDebug==PR_TRUE)
{
@ -341,11 +341,11 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
aDesiredSize.ascent = topInset;
aDesiredSize.descent = bottomInset;
if (nsnull!=aMaxElementSize)
if (nsnull!=aDesiredSize.maxElementSize)
{
*aMaxElementSize = *pMaxElementSize;
aMaxElementSize->height += topInset + bottomInset;
aMaxElementSize->width += leftInset + rightInset;
*aDesiredSize.maxElementSize = *pMaxElementSize;
aDesiredSize.maxElementSize->height += topInset + bottomInset;
aDesiredSize.maxElementSize->width += leftInset + rightInset;
}
if (gsDebug==PR_TRUE)
@ -359,18 +359,6 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsTableCellFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
if (gsDebug == PR_TRUE) printf("nsTableCellFrame::IncrementalReflow\n");
// total hack for now, just some hard-coded values
ResizeReflow(aPresContext, aDesiredSize, aMaxSize, nsnull, aStatus);
return NS_OK;
}
NS_METHOD
nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -42,17 +42,10 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/**
* @see nsContainerFrame

View File

@ -47,35 +47,22 @@ NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext& aPresContext,
NS_METHOD
nsTableColGroupFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_ASSERTION(nsnull!=aPresContext, "bad arg");
if (gsDebug==PR_TRUE) printf("nsTableColGroupFrame::ResizeReflow\n");
if (gsDebug==PR_TRUE) printf("nsTableColGroupFrame::Reflow\n");
aDesiredSize.width=0;
aDesiredSize.height=0;
if (nsnull!=aMaxElementSize)
if (nsnull!=aDesiredSize.maxElementSize)
{
aMaxElementSize->width=0;
aMaxElementSize->height=0;
aDesiredSize.maxElementSize->width=0;
aDesiredSize.maxElementSize->height=0;
}
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
NS_METHOD
nsTableColGroupFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_ASSERTION(nsnull!=aPresContext, "bad arg");
if (gsDebug==PR_TRUE) printf("nsTableColGroupFrame::IncrementalReflow\n");
return NS_OK;
}
nsresult nsTableColGroupFrame::NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
nsIFrame* aParent)

View File

@ -41,16 +41,9 @@ public:
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
protected:
nsTableColGroupFrame(nsIContent* aContent, nsIFrame* aParentFrame);

View File

@ -476,18 +476,17 @@ PRBool nsTableFrame::NeedsReflow(const nsSize& aMaxSize)
/** Layout the entire inner table.
*/
NS_METHOD nsTableFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_PRECONDITION(nsnull != aPresContext, "null arg");
if (gsDebug==PR_TRUE)
{
printf("-----------------------------------------------------------------\n");
printf("nsTableFrame::ResizeReflow: maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height);
printf("nsTableFrame::Reflow: maxSize=%d,%d\n",
aReflowState.maxSize.width, aReflowState.maxSize.height);
}
#ifdef NS_DEBUG
@ -504,25 +503,25 @@ NS_METHOD nsTableFrame::ResizeReflow(nsIPresContext* aPresContext,
if (PR_TRUE==gsDebug)
printf ("*** tableframe reflow\t\t%p\n", this);
if (PR_TRUE==NeedsReflow(aMaxSize))
if (PR_TRUE==NeedsReflow(aReflowState.maxSize))
{
if (PR_FALSE==IsFirstPassValid())
{ // we treat the table as if we've never seen the layout data before
mPass = kPASS_FIRST;
aStatus = ResizeReflowPass1(aPresContext, aDesiredSize,
aMaxSize, aMaxElementSize);
aReflowState.maxSize, aDesiredSize.maxElementSize);
// check result
}
mPass = kPASS_SECOND;
// assign column widths, and assign aMaxElementSize->width
BalanceColumnWidths(aPresContext, aMaxSize, aMaxElementSize);
BalanceColumnWidths(aPresContext, aReflowState.maxSize, aDesiredSize.maxElementSize);
// assign table width
SetTableWidth(aPresContext);
aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aMaxSize,
aMaxElementSize, 0, 0);
aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aReflowState.maxSize,
aDesiredSize.maxElementSize, 0, 0);
if (gsTiming) {
PRIntervalTime endTime = PR_IntervalNow();
@ -579,7 +578,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
nsSize maxSize(0, 0); // maxSize is the size of the largest child so far in the process
nsSize kidMaxSize(0,0);
nsSize* pKidMaxSize = (nsnull != aMaxElementSize) ? &kidMaxSize : nsnull;
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxSize);
nscoord y = 0;
nscoord maxAscent = 0;
nscoord maxDescent = 0;
@ -642,7 +641,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
}
nsSize maxKidElementSize;
result = ReflowChild(kidFrame, aPresContext, kidSize, availSize, pKidMaxSize);
nsReflowState kidReflowState(eReflowReason_Resize, availSize);
result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Place the child since some of it's content fit in us.
if (gsDebug) {
@ -984,7 +984,7 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
nsSize kidAvailSize(aState.availSize);
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(pKidMaxElementSize);
nsReflowStatus status;
// Get top margin for this kid
@ -1015,8 +1015,8 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
}
// Reflow the child into the available space
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
// Did the child fit?
if ((kidFrame != mFirstChild) && (desiredSize.height > kidAvailSize.height))
@ -1195,7 +1195,7 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
while (nsnull != nextInFlow) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowStatus status;
// Get the next child
@ -1230,8 +1230,8 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
mLastContentIsComplete = prevLastContentIsComplete;
break;
}
status = ReflowChild(kidFrame, aPresContext, kidSize, aState.availSize,
pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) {
@ -1435,9 +1435,9 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not
// fit or might need continuing.
nsReflowMetrics kidSize;
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize,
aState.availSize, pKidMaxElementSize);
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Initial, aState.availSize);
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) {
@ -1888,26 +1888,6 @@ PRBool nsTableFrame::IsProportionalWidth(nsStylePosition* aStylePosition)
return result;
}
/**
*/
NS_METHOD nsTableFrame::IncrementalReflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_ASSERTION(nsnull != aCX, "bad arg");
if (gsDebug==PR_TRUE) printf ("nsTableFrame::IncrementalReflow: maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height);
// mFirstPassValid needs to be set somewhere in response to change notifications.
aDesiredSize.width = mRect.width;
aDesiredSize.height = mRect.height;
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
void nsTableFrame::VerticallyAlignChildren(nsIPresContext* aPresContext,
nscoord* aAscents,
nscoord aMaxAscent,

View File

@ -71,27 +71,19 @@ public:
* do column balancing
* set mFirstPassValid to true
* do pass 2
* use column widths to ResizeReflow cells
* use column widths to Reflow cells
* shrinkWrap Cells in each row to tallest, realigning contents within the cell
* </pre>
*
* @see ResizeReflowPass1
* @see ResizeReflowPass2
* @see BalanceColumnWidths
* @see nsIFrame::ResizeReflow
* @see nsIFrame::Reflow
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
/** @see nsIFrame::IncrementalReflow */
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,

View File

@ -106,7 +106,8 @@ nsTableOuterFrame::nsTableOuterFrame(nsIContent* aContent, nsIFrame* aParentFram
mBottomCaptions(nsnull),
mMinCaptionWidth(0),
mMaxCaptionWidth(0),
mFirstPassValid(PR_FALSE)
mFirstPassValid(PR_FALSE),
mDesiredSize(nsnull)
{
}
@ -151,7 +152,7 @@ void nsTableOuterFrame::SetFirstPassValid(PRBool aValidState)
}
/**
* ResizeReflow is a 2-step process.
* Reflow is a 2-step process.
* In the first step, we lay out all of the captions and the inner table in NS_UNCONSTRAINEDSIZE space.
* This gives us absolute minimum and maximum widths.
* In the second step, we force all the captions and the table to the width of the widest component,
@ -160,17 +161,16 @@ void nsTableOuterFrame::SetFirstPassValid(PRBool aValidState)
* NOTE: for breaking across pages, this method has to account for table content that is not laid out
* linearly vis a vis the frames. That is, content hierarchy and the frame hierarchy do not match.
*/
NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if (PR_TRUE==gsDebug)
printf ("***table outer frame reflow \t\t%p\n", this);
if (PR_TRUE==gsDebug)
printf("nsTableOuterFrame::ResizeReflow : maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height);
printf("nsTableOuterFrame::Reflow : maxSize=%d,%d\n",
aReflowState.maxSize.width, aReflowState.maxSize.height);
#ifdef NS_DEBUG
// replace with a check that does not assume linear placement of children
@ -178,9 +178,9 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
#endif
// Initialize out parameter
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = 0;
aMaxElementSize->height = 0;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = 0;
aDesiredSize.maxElementSize->height = 0;
}
PRBool reflowMappedOK = PR_TRUE;
@ -206,7 +206,7 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
return NS_OK;
}
OuterTableReflowState state(aPresContext, aMaxSize);
OuterTableReflowState state(aPresContext, aReflowState.maxSize);
// lay out captions pass 1, if necessary
if (PR_FALSE==IsFirstPassValid())
@ -222,7 +222,7 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
// we treat the table as if we've never seen the layout data before
mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_FIRST);
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize, aMaxSize,
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState.maxSize,
&innerTableMaxElementSize);
mInnerTableFrame->RecalcLayoutData();
@ -236,7 +236,7 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
if (nsnull==prevInFlow)
{
// assign column widths, and assign aMaxElementSize->width
mInnerTableFrame->BalanceColumnWidths(aPresContext, aMaxSize, aMaxElementSize);
mInnerTableFrame->BalanceColumnWidths(aPresContext, aReflowState.maxSize, aDesiredSize.maxElementSize);
// assign table width
mInnerTableFrame->SetTableWidth(aPresContext);
}
@ -245,11 +245,11 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
mInnerTableFrame->GetSize(innerTableSize);
state.innerTableMaxSize.width = innerTableSize.width;
state.innerTableMaxSize.height = aMaxSize.height;
state.innerTableMaxSize.height = aReflowState.maxSize.height;
// Reflow the child frames
if (nsnull != mFirstChild) {
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aMaxElementSize);
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
if (PR_FALSE == reflowMappedOK) {
aStatus = NS_FRAME_NOT_COMPLETE;
}
@ -265,7 +265,7 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
}
} else if (NextChildOffset() < mContent->ChildCount()) {
// Try and pull-up some children from a next-in-flow
if (PullUpChildren(aPresContext, state, aMaxElementSize)) {
if (PullUpChildren(aPresContext, state, aDesiredSize.maxElementSize)) {
// If we still have unmapped children then create some new frames
NS_ABORT(); // huge error for tables!
} else {
@ -293,17 +293,17 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
* trying to lay out in a slot that we know isn't tall enough to fit our minimum.
* otherwise, we're as tall as our kids want us to be */
if (NS_FRAME_IS_NOT_COMPLETE(aStatus))
aDesiredSize.height = aMaxSize.height;
aDesiredSize.height = aReflowState.maxSize.height;
else
aDesiredSize.height = state.y;
if (gsDebug==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
if (nsnull!=aDesiredSize.maxElementSize)
printf("Outer frame Reflow complete, returning %s with aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
NS_FRAME_IS_COMPLETE(aStatus)? "Complete" : "Not Complete",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
else
printf("Outer frame Reflow complete, returning %s with aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
NS_FRAME_IS_COMPLETE(aStatus)? "Complete" : "Not Complete",
@ -440,7 +440,7 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
PRBool result = PR_TRUE;
aState.availSize.width = aState.innerTableMaxSize.width;
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowStatus status;
SetReflowState(aState, kidFrame);
@ -663,7 +663,7 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
while (nsnull != nextInFlow) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowStatus status;
// Get the next child
@ -1022,10 +1022,11 @@ nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext)
{
nsSize maxElementSize(0,0);
nsSize maxSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(&maxElementSize);
nsTableCaptionFrame *captionFrame = (nsTableCaptionFrame *)mCaptionFrames->ElementAt(captionIndex);
nsReflowStatus status;
captionFrame->ResizeReflow(aPresContext, desiredSize, maxSize, &maxElementSize, status);
nsReflowState reflowState(eReflowReason_Resize, maxSize);
captionFrame->Reflow(aPresContext, desiredSize, reflowState, status);
if (mMinCaptionWidth<maxElementSize.width)
mMinCaptionWidth = maxElementSize.width;
if (mMaxCaptionWidth<desiredSize.width)
@ -1071,8 +1072,9 @@ nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
// reflow the caption, skipping top captions after the first that doesn't fit
if (NS_FRAME_IS_COMPLETE(result))
{
nsReflowMetrics desiredSize;
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, aMaxSize, nsnull);
nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aMaxSize);
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);
// place the caption
captionFrame->SetRect(nsRect(0, topCaptionY, desiredSize.width, desiredSize.height));
if (NS_UNCONSTRAINEDSIZE!=desiredSize.height)
@ -1130,8 +1132,9 @@ nsTableOuterFrame::ResizeReflowBottomCaptionsPass2(nsIPresContext* aPresContext
NS_ASSERTION(nsnull != captionStyle, "null style molecule for caption");
*/
// reflow the caption
nsReflowMetrics desiredSize;
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, aMaxSize, nsnull);
nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aMaxSize);
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);
// place the caption
nsRect rect;
@ -1189,19 +1192,6 @@ void nsTableOuterFrame::SetLastContentOffset(const nsIFrame* aLastChild)
}
*/
NS_METHOD
nsTableOuterFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
if (PR_TRUE==gsDebug) printf("nsTableOuterFrame::IncrementalReflow\n");
// total hack for now, just some hard-coded values
ResizeReflow(aPresContext, aDesiredSize, aMaxSize, nsnull, aStatus);
return NS_OK;
}
NS_METHOD
nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -80,20 +80,12 @@ public:
* @see nsTableFrame::ResizeReflowPass1
* @see nsTableFrame::ResizeReflowPass2
* @see nsTableFrame::BalanceColumnWidths
* @see nsIFrame::ResizeReflow
* @see nsIFrame::Reflow
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
/** @see nsIFrame::IncrementalReflow */
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/** @see nsContainerFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,

View File

@ -317,7 +317,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
if (0>=kidAvailSize.height)
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(pKidMaxElementSize);
nsReflowStatus status;
nsMargin kidMargin(0,0,0,0);
@ -343,8 +343,9 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
{
// Reflow the child into the available space
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
kidReflowState);
nsCellLayoutData kidLayoutData((nsTableCellFrame *)kidFrame, &desiredSize, pKidMaxElementSize);
aState.tableFrame->SetCellLayoutData(&kidLayoutData, cell);
}
@ -358,8 +359,8 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
kidAvailSize.width = availWidth;
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
}
if (nsnull!=pKidMaxElementSize)
{
@ -579,7 +580,7 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
while (nsnull != nextInFlow) {
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(pKidMaxElementSize);
nsReflowStatus status;
// Get the next child
@ -630,8 +631,8 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
NS_ASSERTION(0<availWidth, "illegal width for this column");
kidAvailSize.width = availWidth;
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
if (nsnull!=pKidMaxElementSize)
{
if (gsDebug1)
@ -889,13 +890,13 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not
// fit or might need continuing.
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(pKidMaxElementSize);
nsReflowStatus status;
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
{
nsReflowState kidReflowState(eReflowReason_Initial, kidAvailSize);
// Reflow the child into the available space
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
nsCellLayoutData kidLayoutData((nsTableCellFrame *)kidFrame, &desiredSize, pKidMaxElementSize);
aState.tableFrame->SetCellLayoutData(&kidLayoutData, (nsTableCell *)cell);
}
@ -909,8 +910,8 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
NS_ASSERTION(0<availWidth, "illegal width for this column");
kidAvailSize.width = availWidth;
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Initial, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
}
if (nsnull!=pKidMaxElementSize)
{
@ -995,23 +996,22 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
* Rows are responsible for layout of their children (cells).
*/
NS_METHOD
nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if (gsDebug1==PR_TRUE)
printf("nsTableRowFrame::ResizeReflow - aMaxSize = %d, %d\n",
aMaxSize.width, aMaxSize.height);
printf("nsTableRowFrame::Reflow - aMaxSize = %d, %d\n",
aReflowState.maxSize.width, aReflowState.maxSize.height);
#ifdef NS_DEBUG
PreReflowCheck();
#endif
// Initialize out parameter
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = 0;
aMaxElementSize->height = 0;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = 0;
aDesiredSize.maxElementSize->height = 0;
}
// Initialize our internal data
@ -1024,12 +1024,12 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
// Check for an overflow list
MoveOverflowToChildList();
RowReflowState state(aPresContext, aMaxSize);
RowReflowState state(aPresContext, aReflowState.maxSize);
mContentParent->GetContentParent((nsIFrame*&)(state.tableFrame));
// Reflow the existing frames
if (nsnull != mFirstChild) {
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aMaxElementSize);
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
if (PR_FALSE == reflowMappedOK) {
aStatus = NS_FRAME_NOT_COMPLETE;
}
@ -1045,10 +1045,10 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
}
} else if (NextChildOffset() < mContent->ChildCount()) {
// Try and pull-up some children from a next-in-flow
if (PullUpChildren(aPresContext, state, aMaxElementSize)) {
if (PullUpChildren(aPresContext, state, aDesiredSize.maxElementSize)) {
// If we still have unmapped children then create some new frames
if (NextChildOffset() < mContent->ChildCount()) {
aStatus = ReflowUnmappedChildren(aPresContext, state, aMaxElementSize);
aStatus = ReflowUnmappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
}
} else {
// We were unable to pull-up all the existing frames from the
@ -1066,7 +1066,7 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
}
// Return our desired rect
aDesiredSize.width = aMaxSize.width;
aDesiredSize.width = aReflowState.maxSize.width;
aDesiredSize.height = state.maxCellVertSpace;
#ifdef NS_DEBUG
@ -1075,11 +1075,11 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
if (gsDebug1==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
if (nsnull!=aDesiredSize.maxElementSize)
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
else
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
@ -1090,18 +1090,6 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
}
NS_METHOD
nsTableRowFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
if (gsDebug1==PR_TRUE) printf("nsTableRowFrame::IncrementalReflow\n");
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
NS_METHOD
nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -64,7 +64,7 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** calls ResizeReflow for all of its child cells.
/** calls Reflow for all of its child cells.
* Cells with rowspan=1 are all set to the same height and stacked horizontally.
* <P> Cells are not split unless absolutely necessary.
* <P> Cells are resized in nsTableFrame::BalanceColumnWidths
@ -73,22 +73,14 @@ public:
* @param aDesiredSize width set to width of the sum of the cells, height set to
* height of cells with rowspan=1.
*
* @see nsIFrame::ResizeReflow
* @see nsIFrame::Reflow
* @see nsTableFrame::BalanceColumnWidths
* @see nsTableFrame::ShrinkWrapChildren
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
/** @see nsIFrame::IncrementalReflow */
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,

View File

@ -268,7 +268,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
nsSize kidAvailSize(aState.availSize);
if (0>=kidAvailSize.height)
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(pKidMaxElementSize);
nsReflowStatus status;
// Get top margin for this kid
@ -296,8 +296,8 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
}
// Reflow the child into the available space
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
// Did the child fit?
if ((kidFrame != mFirstChild) &&
@ -494,7 +494,7 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
while (nsnull != nextInFlow) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowStatus status;
// Get the next child
@ -530,8 +530,8 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
mLastContentIsComplete = prevLastContentIsComplete;
break;
}
status = ReflowChild(kidFrame, aPresContext, kidSize, aState.availSize,
pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) {
@ -757,9 +757,10 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not
// fit or might need continuing.
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Initial, aState.availSize);
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize,
aState.availSize, pKidMaxElementSize);
kidReflowState);
// Did the child fit?
if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) {
@ -818,23 +819,22 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
* Rows are responsible for layout of their children.
*/
NS_METHOD
nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if (gsDebug1==PR_TRUE)
printf("nsTableRowGroupFrame::ResizeReflow - aMaxSize = %d, %d\n",
aMaxSize.width, aMaxSize.height);
printf("nsTableRowGroupFrame::Reflow - aMaxSize = %d, %d\n",
aReflowState.maxSize.width, aReflowState.maxSize.height);
#ifdef NS_DEBUG
PreReflowCheck();
#endif
// Initialize out parameter
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = 0;
aMaxElementSize->height = 0;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = 0;
aDesiredSize.maxElementSize->height = 0;
}
PRBool reflowMappedOK = PR_TRUE;
@ -844,11 +844,11 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
// Check for an overflow list
MoveOverflowToChildList();
RowGroupReflowState state(aPresContext, aMaxSize);
RowGroupReflowState state(aPresContext, aReflowState.maxSize);
// Reflow the existing frames
if (nsnull != mFirstChild) {
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aMaxElementSize);
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
if (PR_FALSE == reflowMappedOK) {
aStatus = NS_FRAME_NOT_COMPLETE;
}
@ -864,10 +864,10 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
}
} else if (NextChildOffset() < mContent->ChildCount()) {
// Try and pull-up some children from a next-in-flow
if (PullUpChildren(aPresContext, state, aMaxElementSize)) {
if (PullUpChildren(aPresContext, state, aDesiredSize.maxElementSize)) {
// If we still have unmapped children then create some new frames
if (NextChildOffset() < mContent->ChildCount()) {
aStatus = ReflowUnmappedChildren(aPresContext, state, aMaxElementSize);
aStatus = ReflowUnmappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
}
} else {
// We were unable to pull-up all the existing frames from the
@ -890,7 +890,7 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
// Return our desired rect
//NS_ASSERTION(0<state.firstRowHeight, "illegal firstRowHeight after reflow");
//NS_ASSERTION(0<state.y, "illegal height after reflow");
aDesiredSize.width = aMaxSize.width;
aDesiredSize.width = aReflowState.maxSize.width;
aDesiredSize.height = state.y;
#ifdef NS_DEBUG
@ -899,11 +899,11 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
if (gsDebug1==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
if (nsnull!=aDesiredSize.maxElementSize)
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
else
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
@ -914,23 +914,6 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
}
NS_METHOD
nsTableRowGroupFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
if (gsDebug1==PR_TRUE) printf("nsTableRowGroupFrame::IncrementalReflow\n");
// total hack for now, just some hard-coded values
aDesiredSize.width = aMaxSize.width;
aDesiredSize.height = aMaxSize.height;
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
NS_METHOD
nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -62,26 +62,19 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** calls ResizeReflow for all of its child rows.
/** calls Reflow for all of its child rows.
* Rows are all set to the same width and stacked vertically.
* <P> rows are not split unless absolutely necessary.
*
* @param aDesiredSize width set to width of rows, height set to
* sum of height of rows that fit in aMaxSize.height.
*
* @see nsIFrame::ResizeReflow
* @see nsIFrame::Reflow
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
/** @see nsIFrame::IncrementalReflow */
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,

View File

@ -67,10 +67,10 @@ public:
FixedSizeFrame(nsIContent* aContent,
nsIFrame* aParentFrame);
nsReflowStatus ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
PRBool IsSplittable() const;
};
@ -108,13 +108,13 @@ FixedSizeFrame::FixedSizeFrame(nsIContent* aContent,
{
}
nsReflowStatus
FixedSizeFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize)
NS_METHOD FixedSizeFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_PRECONDITION((aMaxSize.width > 0) && (aMaxSize.height > 0), "bad max size");
NS_PRECONDITION((aReflowState.maxSize.width > 0) && (aReflowState.maxSize.height > 0),
"bad max size");
FixedSizeContent* content = (FixedSizeContent*)mContent;
nsReflowStatus status = NS_FRAME_COMPLETE;
FixedSizeFrame* prevInFlow = (FixedSizeFrame*)mPrevInFlow;
@ -125,16 +125,16 @@ FixedSizeFrame::ResizeReflow(nsIPresContext* aPresContext,
// We can split once horizontally
if (nsnull != prevInFlow) {
aDesiredSize.width -= prevInFlow->mRect.width;
} else if ((aDesiredSize.width > aMaxSize.width) && content->IsSplittable()) {
aDesiredSize.width = aMaxSize.width;
} else if ((aDesiredSize.width > aReflowState.maxSize.width) && content->IsSplittable()) {
aDesiredSize.width = aReflowState.maxSize.width;
status = NS_FRAME_NOT_COMPLETE;
}
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = aDesiredSize.width;
aMaxElementSize->height = aDesiredSize.height;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height;
}
return status;

View File

@ -227,11 +227,10 @@ nsTableFrame* nsTableCellFrame::GetTableFrame()
/**
*/
NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_PRECONDITION(nsnull!=aPresContext, "bad arg");
@ -242,16 +241,15 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
aStatus = NS_FRAME_COMPLETE;
if (gsDebug==PR_TRUE)
printf("nsTableCellFrame::ResizeReflow: maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height);
aReflowState.maxSize.width, aReflowState.maxSize.height);
mFirstContentOffset = mLastContentOffset = 0;
nsSize availSize(aMaxSize);
nsSize availSize(aReflowState.maxSize);
nsSize maxElementSize;
nsSize *pMaxElementSize = aMaxElementSize;
if (NS_UNCONSTRAINEDSIZE==aMaxSize.width)
nsSize *pMaxElementSize = aDesiredSize.maxElementSize;
if (NS_UNCONSTRAINEDSIZE==aReflowState.maxSize.width)
pMaxElementSize = &maxElementSize;
nsReflowMetrics kidSize;
nscoord x = 0;
// SEC: what about ascent and decent???
@ -296,7 +294,9 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
if (gsDebug==PR_TRUE)
printf(" nsTableCellFrame::ResizeReflow calling ReflowChild with availSize=%d,%d\n",
availSize.width, availSize.height);
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, availSize, pMaxElementSize);
nsReflowMetrics kidSize(pMaxElementSize);
nsReflowState kidReflowState(aReflowState, availSize);
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);
if (gsDebug==PR_TRUE)
{
@ -341,11 +341,11 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
aDesiredSize.ascent = topInset;
aDesiredSize.descent = bottomInset;
if (nsnull!=aMaxElementSize)
if (nsnull!=aDesiredSize.maxElementSize)
{
*aMaxElementSize = *pMaxElementSize;
aMaxElementSize->height += topInset + bottomInset;
aMaxElementSize->width += leftInset + rightInset;
*aDesiredSize.maxElementSize = *pMaxElementSize;
aDesiredSize.maxElementSize->height += topInset + bottomInset;
aDesiredSize.maxElementSize->width += leftInset + rightInset;
}
if (gsDebug==PR_TRUE)
@ -359,18 +359,6 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsTableCellFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
if (gsDebug == PR_TRUE) printf("nsTableCellFrame::IncrementalReflow\n");
// total hack for now, just some hard-coded values
ResizeReflow(aPresContext, aDesiredSize, aMaxSize, nsnull, aStatus);
return NS_OK;
}
NS_METHOD
nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -42,17 +42,10 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/**
* @see nsContainerFrame

View File

@ -47,35 +47,22 @@ NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext& aPresContext,
NS_METHOD
nsTableColGroupFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_ASSERTION(nsnull!=aPresContext, "bad arg");
if (gsDebug==PR_TRUE) printf("nsTableColGroupFrame::ResizeReflow\n");
if (gsDebug==PR_TRUE) printf("nsTableColGroupFrame::Reflow\n");
aDesiredSize.width=0;
aDesiredSize.height=0;
if (nsnull!=aMaxElementSize)
if (nsnull!=aDesiredSize.maxElementSize)
{
aMaxElementSize->width=0;
aMaxElementSize->height=0;
aDesiredSize.maxElementSize->width=0;
aDesiredSize.maxElementSize->height=0;
}
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
NS_METHOD
nsTableColGroupFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_ASSERTION(nsnull!=aPresContext, "bad arg");
if (gsDebug==PR_TRUE) printf("nsTableColGroupFrame::IncrementalReflow\n");
return NS_OK;
}
nsresult nsTableColGroupFrame::NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
nsIFrame* aParent)

View File

@ -41,16 +41,9 @@ public:
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
protected:
nsTableColGroupFrame(nsIContent* aContent, nsIFrame* aParentFrame);

View File

@ -476,18 +476,17 @@ PRBool nsTableFrame::NeedsReflow(const nsSize& aMaxSize)
/** Layout the entire inner table.
*/
NS_METHOD nsTableFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_PRECONDITION(nsnull != aPresContext, "null arg");
if (gsDebug==PR_TRUE)
{
printf("-----------------------------------------------------------------\n");
printf("nsTableFrame::ResizeReflow: maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height);
printf("nsTableFrame::Reflow: maxSize=%d,%d\n",
aReflowState.maxSize.width, aReflowState.maxSize.height);
}
#ifdef NS_DEBUG
@ -504,25 +503,25 @@ NS_METHOD nsTableFrame::ResizeReflow(nsIPresContext* aPresContext,
if (PR_TRUE==gsDebug)
printf ("*** tableframe reflow\t\t%p\n", this);
if (PR_TRUE==NeedsReflow(aMaxSize))
if (PR_TRUE==NeedsReflow(aReflowState.maxSize))
{
if (PR_FALSE==IsFirstPassValid())
{ // we treat the table as if we've never seen the layout data before
mPass = kPASS_FIRST;
aStatus = ResizeReflowPass1(aPresContext, aDesiredSize,
aMaxSize, aMaxElementSize);
aReflowState.maxSize, aDesiredSize.maxElementSize);
// check result
}
mPass = kPASS_SECOND;
// assign column widths, and assign aMaxElementSize->width
BalanceColumnWidths(aPresContext, aMaxSize, aMaxElementSize);
BalanceColumnWidths(aPresContext, aReflowState.maxSize, aDesiredSize.maxElementSize);
// assign table width
SetTableWidth(aPresContext);
aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aMaxSize,
aMaxElementSize, 0, 0);
aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aReflowState.maxSize,
aDesiredSize.maxElementSize, 0, 0);
if (gsTiming) {
PRIntervalTime endTime = PR_IntervalNow();
@ -579,7 +578,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
nsSize maxSize(0, 0); // maxSize is the size of the largest child so far in the process
nsSize kidMaxSize(0,0);
nsSize* pKidMaxSize = (nsnull != aMaxElementSize) ? &kidMaxSize : nsnull;
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxSize);
nscoord y = 0;
nscoord maxAscent = 0;
nscoord maxDescent = 0;
@ -642,7 +641,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
}
nsSize maxKidElementSize;
result = ReflowChild(kidFrame, aPresContext, kidSize, availSize, pKidMaxSize);
nsReflowState kidReflowState(eReflowReason_Resize, availSize);
result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Place the child since some of it's content fit in us.
if (gsDebug) {
@ -984,7 +984,7 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
nsSize kidAvailSize(aState.availSize);
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(pKidMaxElementSize);
nsReflowStatus status;
// Get top margin for this kid
@ -1015,8 +1015,8 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
}
// Reflow the child into the available space
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
// Did the child fit?
if ((kidFrame != mFirstChild) && (desiredSize.height > kidAvailSize.height))
@ -1195,7 +1195,7 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
while (nsnull != nextInFlow) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowStatus status;
// Get the next child
@ -1230,8 +1230,8 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
mLastContentIsComplete = prevLastContentIsComplete;
break;
}
status = ReflowChild(kidFrame, aPresContext, kidSize, aState.availSize,
pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) {
@ -1435,9 +1435,9 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not
// fit or might need continuing.
nsReflowMetrics kidSize;
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize,
aState.availSize, pKidMaxElementSize);
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Initial, aState.availSize);
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) {
@ -1888,26 +1888,6 @@ PRBool nsTableFrame::IsProportionalWidth(nsStylePosition* aStylePosition)
return result;
}
/**
*/
NS_METHOD nsTableFrame::IncrementalReflow(nsIPresContext* aCX,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
NS_ASSERTION(nsnull != aCX, "bad arg");
if (gsDebug==PR_TRUE) printf ("nsTableFrame::IncrementalReflow: maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height);
// mFirstPassValid needs to be set somewhere in response to change notifications.
aDesiredSize.width = mRect.width;
aDesiredSize.height = mRect.height;
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
void nsTableFrame::VerticallyAlignChildren(nsIPresContext* aPresContext,
nscoord* aAscents,
nscoord aMaxAscent,

View File

@ -71,27 +71,19 @@ public:
* do column balancing
* set mFirstPassValid to true
* do pass 2
* use column widths to ResizeReflow cells
* use column widths to Reflow cells
* shrinkWrap Cells in each row to tallest, realigning contents within the cell
* </pre>
*
* @see ResizeReflowPass1
* @see ResizeReflowPass2
* @see BalanceColumnWidths
* @see nsIFrame::ResizeReflow
* @see nsIFrame::Reflow
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
/** @see nsIFrame::IncrementalReflow */
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,

View File

@ -106,7 +106,8 @@ nsTableOuterFrame::nsTableOuterFrame(nsIContent* aContent, nsIFrame* aParentFram
mBottomCaptions(nsnull),
mMinCaptionWidth(0),
mMaxCaptionWidth(0),
mFirstPassValid(PR_FALSE)
mFirstPassValid(PR_FALSE),
mDesiredSize(nsnull)
{
}
@ -151,7 +152,7 @@ void nsTableOuterFrame::SetFirstPassValid(PRBool aValidState)
}
/**
* ResizeReflow is a 2-step process.
* Reflow is a 2-step process.
* In the first step, we lay out all of the captions and the inner table in NS_UNCONSTRAINEDSIZE space.
* This gives us absolute minimum and maximum widths.
* In the second step, we force all the captions and the table to the width of the widest component,
@ -160,17 +161,16 @@ void nsTableOuterFrame::SetFirstPassValid(PRBool aValidState)
* NOTE: for breaking across pages, this method has to account for table content that is not laid out
* linearly vis a vis the frames. That is, content hierarchy and the frame hierarchy do not match.
*/
NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if (PR_TRUE==gsDebug)
printf ("***table outer frame reflow \t\t%p\n", this);
if (PR_TRUE==gsDebug)
printf("nsTableOuterFrame::ResizeReflow : maxSize=%d,%d\n",
aMaxSize.width, aMaxSize.height);
printf("nsTableOuterFrame::Reflow : maxSize=%d,%d\n",
aReflowState.maxSize.width, aReflowState.maxSize.height);
#ifdef NS_DEBUG
// replace with a check that does not assume linear placement of children
@ -178,9 +178,9 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
#endif
// Initialize out parameter
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = 0;
aMaxElementSize->height = 0;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = 0;
aDesiredSize.maxElementSize->height = 0;
}
PRBool reflowMappedOK = PR_TRUE;
@ -206,7 +206,7 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
return NS_OK;
}
OuterTableReflowState state(aPresContext, aMaxSize);
OuterTableReflowState state(aPresContext, aReflowState.maxSize);
// lay out captions pass 1, if necessary
if (PR_FALSE==IsFirstPassValid())
@ -222,7 +222,7 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
// we treat the table as if we've never seen the layout data before
mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_FIRST);
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize, aMaxSize,
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState.maxSize,
&innerTableMaxElementSize);
mInnerTableFrame->RecalcLayoutData();
@ -236,7 +236,7 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
if (nsnull==prevInFlow)
{
// assign column widths, and assign aMaxElementSize->width
mInnerTableFrame->BalanceColumnWidths(aPresContext, aMaxSize, aMaxElementSize);
mInnerTableFrame->BalanceColumnWidths(aPresContext, aReflowState.maxSize, aDesiredSize.maxElementSize);
// assign table width
mInnerTableFrame->SetTableWidth(aPresContext);
}
@ -245,11 +245,11 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
mInnerTableFrame->GetSize(innerTableSize);
state.innerTableMaxSize.width = innerTableSize.width;
state.innerTableMaxSize.height = aMaxSize.height;
state.innerTableMaxSize.height = aReflowState.maxSize.height;
// Reflow the child frames
if (nsnull != mFirstChild) {
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aMaxElementSize);
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
if (PR_FALSE == reflowMappedOK) {
aStatus = NS_FRAME_NOT_COMPLETE;
}
@ -265,7 +265,7 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
}
} else if (NextChildOffset() < mContent->ChildCount()) {
// Try and pull-up some children from a next-in-flow
if (PullUpChildren(aPresContext, state, aMaxElementSize)) {
if (PullUpChildren(aPresContext, state, aDesiredSize.maxElementSize)) {
// If we still have unmapped children then create some new frames
NS_ABORT(); // huge error for tables!
} else {
@ -293,17 +293,17 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
* trying to lay out in a slot that we know isn't tall enough to fit our minimum.
* otherwise, we're as tall as our kids want us to be */
if (NS_FRAME_IS_NOT_COMPLETE(aStatus))
aDesiredSize.height = aMaxSize.height;
aDesiredSize.height = aReflowState.maxSize.height;
else
aDesiredSize.height = state.y;
if (gsDebug==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
if (nsnull!=aDesiredSize.maxElementSize)
printf("Outer frame Reflow complete, returning %s with aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
NS_FRAME_IS_COMPLETE(aStatus)? "Complete" : "Not Complete",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
else
printf("Outer frame Reflow complete, returning %s with aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
NS_FRAME_IS_COMPLETE(aStatus)? "Complete" : "Not Complete",
@ -440,7 +440,7 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
PRBool result = PR_TRUE;
aState.availSize.width = aState.innerTableMaxSize.width;
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowStatus status;
SetReflowState(aState, kidFrame);
@ -663,7 +663,7 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
while (nsnull != nextInFlow) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowStatus status;
// Get the next child
@ -1022,10 +1022,11 @@ nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext)
{
nsSize maxElementSize(0,0);
nsSize maxSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(&maxElementSize);
nsTableCaptionFrame *captionFrame = (nsTableCaptionFrame *)mCaptionFrames->ElementAt(captionIndex);
nsReflowStatus status;
captionFrame->ResizeReflow(aPresContext, desiredSize, maxSize, &maxElementSize, status);
nsReflowState reflowState(eReflowReason_Resize, maxSize);
captionFrame->Reflow(aPresContext, desiredSize, reflowState, status);
if (mMinCaptionWidth<maxElementSize.width)
mMinCaptionWidth = maxElementSize.width;
if (mMaxCaptionWidth<desiredSize.width)
@ -1071,8 +1072,9 @@ nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
// reflow the caption, skipping top captions after the first that doesn't fit
if (NS_FRAME_IS_COMPLETE(result))
{
nsReflowMetrics desiredSize;
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, aMaxSize, nsnull);
nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aMaxSize);
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);
// place the caption
captionFrame->SetRect(nsRect(0, topCaptionY, desiredSize.width, desiredSize.height));
if (NS_UNCONSTRAINEDSIZE!=desiredSize.height)
@ -1130,8 +1132,9 @@ nsTableOuterFrame::ResizeReflowBottomCaptionsPass2(nsIPresContext* aPresContext
NS_ASSERTION(nsnull != captionStyle, "null style molecule for caption");
*/
// reflow the caption
nsReflowMetrics desiredSize;
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, aMaxSize, nsnull);
nsReflowMetrics desiredSize(nsnull);
nsReflowState reflowState(eReflowReason_Resize, aMaxSize);
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);
// place the caption
nsRect rect;
@ -1189,19 +1192,6 @@ void nsTableOuterFrame::SetLastContentOffset(const nsIFrame* aLastChild)
}
*/
NS_METHOD
nsTableOuterFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
if (PR_TRUE==gsDebug) printf("nsTableOuterFrame::IncrementalReflow\n");
// total hack for now, just some hard-coded values
ResizeReflow(aPresContext, aDesiredSize, aMaxSize, nsnull, aStatus);
return NS_OK;
}
NS_METHOD
nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -80,20 +80,12 @@ public:
* @see nsTableFrame::ResizeReflowPass1
* @see nsTableFrame::ResizeReflowPass2
* @see nsTableFrame::BalanceColumnWidths
* @see nsIFrame::ResizeReflow
* @see nsIFrame::Reflow
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
/** @see nsIFrame::IncrementalReflow */
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/** @see nsContainerFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,

View File

@ -317,7 +317,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
if (0>=kidAvailSize.height)
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(pKidMaxElementSize);
nsReflowStatus status;
nsMargin kidMargin(0,0,0,0);
@ -343,8 +343,9 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
{
// Reflow the child into the available space
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
kidReflowState);
nsCellLayoutData kidLayoutData((nsTableCellFrame *)kidFrame, &desiredSize, pKidMaxElementSize);
aState.tableFrame->SetCellLayoutData(&kidLayoutData, cell);
}
@ -358,8 +359,8 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
kidAvailSize.width = availWidth;
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
}
if (nsnull!=pKidMaxElementSize)
{
@ -579,7 +580,7 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
while (nsnull != nextInFlow) {
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(pKidMaxElementSize);
nsReflowStatus status;
// Get the next child
@ -630,8 +631,8 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
NS_ASSERTION(0<availWidth, "illegal width for this column");
kidAvailSize.width = availWidth;
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
if (nsnull!=pKidMaxElementSize)
{
if (gsDebug1)
@ -889,13 +890,13 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not
// fit or might need continuing.
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(pKidMaxElementSize);
nsReflowStatus status;
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
{
nsReflowState kidReflowState(eReflowReason_Initial, kidAvailSize);
// Reflow the child into the available space
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
nsCellLayoutData kidLayoutData((nsTableCellFrame *)kidFrame, &desiredSize, pKidMaxElementSize);
aState.tableFrame->SetCellLayoutData(&kidLayoutData, (nsTableCell *)cell);
}
@ -909,8 +910,8 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
NS_ASSERTION(0<availWidth, "illegal width for this column");
kidAvailSize.width = availWidth;
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Initial, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
}
if (nsnull!=pKidMaxElementSize)
{
@ -995,23 +996,22 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
* Rows are responsible for layout of their children (cells).
*/
NS_METHOD
nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if (gsDebug1==PR_TRUE)
printf("nsTableRowFrame::ResizeReflow - aMaxSize = %d, %d\n",
aMaxSize.width, aMaxSize.height);
printf("nsTableRowFrame::Reflow - aMaxSize = %d, %d\n",
aReflowState.maxSize.width, aReflowState.maxSize.height);
#ifdef NS_DEBUG
PreReflowCheck();
#endif
// Initialize out parameter
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = 0;
aMaxElementSize->height = 0;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = 0;
aDesiredSize.maxElementSize->height = 0;
}
// Initialize our internal data
@ -1024,12 +1024,12 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
// Check for an overflow list
MoveOverflowToChildList();
RowReflowState state(aPresContext, aMaxSize);
RowReflowState state(aPresContext, aReflowState.maxSize);
mContentParent->GetContentParent((nsIFrame*&)(state.tableFrame));
// Reflow the existing frames
if (nsnull != mFirstChild) {
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aMaxElementSize);
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
if (PR_FALSE == reflowMappedOK) {
aStatus = NS_FRAME_NOT_COMPLETE;
}
@ -1045,10 +1045,10 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
}
} else if (NextChildOffset() < mContent->ChildCount()) {
// Try and pull-up some children from a next-in-flow
if (PullUpChildren(aPresContext, state, aMaxElementSize)) {
if (PullUpChildren(aPresContext, state, aDesiredSize.maxElementSize)) {
// If we still have unmapped children then create some new frames
if (NextChildOffset() < mContent->ChildCount()) {
aStatus = ReflowUnmappedChildren(aPresContext, state, aMaxElementSize);
aStatus = ReflowUnmappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
}
} else {
// We were unable to pull-up all the existing frames from the
@ -1066,7 +1066,7 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
}
// Return our desired rect
aDesiredSize.width = aMaxSize.width;
aDesiredSize.width = aReflowState.maxSize.width;
aDesiredSize.height = state.maxCellVertSpace;
#ifdef NS_DEBUG
@ -1075,11 +1075,11 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
if (gsDebug1==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
if (nsnull!=aDesiredSize.maxElementSize)
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
else
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
@ -1090,18 +1090,6 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
}
NS_METHOD
nsTableRowFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
if (gsDebug1==PR_TRUE) printf("nsTableRowFrame::IncrementalReflow\n");
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
NS_METHOD
nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -64,7 +64,7 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** calls ResizeReflow for all of its child cells.
/** calls Reflow for all of its child cells.
* Cells with rowspan=1 are all set to the same height and stacked horizontally.
* <P> Cells are not split unless absolutely necessary.
* <P> Cells are resized in nsTableFrame::BalanceColumnWidths
@ -73,22 +73,14 @@ public:
* @param aDesiredSize width set to width of the sum of the cells, height set to
* height of cells with rowspan=1.
*
* @see nsIFrame::ResizeReflow
* @see nsIFrame::Reflow
* @see nsTableFrame::BalanceColumnWidths
* @see nsTableFrame::ShrinkWrapChildren
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
/** @see nsIFrame::IncrementalReflow */
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,

View File

@ -268,7 +268,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
nsSize kidAvailSize(aState.availSize);
if (0>=kidAvailSize.height)
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
nsReflowMetrics desiredSize;
nsReflowMetrics desiredSize(pKidMaxElementSize);
nsReflowStatus status;
// Get top margin for this kid
@ -296,8 +296,8 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
}
// Reflow the child into the available space
status = ReflowChild(kidFrame, aPresContext, desiredSize,
kidAvailSize, pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, kidAvailSize);
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
// Did the child fit?
if ((kidFrame != mFirstChild) &&
@ -494,7 +494,7 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
PRBool result = PR_TRUE;
while (nsnull != nextInFlow) {
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowStatus status;
// Get the next child
@ -530,8 +530,8 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
mLastContentIsComplete = prevLastContentIsComplete;
break;
}
status = ReflowChild(kidFrame, aPresContext, kidSize, aState.availSize,
pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Resize, aState.availSize);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit?
if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) {
@ -757,9 +757,10 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Try to reflow the child into the available space. It might not
// fit or might need continuing.
nsReflowMetrics kidSize;
nsReflowMetrics kidSize(pKidMaxElementSize);
nsReflowState kidReflowState(eReflowReason_Initial, aState.availSize);
nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize,
aState.availSize, pKidMaxElementSize);
kidReflowState);
// Did the child fit?
if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) {
@ -818,23 +819,22 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
* Rows are responsible for layout of their children.
*/
NS_METHOD
nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus)
nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if (gsDebug1==PR_TRUE)
printf("nsTableRowGroupFrame::ResizeReflow - aMaxSize = %d, %d\n",
aMaxSize.width, aMaxSize.height);
printf("nsTableRowGroupFrame::Reflow - aMaxSize = %d, %d\n",
aReflowState.maxSize.width, aReflowState.maxSize.height);
#ifdef NS_DEBUG
PreReflowCheck();
#endif
// Initialize out parameter
if (nsnull != aMaxElementSize) {
aMaxElementSize->width = 0;
aMaxElementSize->height = 0;
if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = 0;
aDesiredSize.maxElementSize->height = 0;
}
PRBool reflowMappedOK = PR_TRUE;
@ -844,11 +844,11 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
// Check for an overflow list
MoveOverflowToChildList();
RowGroupReflowState state(aPresContext, aMaxSize);
RowGroupReflowState state(aPresContext, aReflowState.maxSize);
// Reflow the existing frames
if (nsnull != mFirstChild) {
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aMaxElementSize);
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
if (PR_FALSE == reflowMappedOK) {
aStatus = NS_FRAME_NOT_COMPLETE;
}
@ -864,10 +864,10 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
}
} else if (NextChildOffset() < mContent->ChildCount()) {
// Try and pull-up some children from a next-in-flow
if (PullUpChildren(aPresContext, state, aMaxElementSize)) {
if (PullUpChildren(aPresContext, state, aDesiredSize.maxElementSize)) {
// If we still have unmapped children then create some new frames
if (NextChildOffset() < mContent->ChildCount()) {
aStatus = ReflowUnmappedChildren(aPresContext, state, aMaxElementSize);
aStatus = ReflowUnmappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
}
} else {
// We were unable to pull-up all the existing frames from the
@ -890,7 +890,7 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
// Return our desired rect
//NS_ASSERTION(0<state.firstRowHeight, "illegal firstRowHeight after reflow");
//NS_ASSERTION(0<state.y, "illegal height after reflow");
aDesiredSize.width = aMaxSize.width;
aDesiredSize.width = aReflowState.maxSize.width;
aDesiredSize.height = state.y;
#ifdef NS_DEBUG
@ -899,11 +899,11 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
if (gsDebug1==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
if (nsnull!=aDesiredSize.maxElementSize)
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
else
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
@ -914,23 +914,6 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
}
NS_METHOD
nsTableRowGroupFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus)
{
if (gsDebug1==PR_TRUE) printf("nsTableRowGroupFrame::IncrementalReflow\n");
// total hack for now, just some hard-coded values
aDesiredSize.width = aMaxSize.width;
aDesiredSize.height = aMaxSize.height;
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
NS_METHOD
nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,

View File

@ -62,26 +62,19 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** calls ResizeReflow for all of its child rows.
/** calls Reflow for all of its child rows.
* Rows are all set to the same width and stacked vertically.
* <P> rows are not split unless absolutely necessary.
*
* @param aDesiredSize width set to width of rows, height set to
* sum of height of rows that fit in aMaxSize.height.
*
* @see nsIFrame::ResizeReflow
* @see nsIFrame::Reflow
*/
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
nsReflowStatus& aStatus);
/** @see nsIFrame::IncrementalReflow */
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand,
nsReflowStatus& aStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,