Ported to new CreateFrame/CreateContinuingFrame APIs

git-svn-id: svn://10.0.0.236/trunk@1204 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
kipp 1998-05-07 00:08:20 +00:00
parent 99983b9346
commit d75e25fc42
89 changed files with 1092 additions and 624 deletions

View File

@ -81,8 +81,10 @@ public:
* Used by the html content's delegate to create a frame
* for the content.
*/
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame) = 0;
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult) = 0;
};
#endif /* nsIHTMLContent_h___ */

View File

@ -59,9 +59,11 @@ nsContainerFrame::~nsContainerFrame()
}
}
void nsContainerFrame::PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsContainerFrame* aContFrame)
void
nsContainerFrame::PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsContainerFrame* aContFrame)
{
// Append the continuing frame to the flow
aContFrame->AppendToFlow(this);
@ -74,25 +76,24 @@ void nsContainerFrame::PrepareContinuingFrame(nsIPresContext* aPresContext,
aContFrame->mLastContentOffset = nextOffset;
aContFrame->mLastContentIsComplete = PR_TRUE;
// Resolve style for the continuing frame and set its style context.
// XXX presumptive
nsIStyleContext* styleContext =
aPresContext->ResolveStyleContextFor(mContent, aParent);
aContFrame->SetStyleContext(aPresContext, styleContext);
NS_RELEASE(styleContext);
aContFrame->SetStyleContext(aPresContext, aStyleContext);
}
NS_METHOD nsContainerFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsContainerFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsIContentDelegate* contentDelegate = mContent->GetDelegate(aPresContext);
aContinuingFrame = contentDelegate->CreateFrame(aPresContext, mContent, aParent);
nsresult rv = contentDelegate->CreateFrame(aPresContext, mContent, aParent,
aStyleContext, aContinuingFrame);
NS_RELEASE(contentDelegate);
PrepareContinuingFrame(aPresContext, aParent, (nsContainerFrame*)aContinuingFrame);
return NS_OK;
if (NS_OK == rv) {
PrepareContinuingFrame(aPresContext, aParent, aStyleContext,
(nsContainerFrame*)aContinuingFrame);
}
return rv;
}

View File

@ -111,9 +111,10 @@ public:
* set the content offsets, mLastContentOffset, and append the continuing
* frame to the flow.
*/
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
// Painting
NS_IMETHOD Paint(nsIPresContext& aPresContext,
@ -195,12 +196,14 @@ protected:
virtual ~nsContainerFrame();
/**
* Prepare a continuation frame of this frame for reflow. Appends it to the
* flow, sets its content offsets, mLastContentIsComplete, and style context.
* Subclasses should invoke this method after construction of a continuing frame.
* Prepare a continuation frame of this frame for reflow. Appends
* it to the flow, sets its content offsets, mLastContentIsComplete,
* and style context. Subclasses should invoke this method after
* construction of a continuing frame.
*/
void PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsContainerFrame* aContFrame);

View File

@ -177,9 +177,13 @@ NS_METHOD nsFrame::GetContent(nsIContent*& aContent) const
NS_METHOD nsFrame::GetContentIndex(PRInt32& aIndexInParent) const
{
nsIContent* parent = mContent->GetParent();
aIndexInParent = parent->IndexOf(mContent);
NS_RELEASE(parent);
if (nsnull != parent) {
aIndexInParent = parent->IndexOf(mContent);
NS_RELEASE(parent);
}
else {
aIndexInParent = 0;
}
return NS_OK;
}
@ -733,13 +737,14 @@ NS_METHOD nsFrame::IsSplittable(SplittableType& aIsSplittable) const
return NS_OK;
}
NS_METHOD nsFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD nsFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
NS_ERROR("not splittable");
aContinuingFrame = nsnull;
return NS_OK;
return NS_OK;/* XXX return an invalid value? */
}
NS_METHOD nsFrame::GetPrevInFlow(nsIFrame*& aPrevInFlow) const
@ -1259,4 +1264,4 @@ void nsFrame::NewContentIsAfter(nsIPresContext& aPresContext,
#endif
}
#endif
#endif

View File

@ -128,9 +128,10 @@ public:
// Flow member functions
NS_IMETHOD IsSplittable(SplittableType& aIsSplittable) const;
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
NS_IMETHOD GetPrevInFlow(nsIFrame*& aPrevInFlow) const;
NS_IMETHOD SetPrevInFlow(nsIFrame*);

View File

@ -340,14 +340,13 @@ void PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
if (nsnull != root) {
nsIContentDelegate* cd = root->GetDelegate(mPresContext);
if (nsnull != cd) {
mRootFrame = cd->CreateFrame(mPresContext, root, nsnull);
nsIStyleContext* rootSC =
mPresContext->ResolveStyleContextFor(root, nsnull);
nsresult rv = cd->CreateFrame(mPresContext, root, nsnull,
rootSC, mRootFrame);
NS_RELEASE(rootSC);
NS_RELEASE(cd);
// set root frame's style context
nsIStyleContext* rootContext = mPresContext->ResolveStyleContextFor(root, nsnull);
mRootFrame->SetStyleContext(mPresContext,rootContext);
NS_RELEASE(rootContext);
// Bind root frame to root view (and root window)
nsIView* rootView = mViewManager->GetRootView();
mRootFrame->SetView(rootView);

View File

@ -48,14 +48,20 @@ NS_METHOD nsSplittableFrame::IsSplittable(SplittableType& aIsSplittable) const
* the receiver's geometric parent
* @return the continuing frame or null if unsuccessful
*/
NS_METHOD nsSplittableFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsSplittableFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsIContentDelegate* contentDelegate = mContent->GetDelegate(aPresContext);
aContinuingFrame = contentDelegate->CreateFrame(aPresContext, mContent, aParent);
nsresult rv = contentDelegate->CreateFrame(aPresContext, mContent, aParent,
aStyleContext, aContinuingFrame);
NS_RELEASE(contentDelegate);
if (NS_OK != rv) {
return rv;
}
// Append the continuing frame to the flow
aContinuingFrame->AppendToFlow(this);
@ -66,7 +72,7 @@ NS_METHOD nsSplittableFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
aContinuingFrame->SetStyleContext(aPresContext,styleContext);
NS_RELEASE(styleContext);
return NS_OK;
return rv;
}
NS_METHOD nsSplittableFrame::GetPrevInFlow(nsIFrame*& aPrevInFlow) const

View File

@ -27,9 +27,10 @@ public:
// CreateContinuingFrame() does the default behavior of using the
// content delegate to create a new frame
NS_IMETHOD IsSplittable(SplittableType& aIsSplittable) const;
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
// Flow member functions.
NS_IMETHOD GetPrevInFlow(nsIFrame*& aPrevInFlow) const;

View File

@ -172,9 +172,10 @@ public:
NS_IMETHOD GetReflowMetrics(nsIPresContext* aPresContext,
nsReflowMetrics& aMetrics);
NS_IMETHOD IsSplittable(SplittableType& aIsSplittable) const;
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
NS_IMETHOD ListTag(FILE* out) const;
NS_IMETHOD VerifyTree() const;

View File

@ -243,35 +243,45 @@ static void AdjustIndexInParents(nsIFrame* aContainerFrame,
}
}
nsIFrame* nsHTMLContainerFrame::CreateFrameFor(nsIPresContext* aPresContext,
nsIContent* aContent)
nsresult
nsHTMLContainerFrame::CreateFrameFor(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
// Get the style content for the frame
nsIStyleContextPtr styleContext = aPresContext->ResolveStyleContextFor(aContent, this);
nsStylePosition* position = (nsStylePosition*)styleContext->GetData(kStylePositionSID);
nsStyleDisplay* display = (nsStyleDisplay*)styleContext->GetData(kStyleDisplaySID);
nsIFrame* result;
// Get the style data for the frame
nsStylePosition* position = (nsStylePosition*)
aStyleContext->GetData(kStylePositionSID);
nsStyleDisplay* display = (nsStyleDisplay*)
aStyleContext->GetData(kStyleDisplaySID);
nsIFrame* frame = nsnull;
// See whether it wants any special handling
nsresult rv;
if (NS_STYLE_POSITION_ABSOLUTE == position->mPosition) {
AbsoluteFrame::NewFrame(&result, aContent, this);
rv = AbsoluteFrame::NewFrame(&frame, aContent, this);
if (NS_OK == rv) {
frame->SetStyleContext(aPresContext, aStyleContext);
}
} else if (display->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&result, aContent, this);
rv = PlaceholderFrame::NewFrame(&frame, aContent, this);
if (NS_OK == rv) {
frame->SetStyleContext(aPresContext, aStyleContext);
}
} else if (NS_STYLE_DISPLAY_NONE == display->mDisplay) {
nsFrame::NewFrame(&result, aContent, this);
rv = nsFrame::NewFrame(&frame, aContent, this);
if (NS_OK == rv) {
frame->SetStyleContext(aPresContext, aStyleContext);
}
} else {
nsIContentDelegate* delegate;
// Ask the content delegate to create the frame
// XXX The delegate will also resolve the style context...
delegate = aContent->GetDelegate(aPresContext);
result = delegate->CreateFrame(aPresContext, aContent, this);
nsIContentDelegate* delegate = aContent->GetDelegate(aPresContext);
rv = delegate->CreateFrame(aPresContext, aContent, this,
aStyleContext, frame);
NS_RELEASE(delegate);
}
// Set the frame's style context
result->SetStyleContext(aPresContext, styleContext);
return result;
aResult = frame;
return rv;
}
NS_METHOD nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell,
@ -324,13 +334,18 @@ NS_METHOD nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell,
// next-in-flow(s). It could be a pseudo-frame, but then it better also be
// a nsHTMLContainerFrame...
nsHTMLContainerFrame* parent = this;
if (nsnull != prevSibling) {
prevSibling->GetGeometricParent((nsIFrame*&)parent);
}
// Create the new frame
nsIFrame* newFrame = parent->CreateFrameFor(aPresContext, aChild);
nsIStyleContext* kidSC;
kidSC = aPresContext->ResolveStyleContextFor(aChild, parent);
nsIFrame* newFrame;
nsresult rv = parent->CreateFrameFor(aPresContext, aChild, kidSC, newFrame);
if (NS_OK != rv) {
return rv;
}
// Insert the frame
if (nsnull == prevSibling) {

View File

@ -61,8 +61,10 @@ protected:
const nsString& aURLSpec,
const nsString& aTargetSpec);
nsIFrame* CreateFrameFor(nsIPresContext* aPresContext,
nsIContent* aContent);
nsresult CreateFrameFor(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
};
#endif /* nsHTMLContainerFrame_h___ */

View File

@ -256,7 +256,11 @@ PRBool nsInlineFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
// frame. This hooks the child into the flow
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to the sibling list
@ -440,7 +444,11 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
// prepares it for reflow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to our sibling list and then push
@ -568,12 +576,17 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
kidStyleContext->GetData(kStylePositionSID);
// Check whether it wants to floated or absolutely positioned
nsresult rv;
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, kid, this);
kidFrame->SetStyleContext(aPresContext,kidStyleContext);
rv = AbsoluteFrame::NewFrame(&kidFrame, kid, this);
if (NS_OK == rv) {
kidFrame->SetStyleContext(aPresContext, kidStyleContext);
}
} else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, this);
kidFrame->SetStyleContext(aPresContext,kidStyleContext);
rv = PlaceholderFrame::NewFrame(&kidFrame, kid, this);
if (NS_OK == rv) {
kidFrame->SetStyleContext(aPresContext, kidStyleContext);
}
} else if (nsnull == kidPrevInFlow) {
nsIContentDelegate* kidDel;
switch (kidDisplay->mDisplay) {
@ -590,18 +603,22 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
case NS_STYLE_DISPLAY_INLINE:
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, this);
rv = kidDel->CreateFrame(aPresContext, kid, this,
kidStyleContext, kidFrame);
NS_RELEASE(kidDel);
break;
default:
NS_ASSERTION(nsnull == kidPrevInFlow, "bad prev in flow");
nsFrame::NewFrame(&kidFrame, kid, this);
rv = nsFrame::NewFrame(&kidFrame, kid, this);
if (NS_OK == rv) {
kidFrame->SetStyleContext(aPresContext, kidStyleContext);
}
break;
}
kidFrame->SetStyleContext(aPresContext,kidStyleContext);
} else {
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame);
rv = kidPrevInFlow->CreateContinuingFrame(aPresContext, this,
kidStyleContext, kidFrame);
}
NS_RELEASE(kid);
NS_RELEASE(kidStyleContext);

View File

@ -537,7 +537,11 @@ nsLineLayout::SplitLine(PRInt32 aChildReflowStatus, PRInt32 aRemainingKids)
// into our lines child list.
nsIFrame* nextFrame;
mPrevKidFrame->GetNextSibling(nextFrame);
mPrevKidFrame->CreateContinuingFrame(mPresContext, mBlock, nextInFlow);
nsIStyleContext* kidSC;
mPrevKidFrame->GetStyleContext(mPresContext, kidSC);
mPrevKidFrame->CreateContinuingFrame(mPresContext, mBlock, kidSC,
nextInFlow);
NS_RELEASE(kidSC);
if (nsnull == nextInFlow) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -828,74 +832,61 @@ done:
nsresult
nsLineLayout::CreateFrameFor(nsIContent* aKid)
{
nsresult rv = NS_OK;
// XXX what if kidSC ends up null?
nsIStyleContextPtr kidSC =
mPresContext->ResolveStyleContextFor(aKid, mBlock);
mPresContext->ResolveStyleContextFor(aKid, mBlock); // XXX bad API
if (nsnull == kidSC) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsStylePosition* kidPosition = (nsStylePosition*)
kidSC->GetData(kStylePositionSID);
nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
kidSC->GetData(kStyleDisplaySID);
// Check whether it wants to floated or absolutely positioned
// XXX don't lose error status from frame ctor's!
PRBool isBlock = PR_FALSE;
nsIFrame* kidFrame;
nsresult rv;
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, aKid, mBlock);
kidFrame->SetStyleContext(mPresContext, kidSC);
rv = AbsoluteFrame::NewFrame(&kidFrame, aKid, mBlock);
if (NS_OK == rv) {
kidFrame->SetStyleContext(mPresContext, kidSC);
}
} else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, aKid, mBlock);
kidFrame->SetStyleContext(mPresContext, kidSC);
rv = PlaceholderFrame::NewFrame(&kidFrame, aKid, mBlock);
if (NS_OK == rv) {
kidFrame->SetStyleContext(mPresContext, kidSC);
}
} else if (nsnull == mKidPrevInFlow) {
// Create initial frame for the child
// XXX refactor to just let delegate create frame (unless style is
// none) and then after that if it's a block frame and the child
// count is non-zero we return the break-before value.
nsIContentDelegate* kidDel;
switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_NONE:
rv = nsFrame::NewFrame(&kidFrame, aKid, mBlock);
if (NS_OK == rv) {
kidFrame->SetStyleContext(mPresContext, kidSC);
}
break;
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
#if 0
// XXX Do we still need this? Now that the body code is changed it
// causes a problem...
if (mBlockIsPseudo) {
// Don't create the frame! It doesn't belong in us.
// XXX the unfortunate thing here is that we waste the style
// lookup!
return NS_LINE_LAYOUT_PSEUDO_BREAK_BEFORE_BLOCK;
}
#endif
kidDel = aKid->GetDelegate(mPresContext);
kidFrame = kidDel->CreateFrame(mPresContext, aKid, mBlock);
NS_RELEASE(kidDel);
isBlock = PR_TRUE;
break;
case NS_STYLE_DISPLAY_INLINE:
// XXX pass in kidSC to speed things up *alot*!
// XXX fix CreateFrame API to return an nsresult!
// FALL THROUGH
default:
kidDel = aKid->GetDelegate(mPresContext);
kidFrame = kidDel->CreateFrame(mPresContext, aKid, mBlock);
rv = kidDel->CreateFrame(mPresContext, aKid, mBlock, kidSC, kidFrame);
NS_RELEASE(kidDel);
break;
default:/* XXX bzzt! */
nsFrame::NewFrame(&kidFrame, aKid, mBlock);
break;
}
kidFrame->SetStyleContext(mPresContext, kidSC);
} else {
// Since kid has a prev-in-flow, use that to create the next
// frame.
mKidPrevInFlow->CreateContinuingFrame(mPresContext, mBlock, kidFrame);
rv = mKidPrevInFlow->CreateContinuingFrame(mPresContext, mBlock, kidSC,
kidFrame);
NS_ASSERTION(0 == mLine->mChildCount, "bad continuation");
}
if (NS_OK != rv) {
return rv;
}
mKidFrame = kidFrame;
mNewFrames++;

View File

@ -38,16 +38,14 @@ void PageFrame::CreateFirstChild(nsIPresContext* aPresContext)
// Create a frame
nsIContentDelegate* cd = child->GetDelegate(aPresContext);
if (nsnull != cd) {
mFirstChild = cd->CreateFrame(aPresContext, child, this);
if (nsnull != mFirstChild) {
nsIStyleContext* kidStyleContext =
aPresContext->ResolveStyleContextFor(child, this);
nsresult rv = cd->CreateFrame(aPresContext, child, this,
kidStyleContext, mFirstChild);
NS_RELEASE(kidStyleContext);
if (NS_OK == mFirstChild) {
mChildCount = 1;
mLastContentOffset = mFirstContentOffset;
// Resolve style and set the style context
nsIStyleContext* kidStyleContext =
aPresContext->ResolveStyleContextFor(child, this);
mFirstChild->SetStyleContext(aPresContext,kidStyleContext);
NS_RELEASE(kidStyleContext);
}
NS_RELEASE(cd);
}
@ -80,7 +78,12 @@ NS_METHOD PageFrame::ResizeReflow(nsIPresContext* aPresContext,
prevPage->LastChild(prevLastChild);
// Create a continuing child of the previous page's last child
prevLastChild->CreateContinuingFrame(aPresContext, this, mFirstChild);
nsIStyleContext* kidSC;
prevLastChild->GetStyleContext(aPresContext, kidSC);
nsresult rv = prevLastChild->CreateContinuingFrame(aPresContext, this,
kidSC, mFirstChild);
NS_RELEASE(kidSC);
mChildCount = 1;
mLastContentOffset = mFirstContentOffset;
}
@ -154,12 +157,17 @@ NS_METHOD PageFrame::IncrementalReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD PageFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
PageFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
PageFrame* cf = new PageFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
aContinuingFrame = cf;
return NS_OK;
}

View File

@ -37,9 +37,10 @@ public:
nsReflowCommand& aReflowCommand,
ReflowStatus& aStatus);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aCX,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,

View File

@ -69,12 +69,13 @@ NS_METHOD PlaceholderFrame::ResizeReflow(nsIPresContext* aPresContext,
if (nsnull == mAnchoredItem) {
// Create the anchored item
nsIContentDelegate* delegate = mContent->GetDelegate(aPresContext);
mAnchoredItem = delegate->CreateFrame(aPresContext, mContent, mGeometricParent);
nsresult rv = delegate->CreateFrame(aPresContext, mContent,
mGeometricParent, mStyleContext,
mAnchoredItem);
NS_RELEASE(delegate);
// Set the style context for the frame
mAnchoredItem->SetStyleContext(aPresContext,mStyleContext);
if (NS_OK != rv) {
return rv;
}
// Resize reflow the anchored item into the available space
// XXX Check for complete?

View File

@ -245,11 +245,12 @@ NS_METHOD AbsoluteFrame::ResizeReflow(nsIPresContext* aPresContext,
// also create a view
nsIContentDelegate* delegate = mContent->GetDelegate(aPresContext);
mFrame= delegate->CreateFrame(aPresContext, mContent, this);
nsresult rv = delegate->CreateFrame(aPresContext, mContent, this,
mStyleContext, mFrame);
NS_RELEASE(delegate);
// Set the style context for the frame
mFrame->SetStyleContext(aPresContext,mStyleContext);
if (NS_OK != rv) {
return rv;
}
}
// Get the containing block, and its associated view

View File

@ -134,8 +134,11 @@ public:
virtual void UnsetAttribute(nsIAtom* aAttribute);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
PRInt32 GetClear() {
return mClear;
@ -163,11 +166,19 @@ BRPart::~BRPart()
{
}
nsIFrame* BRPart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
BRPart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv = new BRFrame(this, aParentFrame);
return rv;
nsIFrame* frame = new BRFrame(this, aParentFrame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
//----------------------------------------------------------------------

View File

@ -172,9 +172,10 @@ public:
NS_IMETHOD GetReflowMetrics(nsIPresContext* aPresContext,
nsReflowMetrics& aMetrics);
NS_IMETHOD IsSplittable(SplittableType& aIsSplittable) const;
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
NS_IMETHOD ListTag(FILE* out) const;
NS_IMETHOD VerifyTree() const;

View File

@ -96,7 +96,7 @@ void nsBodyFrame::CreateColumnFrame(nsIPresContext* aPresContext)
NS_ASSERTION(prevBody->ChildIsPseudoFrame(prevColumn), "bad previous column");
// Create a continuing column
prevColumn->CreateContinuingFrame(aPresContext, this, mFirstChild);
prevColumn->CreateContinuingFrame(aPresContext, this, nsnull, mFirstChild);
mChildCount = 1;
}
}
@ -364,12 +364,17 @@ void nsBodyFrame::RemoveAnchoredItem(nsIFrame* aAnchoredItem)
mChildCount--;
}
NS_METHOD nsBodyFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsBodyFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsBodyFrame* cf = new nsBodyFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
aContinuingFrame = cf;
return NS_OK;
}

View File

@ -55,9 +55,10 @@ public:
nsIContent* aChild,
PRInt32 aIndexInParent);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
virtual void AddAnchoredItem(nsIFrame* aAnchoredItem,
AnchoringPosition aPosition,

View File

@ -27,8 +27,11 @@ public:
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
protected:
virtual ~BodyPart();
@ -57,12 +60,20 @@ nsrefcnt BodyPart::Release(void)
return mRefCnt;
}
nsIFrame* BodyPart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
BodyPart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv;
nsresult status = nsBodyFrame::NewFrame(&rv, this, aParentFrame);
return rv;
nsIFrame* frame = nsnull;
nsresult rv = nsBodyFrame::NewFrame(&frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
nsresult

View File

@ -47,8 +47,11 @@ public:
virtual nsrefcnt AddRef(void);
virtual nsrefcnt Release(void);
#endif
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);
virtual nsContentAttr GetAttribute(nsIAtom* aAttribute,
@ -417,11 +420,19 @@ nsContentAttr HRulePart::AttributeToString(nsIAtom* aAttribute,
//----------------------------------------------------------------------
nsIFrame* HRulePart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
HRulePart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv = new HRuleFrame(this, aParentFrame);
return rv;
nsIFrame* frame = new HRuleFrame(this, aParentFrame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
nsresult

View File

@ -182,39 +182,38 @@ void nsHTMLContainer::Compact()
//XXX I'll turn this on in a bit... mChildren.Compact();
}
nsIFrame* nsHTMLContainer::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
nsHTMLContainer::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
// Resolve style for the piece of content
// XXX The caller has also resolved the style context, which means we're
// resolving it more than once. That's inefficient, and we need to fix it...
nsIStyleContext* styleContext =
aPresContext->ResolveStyleContextFor(this, aParentFrame);
nsStyleDisplay* styleDisplay =
(nsStyleDisplay*)styleContext->GetData(kStyleDisplaySID);
(nsStyleDisplay*) aStyleContext->GetData(kStyleDisplaySID);
// Use style to choose what kind of frame to create
nsIFrame* rv;
nsresult fr;
nsIFrame* frame = nsnull;
nsresult rv;
switch (styleDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
fr = nsBlockFrame::NewFrame(&rv, this, aParentFrame);
rv = nsBlockFrame::NewFrame(&frame, this, aParentFrame);
break;
case NS_STYLE_DISPLAY_INLINE:
fr = nsInlineFrame::NewFrame(&rv, this, aParentFrame);
rv = nsInlineFrame::NewFrame(&frame, this, aParentFrame);
break;
case NS_STYLE_DISPLAY_LIST_ITEM:
fr = nsListItemFrame::NewFrame(&rv, this, aParentFrame);
rv = nsListItemFrame::NewFrame(&frame, this, aParentFrame);
break;
default:
// Create an empty frame for holding content that is not being
// reflowed.
fr = nsFrame::NewFrame(&rv, this, aParentFrame);
rv = nsFrame::NewFrame(&frame, this, aParentFrame);
break;
}
rv->SetStyleContext(aPresContext,styleContext);
NS_RELEASE(styleContext);
if (NS_OK == rv) {
frame->SetStyleContext(aPresContext, aStyleContext);
}
aResult = frame;
return rv;
}

View File

@ -38,8 +38,10 @@ public:
virtual void Compact();
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);
virtual void MapAttributesInto(nsIStyleContext* aContext,

View File

@ -243,35 +243,45 @@ static void AdjustIndexInParents(nsIFrame* aContainerFrame,
}
}
nsIFrame* nsHTMLContainerFrame::CreateFrameFor(nsIPresContext* aPresContext,
nsIContent* aContent)
nsresult
nsHTMLContainerFrame::CreateFrameFor(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
// Get the style content for the frame
nsIStyleContextPtr styleContext = aPresContext->ResolveStyleContextFor(aContent, this);
nsStylePosition* position = (nsStylePosition*)styleContext->GetData(kStylePositionSID);
nsStyleDisplay* display = (nsStyleDisplay*)styleContext->GetData(kStyleDisplaySID);
nsIFrame* result;
// Get the style data for the frame
nsStylePosition* position = (nsStylePosition*)
aStyleContext->GetData(kStylePositionSID);
nsStyleDisplay* display = (nsStyleDisplay*)
aStyleContext->GetData(kStyleDisplaySID);
nsIFrame* frame = nsnull;
// See whether it wants any special handling
nsresult rv;
if (NS_STYLE_POSITION_ABSOLUTE == position->mPosition) {
AbsoluteFrame::NewFrame(&result, aContent, this);
rv = AbsoluteFrame::NewFrame(&frame, aContent, this);
if (NS_OK == rv) {
frame->SetStyleContext(aPresContext, aStyleContext);
}
} else if (display->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&result, aContent, this);
rv = PlaceholderFrame::NewFrame(&frame, aContent, this);
if (NS_OK == rv) {
frame->SetStyleContext(aPresContext, aStyleContext);
}
} else if (NS_STYLE_DISPLAY_NONE == display->mDisplay) {
nsFrame::NewFrame(&result, aContent, this);
rv = nsFrame::NewFrame(&frame, aContent, this);
if (NS_OK == rv) {
frame->SetStyleContext(aPresContext, aStyleContext);
}
} else {
nsIContentDelegate* delegate;
// Ask the content delegate to create the frame
// XXX The delegate will also resolve the style context...
delegate = aContent->GetDelegate(aPresContext);
result = delegate->CreateFrame(aPresContext, aContent, this);
nsIContentDelegate* delegate = aContent->GetDelegate(aPresContext);
rv = delegate->CreateFrame(aPresContext, aContent, this,
aStyleContext, frame);
NS_RELEASE(delegate);
}
// Set the frame's style context
result->SetStyleContext(aPresContext, styleContext);
return result;
aResult = frame;
return rv;
}
NS_METHOD nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell,
@ -324,13 +334,18 @@ NS_METHOD nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell,
// next-in-flow(s). It could be a pseudo-frame, but then it better also be
// a nsHTMLContainerFrame...
nsHTMLContainerFrame* parent = this;
if (nsnull != prevSibling) {
prevSibling->GetGeometricParent((nsIFrame*&)parent);
}
// Create the new frame
nsIFrame* newFrame = parent->CreateFrameFor(aPresContext, aChild);
nsIStyleContext* kidSC;
kidSC = aPresContext->ResolveStyleContextFor(aChild, parent);
nsIFrame* newFrame;
nsresult rv = parent->CreateFrameFor(aPresContext, aChild, kidSC, newFrame);
if (NS_OK != rv) {
return rv;
}
// Insert the frame
if (nsnull == prevSibling) {

View File

@ -61,8 +61,10 @@ protected:
const nsString& aURLSpec,
const nsString& aTargetSpec);
nsIFrame* CreateFrameFor(nsIPresContext* aPresContext,
nsIContent* aContent);
nsresult CreateFrameFor(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
};
#endif /* nsHTMLContainerFrame_h___ */

View File

@ -44,9 +44,11 @@ class ContentDelegate : public nsIContentDelegate {
public:
ContentDelegate();
NS_DECL_ISUPPORTS
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame);
NS_IMETHOD CreateFrame(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
protected:
~ContentDelegate();
};
@ -62,27 +64,34 @@ ContentDelegate::~ContentDelegate()
{
}
nsIFrame* ContentDelegate::CreateFrame(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame)
NS_METHOD
ContentDelegate::CreateFrame(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
NS_PRECONDITION(nsnull != aContent, "null ptr");
// Make sure the content is html content
nsIHTMLContent* hc;
nsIFrame* rv;
nsresult status = aContent->QueryInterface(kIHTMLContentIID, (void**) &hc);
if (NS_OK != status) {
nsIFrame* frame = nsnull;
nsresult rv = aContent->QueryInterface(kIHTMLContentIID, (void**) &hc);
if (NS_OK != rv) {
// This means that *somehow* somebody which is not an html
// content object got ahold of this delegate and tried to
// create a frame with it. Give them back an nsFrame.
status = nsFrame::NewFrame(&rv, aContent, aParentFrame);
return rv;
rv = nsFrame::NewFrame(&frame, aContent, aParentFrame);
if (NS_OK == rv) {
frame->SetStyleContext(aPresContext, aStyleContext);
}
}
// Ask the content object to create the frame
rv = hc->CreateFrame(aPresContext, aParentFrame);
NS_RELEASE(hc);
else {
// Ask the content object to create the frame
rv = hc->CreateFrame(aPresContext, aParentFrame, aStyleContext, frame);
NS_RELEASE(hc);
}
aResult = frame;
return rv;
}

View File

@ -76,8 +76,10 @@ class ImagePart : public nsHTMLTagContent {
public:
ImagePart(nsIAtom* aTag);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);
virtual nsContentAttr GetAttribute(nsIAtom* aAttribute,
@ -565,11 +567,19 @@ void ImagePart::MapAttributesInto(nsIStyleContext* aContext,
}
}
nsIFrame* ImagePart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
ImagePart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
ImageFrame* rv = new ImageFrame(this, aParentFrame);
return rv;
ImageFrame* frame = new ImageFrame(this, aParentFrame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
aResult = frame;
frame->SetStyleContext(aPresContext, aStyleContext);
return NS_OK;
}
nsresult

View File

@ -81,8 +81,10 @@ public:
* Used by the html content's delegate to create a frame
* for the content.
*/
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame) = 0;
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult) = 0;
};
#endif /* nsIHTMLContent_h___ */

View File

@ -256,7 +256,11 @@ PRBool nsInlineFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
// frame. This hooks the child into the flow
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to the sibling list
@ -440,7 +444,11 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
// prepares it for reflow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to our sibling list and then push
@ -568,12 +576,17 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
kidStyleContext->GetData(kStylePositionSID);
// Check whether it wants to floated or absolutely positioned
nsresult rv;
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, kid, this);
kidFrame->SetStyleContext(aPresContext,kidStyleContext);
rv = AbsoluteFrame::NewFrame(&kidFrame, kid, this);
if (NS_OK == rv) {
kidFrame->SetStyleContext(aPresContext, kidStyleContext);
}
} else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, this);
kidFrame->SetStyleContext(aPresContext,kidStyleContext);
rv = PlaceholderFrame::NewFrame(&kidFrame, kid, this);
if (NS_OK == rv) {
kidFrame->SetStyleContext(aPresContext, kidStyleContext);
}
} else if (nsnull == kidPrevInFlow) {
nsIContentDelegate* kidDel;
switch (kidDisplay->mDisplay) {
@ -590,18 +603,22 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
case NS_STYLE_DISPLAY_INLINE:
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, this);
rv = kidDel->CreateFrame(aPresContext, kid, this,
kidStyleContext, kidFrame);
NS_RELEASE(kidDel);
break;
default:
NS_ASSERTION(nsnull == kidPrevInFlow, "bad prev in flow");
nsFrame::NewFrame(&kidFrame, kid, this);
rv = nsFrame::NewFrame(&kidFrame, kid, this);
if (NS_OK == rv) {
kidFrame->SetStyleContext(aPresContext, kidStyleContext);
}
break;
}
kidFrame->SetStyleContext(aPresContext,kidStyleContext);
} else {
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame);
rv = kidPrevInFlow->CreateContinuingFrame(aPresContext, this,
kidStyleContext, kidFrame);
}
NS_RELEASE(kid);
NS_RELEASE(kidStyleContext);

View File

@ -537,7 +537,11 @@ nsLineLayout::SplitLine(PRInt32 aChildReflowStatus, PRInt32 aRemainingKids)
// into our lines child list.
nsIFrame* nextFrame;
mPrevKidFrame->GetNextSibling(nextFrame);
mPrevKidFrame->CreateContinuingFrame(mPresContext, mBlock, nextInFlow);
nsIStyleContext* kidSC;
mPrevKidFrame->GetStyleContext(mPresContext, kidSC);
mPrevKidFrame->CreateContinuingFrame(mPresContext, mBlock, kidSC,
nextInFlow);
NS_RELEASE(kidSC);
if (nsnull == nextInFlow) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -828,74 +832,61 @@ done:
nsresult
nsLineLayout::CreateFrameFor(nsIContent* aKid)
{
nsresult rv = NS_OK;
// XXX what if kidSC ends up null?
nsIStyleContextPtr kidSC =
mPresContext->ResolveStyleContextFor(aKid, mBlock);
mPresContext->ResolveStyleContextFor(aKid, mBlock); // XXX bad API
if (nsnull == kidSC) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsStylePosition* kidPosition = (nsStylePosition*)
kidSC->GetData(kStylePositionSID);
nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
kidSC->GetData(kStyleDisplaySID);
// Check whether it wants to floated or absolutely positioned
// XXX don't lose error status from frame ctor's!
PRBool isBlock = PR_FALSE;
nsIFrame* kidFrame;
nsresult rv;
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, aKid, mBlock);
kidFrame->SetStyleContext(mPresContext, kidSC);
rv = AbsoluteFrame::NewFrame(&kidFrame, aKid, mBlock);
if (NS_OK == rv) {
kidFrame->SetStyleContext(mPresContext, kidSC);
}
} else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, aKid, mBlock);
kidFrame->SetStyleContext(mPresContext, kidSC);
rv = PlaceholderFrame::NewFrame(&kidFrame, aKid, mBlock);
if (NS_OK == rv) {
kidFrame->SetStyleContext(mPresContext, kidSC);
}
} else if (nsnull == mKidPrevInFlow) {
// Create initial frame for the child
// XXX refactor to just let delegate create frame (unless style is
// none) and then after that if it's a block frame and the child
// count is non-zero we return the break-before value.
nsIContentDelegate* kidDel;
switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_NONE:
rv = nsFrame::NewFrame(&kidFrame, aKid, mBlock);
if (NS_OK == rv) {
kidFrame->SetStyleContext(mPresContext, kidSC);
}
break;
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
#if 0
// XXX Do we still need this? Now that the body code is changed it
// causes a problem...
if (mBlockIsPseudo) {
// Don't create the frame! It doesn't belong in us.
// XXX the unfortunate thing here is that we waste the style
// lookup!
return NS_LINE_LAYOUT_PSEUDO_BREAK_BEFORE_BLOCK;
}
#endif
kidDel = aKid->GetDelegate(mPresContext);
kidFrame = kidDel->CreateFrame(mPresContext, aKid, mBlock);
NS_RELEASE(kidDel);
isBlock = PR_TRUE;
break;
case NS_STYLE_DISPLAY_INLINE:
// XXX pass in kidSC to speed things up *alot*!
// XXX fix CreateFrame API to return an nsresult!
// FALL THROUGH
default:
kidDel = aKid->GetDelegate(mPresContext);
kidFrame = kidDel->CreateFrame(mPresContext, aKid, mBlock);
rv = kidDel->CreateFrame(mPresContext, aKid, mBlock, kidSC, kidFrame);
NS_RELEASE(kidDel);
break;
default:/* XXX bzzt! */
nsFrame::NewFrame(&kidFrame, aKid, mBlock);
break;
}
kidFrame->SetStyleContext(mPresContext, kidSC);
} else {
// Since kid has a prev-in-flow, use that to create the next
// frame.
mKidPrevInFlow->CreateContinuingFrame(mPresContext, mBlock, kidFrame);
rv = mKidPrevInFlow->CreateContinuingFrame(mPresContext, mBlock, kidSC,
kidFrame);
NS_ASSERTION(0 == mLine->mChildCount, "bad continuation");
}
if (NS_OK != rv) {
return rv;
}
mKidFrame = kidFrame;
mNewFrames++;

View File

@ -647,12 +647,17 @@ NS_METHOD nsListItemFrame::IncrementalReflow(nsIPresContext* aCX,
}
#endif
NS_METHOD nsListItemFrame::CreateContinuingFrame(nsIPresContext* aCX,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsListItemFrame::CreateContinuingFrame(nsIPresContext* aCX,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsListItemFrame* cf = new nsListItemFrame(mContent, aParent);
PrepareContinuingFrame(aCX, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aCX, aParent, aStyleContext, cf);
aContinuingFrame = cf;
return NS_OK;
}

View File

@ -34,9 +34,10 @@ public:
nsRect& aDesiredRect,
nsSize* aMaxElementSize,
ReflowStatus& aStatus);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aCX,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aCX,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
/**
* Return the reflow state for the list container that contains this

View File

@ -38,16 +38,14 @@ void PageFrame::CreateFirstChild(nsIPresContext* aPresContext)
// Create a frame
nsIContentDelegate* cd = child->GetDelegate(aPresContext);
if (nsnull != cd) {
mFirstChild = cd->CreateFrame(aPresContext, child, this);
if (nsnull != mFirstChild) {
nsIStyleContext* kidStyleContext =
aPresContext->ResolveStyleContextFor(child, this);
nsresult rv = cd->CreateFrame(aPresContext, child, this,
kidStyleContext, mFirstChild);
NS_RELEASE(kidStyleContext);
if (NS_OK == mFirstChild) {
mChildCount = 1;
mLastContentOffset = mFirstContentOffset;
// Resolve style and set the style context
nsIStyleContext* kidStyleContext =
aPresContext->ResolveStyleContextFor(child, this);
mFirstChild->SetStyleContext(aPresContext,kidStyleContext);
NS_RELEASE(kidStyleContext);
}
NS_RELEASE(cd);
}
@ -80,7 +78,12 @@ NS_METHOD PageFrame::ResizeReflow(nsIPresContext* aPresContext,
prevPage->LastChild(prevLastChild);
// Create a continuing child of the previous page's last child
prevLastChild->CreateContinuingFrame(aPresContext, this, mFirstChild);
nsIStyleContext* kidSC;
prevLastChild->GetStyleContext(aPresContext, kidSC);
nsresult rv = prevLastChild->CreateContinuingFrame(aPresContext, this,
kidSC, mFirstChild);
NS_RELEASE(kidSC);
mChildCount = 1;
mLastContentOffset = mFirstContentOffset;
}
@ -154,12 +157,17 @@ NS_METHOD PageFrame::IncrementalReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD PageFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
PageFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
PageFrame* cf = new PageFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
aContinuingFrame = cf;
return NS_OK;
}

View File

@ -37,9 +37,10 @@ public:
nsReflowCommand& aReflowCommand,
ReflowStatus& aStatus);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aCX,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,

View File

@ -69,12 +69,13 @@ NS_METHOD PlaceholderFrame::ResizeReflow(nsIPresContext* aPresContext,
if (nsnull == mAnchoredItem) {
// Create the anchored item
nsIContentDelegate* delegate = mContent->GetDelegate(aPresContext);
mAnchoredItem = delegate->CreateFrame(aPresContext, mContent, mGeometricParent);
nsresult rv = delegate->CreateFrame(aPresContext, mContent,
mGeometricParent, mStyleContext,
mAnchoredItem);
NS_RELEASE(delegate);
// Set the style context for the frame
mAnchoredItem->SetStyleContext(aPresContext,mStyleContext);
if (NS_OK != rv) {
return rv;
}
// Resize reflow the anchored item into the available space
// XXX Check for complete?

View File

@ -267,16 +267,14 @@ void RootContentFrame::CreateFirstChild(nsIPresContext* aPresContext)
// Create a frame
nsIContentDelegate* cd = child->GetDelegate(aPresContext);
if (nsnull != cd) {
mFirstChild = cd->CreateFrame(aPresContext, child, this);
if (nsnull != mFirstChild) {
nsIStyleContext* kidStyleContext =
aPresContext->ResolveStyleContextFor(child, this);
nsresult rv = cd->CreateFrame(aPresContext, child, this,
kidStyleContext, mFirstChild);
NS_RELEASE(kidStyleContext);
if (NS_OK == rv) {
mChildCount = 1;
mLastContentOffset = mFirstContentOffset;
// Resolve style and set the style context
nsIStyleContext* kidStyleContext =
aPresContext->ResolveStyleContextFor(child, this);
mFirstChild->SetStyleContext(aPresContext,kidStyleContext);
NS_RELEASE(kidStyleContext);
}
NS_RELEASE(cd);
}
@ -340,9 +338,12 @@ NS_METHOD RootContentFrame::ResizeReflow(nsIPresContext* aPresContext,
} 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;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingPage);
nsresult rv = kidFrame->CreateContinuingFrame(aPresContext, this,
kidSC, continuingPage);
NS_RELEASE(kidSC);
// Add it to our child list
#ifdef NS_DEBUG
@ -448,8 +449,11 @@ public:
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
protected:
virtual ~RootPart();
@ -480,11 +484,19 @@ nsrefcnt RootPart::Release(void)
return mRefCnt;
}
nsIFrame* RootPart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
RootPart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv = new RootFrame(this);
return rv;
RootFrame* frame = new RootFrame(this);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
nsresult

View File

@ -50,8 +50,10 @@ class SpacerPart : public nsHTMLTagContent {
public:
SpacerPart(nsIAtom* aTag);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);
@ -200,10 +202,19 @@ SpacerPart::~SpacerPart()
{
}
nsIFrame* SpacerPart::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame)
nsresult
SpacerPart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv = new SpacerFrame(this, aParentFrame);
return rv;
nsIFrame* frame = new SpacerFrame(this, aParentFrame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
void SpacerPart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)

View File

@ -219,7 +219,10 @@ public:
virtual void ToHTMLString(nsString& aBuf) const;
virtual nsIFrame* CreateFrame(nsIPresContext* aCX, nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
// nsIScriptObjectOwner interface
virtual nsresult GetScriptObject(JSContext *aContext, void** aScriptObject);
@ -1309,10 +1312,19 @@ void Text::GetText(nsString& aBuf, PRInt32 aOffset, PRInt32 aCount)
}
#endif
nsIFrame* Text::CreateFrame(nsIPresContext* aCX, nsIFrame* aParentFrame)
nsresult
Text::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv = new TextFrame(this, aParentFrame);
return rv;
nsIFrame* frame = new TextFrame(this, aParentFrame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
nsresult Text::GetScriptObject(JSContext *aContext, void** aScriptObject)

View File

@ -24,8 +24,10 @@ class WBRPart : public nsHTMLTagContent {
public:
WBRPart(nsIAtom* aTag);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
protected:
virtual ~WBRPart();
@ -40,14 +42,20 @@ WBRPart::~WBRPart()
{
}
nsIFrame* WBRPart::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame)
nsresult
WBRPart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* frame;
nsIFrame* frame = nsnull;
nsresult rv = nsFrame::NewFrame(&frame, this, aParentFrame);
if (NS_OK == rv) {
return frame;
if (NS_OK != rv) {
return rv;
}
return nsnull;
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
nsresult

View File

@ -162,15 +162,6 @@ nsrefcnt nsInput::Release()
return mRefCnt;
}
nsIFrame*
nsInput::CreateFrame(nsIPresContext *aPresContext,
nsIFrame *aParentFrame)
{
NS_ASSERTION(0, "frames must be created by subclasses of Input");
return nsnull;
}
PRBool
nsInput::IsHidden()
{

View File

@ -46,8 +46,10 @@ public:
/**
* @see nsIContentDelegate CreateFrame
*/
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult) = 0;
virtual void MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext);

View File

@ -63,8 +63,10 @@ public:
nsInputButton (nsIAtom* aTag, nsIFormManager* aManager,
nsButtonType aType);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
virtual void GetDefaultLabel(nsString& aLabel);
@ -206,19 +208,28 @@ nsInputButton::GetDefaultLabel(nsString& aString)
}
}
nsIFrame*
nsresult
nsInputButton::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* frame = nsnull;
if (kButton_Hidden == mType) {
nsIFrame* frame;
nsFrame::NewFrame(&frame, this, aParentFrame);
return frame;
nsresult rv = nsFrame::NewFrame(&frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}
}
else {
return new nsInputButtonFrame(this, aParentFrame);
frame = new nsInputButtonFrame(this, aParentFrame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
PRInt32

View File

@ -195,11 +195,19 @@ nsInputCheckbox::Reset()
}
}
nsIFrame*
nsInputCheckbox::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame)
nsresult
nsInputCheckbox::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv = new nsInputCheckboxFrame(this, aParentFrame);
return rv;
nsIFrame* frame = new nsInputCheckboxFrame(this, aParentFrame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
void nsInputCheckbox::GetType(nsString& aResult) const

View File

@ -28,8 +28,10 @@ public:
typedef nsInput nsInputCheckboxSuper;
nsInputCheckbox (nsIAtom* aTag, nsIFormManager* aManager);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);

View File

@ -68,12 +68,19 @@ nsInputFile::~nsInputFile()
}
}
nsIFrame*
nsresult
nsInputFile::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv = new nsInputFileFrame(this, aParentFrame);
return rv;
nsIFrame* frame = new nsInputFileFrame(this, aParentFrame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
void nsInputFile::GetType(nsString& aResult) const

View File

@ -30,8 +30,10 @@ public:
typedef nsInput nsInputFileSuper;
nsInputFile (nsIAtom* aTag, nsIFormManager* aManager);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
protected:
virtual ~nsInputFile();

View File

@ -185,13 +185,19 @@ nsInputRadio::SetChecked(PRBool aValue, PRBool aSetInitialValue)
((nsIRadioButton *)mWidget)->SetState(aValue);
}
nsIFrame*
nsresult
nsInputRadio::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv = new nsInputRadioFrame(this, aParentFrame);
return rv;
nsIFrame* frame = new nsInputRadioFrame(this, aParentFrame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
void nsInputRadio::GetType(nsString& aResult) const

View File

@ -32,8 +32,10 @@ public:
typedef nsInput nsInputRadioSuper;
nsInputRadio (nsIAtom* aTag, nsIFormManager* aManager);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);

View File

@ -202,11 +202,19 @@ nsInputText::GetTextType() const
return mType;
}
nsIFrame*
nsresult
nsInputText::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
return new nsInputTextFrame(this, aParentFrame);
nsIFrame* frame = new nsInputTextFrame(this, aParentFrame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
PRInt32

View File

@ -38,8 +38,10 @@ public:
typedef nsInput nsInputTextSuper;
nsInputText (nsIAtom* aTag, nsIFormManager* aManager, nsInputTextType aType);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);

View File

@ -74,8 +74,10 @@ public:
typedef nsInput super;
nsSelect (nsIAtom* aTag, nsIFormManager* aFormMan);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);
@ -108,8 +110,10 @@ public:
nsOption (nsIAtom* aTag);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);
@ -299,12 +303,19 @@ void nsSelect::GetType(nsString& aResult) const
aResult = "select";
}
nsIFrame*
nsresult
nsSelect::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv = new nsSelectFrame(this, aParentFrame);
return rv;
nsIFrame* frame = new nsSelectFrame(this, aParentFrame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
void nsSelect::SetAttribute(nsIAtom* aAttribute,
@ -460,13 +471,20 @@ void nsOption::GetType(nsString& aResult) const
aResult = "select";
}
nsIFrame*
nsresult
nsOption::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* frame;
nsFrame::NewFrame(&frame, this, aParentFrame);
return frame;
nsresult rv = nsFrame::NewFrame(&frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return NS_OK;
}
void nsOption::SetAttribute(nsIAtom* aAttribute,

View File

@ -76,13 +76,21 @@ int nsTableCaption::GetType()
return nsITableContent::kTableCaptionType;
}
nsIFrame* nsTableCaption::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
nsTableCaption::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
NS_PRECONDITION(nsnull!=aPresContext, "bad arg");
nsIFrame* rv;
nsresult status = nsTableCaptionFrame::NewFrame(&rv, this, aParentFrame);
NS_ASSERTION(nsnull!=rv, "bad arg");
nsIFrame* frame;
nsresult rv = nsTableCaptionFrame::NewFrame(&frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return rv;
}

View File

@ -59,8 +59,10 @@ public:
virtual int GetType();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
};
#endif

View File

@ -90,7 +90,11 @@ void nsTableCaptionFrame::CreatePsuedoFrame(nsIPresContext* aPresContext)
NS_ASSERTION(prevFrame->ChildIsPseudoFrame(prevPseudoFrame), "bad previous pseudo-frame");
// Create a continuing column
prevPseudoFrame->CreateContinuingFrame(aPresContext, this, mFirstChild);
nsIStyleContext* kidSC;
prevPseudoFrame->GetStyleContext(aPresContext, kidSC);
prevPseudoFrame->CreateContinuingFrame(aPresContext, this, kidSC,
mFirstChild);
NS_RELEASE(kidSC);
mChildCount = 1;
}
}
@ -324,13 +328,18 @@ NS_METHOD nsTableCaptionFrame::IncrementalReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsTableCaptionFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsTableCaptionFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
if (PR_TRUE==gsDebug) printf("nsTableCaptionFrame::CreateContinuingFrame called\n");
nsTableCaptionFrame* cf = new nsTableCaptionFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
aContinuingFrame = cf;
return NS_OK;
}

View File

@ -54,9 +54,10 @@ public:
/**
* @see nsContainerFrame
*/
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
virtual void VerticallyAlignChild(nsIPresContext* aPresContext);

View File

@ -143,13 +143,21 @@ void nsTableCell::SetColIndex (int aColIndex)
mColIndex = aColIndex;
}
nsIFrame* nsTableCell::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
nsTableCell::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
NS_PRECONDITION(nsnull!=aPresContext, "bad arg");
nsIFrame* rv;
nsresult status = nsTableCellFrame::NewFrame(&rv, this, aParentFrame);
NS_ASSERTION(nsnull!=rv, "bad arg");
nsIFrame* frame;
nsresult rv = nsTableCellFrame::NewFrame(&frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return rv;
}

View File

@ -86,8 +86,10 @@ public:
virtual int GetType();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);

View File

@ -194,7 +194,10 @@ void nsTableCellFrame::CreatePsuedoFrame(nsIPresContext* aPresContext)
NS_ASSERTION(prevFrame->ChildIsPseudoFrame(prevPseudoFrame), "bad previous pseudo-frame");
// Create a continuing column
prevPseudoFrame->CreateContinuingFrame(aPresContext, this, mFirstChild);
nsIStyleContext* kidSC;
prevPseudoFrame->GetStyleContext(aPresContext, kidSC);
prevPseudoFrame->CreateContinuingFrame(aPresContext, this, kidSC, mFirstChild);
NS_RELEASE(kidSC);
mChildCount = 1;
}
}
@ -334,12 +337,17 @@ NS_METHOD nsTableCellFrame::IncrementalReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsTableCellFrame* cf = new nsTableCellFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
aContinuingFrame = cf;
return NS_OK;
}

View File

@ -54,9 +54,10 @@ public:
/**
* @see nsContainerFrame
*/
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
void VerticallyAlignChild(nsIPresContext* aPresContext);

View File

@ -319,11 +319,21 @@ nsString * nsTableCol::GetAllInternalAttributeNames ()
return nsnull;
}
nsIFrame* nsTableCol::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
nsTableCol::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv;
nsresult status = nsTableColFrame::NewFrame(&rv, this, aParentFrame);
NS_PRECONDITION(nsnull!=aPresContext, "bad arg");
nsIFrame* frame;
nsresult rv = nsTableColFrame::NewFrame(&frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return rv;
}

View File

@ -76,8 +76,10 @@ public:
virtual int GetType();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
/** return the number of columns this content object represents. always >= 1*/
virtual int GetRepeat ();

View File

@ -331,12 +331,21 @@ PRBool nsTableColGroup::IsCol(nsIContent * aContent) const
return result;
}
nsIFrame* nsTableColGroup::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
nsTableColGroup::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv;
nsresult status = nsTableColGroupFrame::NewFrame(&rv, this, aParentFrame);
NS_ASSERTION(nsnull!=rv, "can't allocate a new frame");
NS_PRECONDITION(nsnull!=aPresContext, "bad arg");
nsIFrame* frame;
nsresult rv = nsTableColGroupFrame::NewFrame(&frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return rv;
}

View File

@ -77,8 +77,10 @@ public:
NS_IMETHOD_(nsrefcnt) Release();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
/** returns nsITableContent::kTableColGroupType */
virtual int GetType();

View File

@ -637,9 +637,9 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresCont
{
nsIContentDelegate* kidDel;
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, this);
nsresult rv = kidDel->CreateFrame(aPresContext, kid,
this, kidStyleContext, kidFrame);
NS_RELEASE(kidDel);
kidFrame->SetStyleContext(aPresContext,kidStyleContext);
}
nsSize maxKidElementSize;
@ -1058,7 +1058,10 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
// frame. This hooks the child into the flow
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to the sibling list
@ -1286,7 +1289,10 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
// prepares it for reflow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to our sibling list and then push
@ -1412,11 +1418,12 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
if (nsnull == kidPrevInFlow) {
nsIContentDelegate* kidDel = nsnull;
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, this);
nsresult rv = kidDel->CreateFrame(aPresContext, kid, this,
kidStyleContext, kidFrame);
NS_RELEASE(kidDel);
kidFrame->SetStyleContext(aPresContext, kidStyleContext);
} else {
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame);
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidStyleContext,
kidFrame);
}
// Try to reflow the child into the available space. It might not
@ -2039,12 +2046,17 @@ PRBool nsTableFrame::IsFirstPassValid() const
return firstInFlow->mFirstPassValid;
}
NS_METHOD nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsTableFrame* cf = new nsTableFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
if (PR_TRUE==gsDebug) printf("nsTableFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf);
// set my width, because all frames in a table flow are the same width
// code in nsTableOuterFrame depends on this being set
@ -2074,9 +2086,10 @@ NS_METHOD nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
aPresContext->ResolveStyleContextFor(content, cf); // kidStyleContext: REFCNT++
nsIContentDelegate* kidDel = nsnull;
kidDel = content->GetDelegate(aPresContext); // kidDel: REFCNT++
nsIFrame * duplicateFrame = kidDel->CreateFrame(aPresContext, content, cf);
nsIFrame* duplicateFrame;
nsresult rv = kidDel->CreateFrame(aPresContext, content, cf,
kidStyleContext, duplicateFrame);
NS_RELEASE(kidDel); // kidDel: REFCNT--
duplicateFrame->SetStyleContext(aPresContext,kidStyleContext);
NS_RELEASE(kidStyleContext); // kidStyleContenxt: REFCNT--
if (nsnull==lastSib)

View File

@ -95,9 +95,10 @@ public:
ReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
/** resize myself and my children according to the arcane rules of cell height magic.
* By default, the height of a cell is the max (height of cells in its row)

View File

@ -529,8 +529,11 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
// The child doesn't have a next-in-flow so create a continuing
// frame. This hooks the child into the flow
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to the sibling list
@ -764,8 +767,10 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext,
// continuing frame. The creation appends it to the flow and
// prepares it for reflow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to our sibling list and then push
@ -1202,12 +1207,17 @@ nsTableOuterFrame::IncrementalReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsTableOuterFrame* cf = new nsTableOuterFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
cf->SetFirstPassValid(PR_TRUE);
if (PR_TRUE==gsDebug)
printf("nsTableOuterFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf);
@ -1215,9 +1225,11 @@ NS_METHOD nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
return NS_OK;
}
void nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsTableOuterFrame* aContFrame)
void
nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsTableOuterFrame* aContFrame)
{
// Append the continuing frame to the flow
aContFrame->AppendToFlow(this);
@ -1238,12 +1250,7 @@ void nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext,
aContFrame->SetFirstContentOffset(nextOffset);
aContFrame->SetLastContentOffset(nextOffset);
aContFrame->SetLastContentIsComplete(PR_TRUE);
// Resolve style for the continuing frame and set its style context.
// XXX presumptive
nsIStyleContextPtr styleContext =
aPresContext->ResolveStyleContextFor(mContent, aParent);
aContFrame->SetStyleContext(aPresContext,styleContext);
aContFrame->SetStyleContext(aPresContext, aStyleContext);
}
NS_METHOD nsTableOuterFrame::VerifyTree() const
@ -1373,8 +1380,10 @@ void nsTableOuterFrame::CreateInnerTableFrame(nsIPresContext* aPresContext)
if (nsnull==mInnerTableFrame)
{
nsIFrame* continuingFrame;
prevInnerTable->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
prevInnerTable->GetStyleContext(aPresContext, kidSC);
prevInnerTable->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
mInnerTableFrame = (nsTableFrame*)continuingFrame;
mChildCount++;
}

View File

@ -97,9 +97,10 @@ public:
ReflowStatus& aStatus);
/** @see nsContainerFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
/** destructor */
virtual ~nsTableOuterFrame();
@ -206,9 +207,10 @@ protected:
/** overridden here to handle special caption-table relationship
* @see nsContainerFrame::PrepareContinuingFrame
*/
virtual void PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsTableOuterFrame* aContFrame);
void PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsTableOuterFrame* aContFrame);
/**
* Remove and delete aChild's next-in-flow(s). Updates the sibling and flow

View File

@ -998,10 +998,21 @@ PRInt32 nsTablePart::GetEffectiveRowSpan (PRInt32 aRowIndex, nsTableCell *aCell)
/**
* Create a frame object that will layout this table.
*/
nsIFrame* nsTablePart::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame)
nsresult
nsTablePart::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv;
nsresult status = nsTableOuterFrame::NewFrame(&rv, this, aParentFrame);
NS_PRECONDITION(nsnull!=aPresContext, "bad arg");
nsIFrame* frame;
nsresult rv = nsTableOuterFrame::NewFrame(&frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return rv;
}

View File

@ -144,8 +144,10 @@ public:
virtual PRBool AppendChild(nsIContent* aKid);
virtual PRBool RemoveChildAt(PRInt32 aIndex);
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
/** called when the input stream knows that the input has been completely consumed.
* this is a hook for future optimizations.

View File

@ -239,12 +239,21 @@ PRBool nsTableRow::RemoveChildAt (int aIndex)
return result;
}
// nsTableRowFrame checks args
nsIFrame* nsTableRow::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
nsTableRow::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv;
nsresult status = nsTableRowFrame::NewFrame(&rv, this, aParentFrame);
NS_PRECONDITION(nsnull!=aPresContext, "bad arg");
nsIFrame* frame;
nsresult rv = nsTableRowFrame::NewFrame(&frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return rv;
}

View File

@ -70,8 +70,10 @@ public:
virtual int GetType();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
/** return the row group that contains me (my parent) */
virtual nsTableRowGroup *GetRowGroup ();

View File

@ -391,8 +391,11 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
// No the child isn't complete, and it doesn't have a next in flow so
// create a continuing frame. This hooks the child into the flow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
// Insert the frame. We'll reflow it next pass through the loop
nsIFrame* nextSib;
@ -654,8 +657,11 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
// continuing frame. The creation appends it to the flow and
// prepares it for reflow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to our sibling list and then push
@ -808,11 +814,12 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
if (nsnull == kidPrevInFlow) {
nsIContentDelegate* kidDel = nsnull;
kidDel = cell->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, cell, this);
nsresult rv = kidDel->CreateFrame(aPresContext, cell,
this, kidStyleContext, kidFrame);
NS_RELEASE(kidDel);
kidFrame->SetStyleContext(aPresContext,kidStyleContext);
} else {
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame);
kidPrevInFlow->CreateContinuingFrame(aPresContext, this,
kidStyleContext, kidFrame);
}
NS_RELEASE(kidStyleContext);
@ -1030,13 +1037,18 @@ nsTableRowFrame::IncrementalReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
if (gsDebug1==PR_TRUE) printf("nsTableRowFrame::CreateContinuingFrame\n");
nsTableRowFrame* cf = new nsTableRowFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
aContinuingFrame = cf;
return NS_OK;
}

View File

@ -91,9 +91,10 @@ public:
ReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
/** set mTallestCell to 0 in anticipation of recalculating it */
void ResetMaxChildHeight();

View File

@ -94,12 +94,21 @@ nsrefcnt nsTableRowGroup::Release(void)
return mRefCnt;
}
// nsTableRowGroupFrame checks arguments
nsIFrame* nsTableRowGroup::CreateFrame( nsIPresContext* aPresContext,
nsIFrame* aParentFrame)
nsresult
nsTableRowGroup::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
{
nsIFrame* rv;
nsresult status = nsTableRowGroupFrame::NewFrame(&rv, this, aParentFrame);
NS_PRECONDITION(nsnull!=aPresContext, "bad arg");
nsIFrame* frame;
nsresult rv = nsTableRowGroupFrame::NewFrame(&frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return rv;
}

View File

@ -63,8 +63,10 @@ public:
NS_IMETHOD_(nsrefcnt) Release();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame);
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
/** return the number of contained rows */
virtual int GetRowCount ()

View File

@ -359,8 +359,11 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
// No the child isn't complete, and it doesn't have a next in flow so
// create a continuing frame. This hooks the child into the flow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
// Insert the frame. We'll reflow it next pass through the loop
nsIFrame* nextSib;
@ -587,8 +590,11 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
// continuing frame. The creation appends it to the flow and
// prepares it for reflow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to our sibling list and then push
@ -739,11 +745,12 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
if (nsnull == kidPrevInFlow) {
nsIContentDelegate* kidDel = nsnull;
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, this);
nsresult rv = kidDel->CreateFrame(aPresContext, kid, this, kidSC,
kidFrame);
NS_RELEASE(kidDel);
kidFrame->SetStyleContext(aPresContext,kidSC);
} else {
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame);
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidSC,
kidFrame);
}
// Try to reflow the child into the available space. It might not
@ -922,12 +929,17 @@ nsTableRowGroupFrame::IncrementalReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsTableRowGroupFrame* cf = new nsTableRowGroupFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
if (PR_TRUE==gsDebug1) printf("nsTableRowGroupFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf);
aContinuingFrame = cf;
return NS_OK;

View File

@ -85,9 +85,10 @@ public:
ReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
/** returns the type of the mapped row group content in aType.
* caller MUST call release on the returned object if it is not null.

View File

@ -194,7 +194,10 @@ void nsTableCellFrame::CreatePsuedoFrame(nsIPresContext* aPresContext)
NS_ASSERTION(prevFrame->ChildIsPseudoFrame(prevPseudoFrame), "bad previous pseudo-frame");
// Create a continuing column
prevPseudoFrame->CreateContinuingFrame(aPresContext, this, mFirstChild);
nsIStyleContext* kidSC;
prevPseudoFrame->GetStyleContext(aPresContext, kidSC);
prevPseudoFrame->CreateContinuingFrame(aPresContext, this, kidSC, mFirstChild);
NS_RELEASE(kidSC);
mChildCount = 1;
}
}
@ -334,12 +337,17 @@ NS_METHOD nsTableCellFrame::IncrementalReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsTableCellFrame* cf = new nsTableCellFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
aContinuingFrame = cf;
return NS_OK;
}

View File

@ -54,9 +54,10 @@ public:
/**
* @see nsContainerFrame
*/
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
void VerticallyAlignChild(nsIPresContext* aPresContext);

View File

@ -637,9 +637,9 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresCont
{
nsIContentDelegate* kidDel;
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, this);
nsresult rv = kidDel->CreateFrame(aPresContext, kid,
this, kidStyleContext, kidFrame);
NS_RELEASE(kidDel);
kidFrame->SetStyleContext(aPresContext,kidStyleContext);
}
nsSize maxKidElementSize;
@ -1058,7 +1058,10 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
// frame. This hooks the child into the flow
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to the sibling list
@ -1286,7 +1289,10 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
// prepares it for reflow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to our sibling list and then push
@ -1412,11 +1418,12 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
if (nsnull == kidPrevInFlow) {
nsIContentDelegate* kidDel = nsnull;
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, this);
nsresult rv = kidDel->CreateFrame(aPresContext, kid, this,
kidStyleContext, kidFrame);
NS_RELEASE(kidDel);
kidFrame->SetStyleContext(aPresContext, kidStyleContext);
} else {
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame);
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidStyleContext,
kidFrame);
}
// Try to reflow the child into the available space. It might not
@ -2039,12 +2046,17 @@ PRBool nsTableFrame::IsFirstPassValid() const
return firstInFlow->mFirstPassValid;
}
NS_METHOD nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsTableFrame* cf = new nsTableFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
if (PR_TRUE==gsDebug) printf("nsTableFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf);
// set my width, because all frames in a table flow are the same width
// code in nsTableOuterFrame depends on this being set
@ -2074,9 +2086,10 @@ NS_METHOD nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
aPresContext->ResolveStyleContextFor(content, cf); // kidStyleContext: REFCNT++
nsIContentDelegate* kidDel = nsnull;
kidDel = content->GetDelegate(aPresContext); // kidDel: REFCNT++
nsIFrame * duplicateFrame = kidDel->CreateFrame(aPresContext, content, cf);
nsIFrame* duplicateFrame;
nsresult rv = kidDel->CreateFrame(aPresContext, content, cf,
kidStyleContext, duplicateFrame);
NS_RELEASE(kidDel); // kidDel: REFCNT--
duplicateFrame->SetStyleContext(aPresContext,kidStyleContext);
NS_RELEASE(kidStyleContext); // kidStyleContenxt: REFCNT--
if (nsnull==lastSib)

View File

@ -95,9 +95,10 @@ public:
ReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
/** resize myself and my children according to the arcane rules of cell height magic.
* By default, the height of a cell is the max (height of cells in its row)

View File

@ -529,8 +529,11 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
// The child doesn't have a next-in-flow so create a continuing
// frame. This hooks the child into the flow
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to the sibling list
@ -764,8 +767,10 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext,
// continuing frame. The creation appends it to the flow and
// prepares it for reflow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to our sibling list and then push
@ -1202,12 +1207,17 @@ nsTableOuterFrame::IncrementalReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsTableOuterFrame* cf = new nsTableOuterFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
cf->SetFirstPassValid(PR_TRUE);
if (PR_TRUE==gsDebug)
printf("nsTableOuterFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf);
@ -1215,9 +1225,11 @@ NS_METHOD nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
return NS_OK;
}
void nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsTableOuterFrame* aContFrame)
void
nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsTableOuterFrame* aContFrame)
{
// Append the continuing frame to the flow
aContFrame->AppendToFlow(this);
@ -1238,12 +1250,7 @@ void nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext,
aContFrame->SetFirstContentOffset(nextOffset);
aContFrame->SetLastContentOffset(nextOffset);
aContFrame->SetLastContentIsComplete(PR_TRUE);
// Resolve style for the continuing frame and set its style context.
// XXX presumptive
nsIStyleContextPtr styleContext =
aPresContext->ResolveStyleContextFor(mContent, aParent);
aContFrame->SetStyleContext(aPresContext,styleContext);
aContFrame->SetStyleContext(aPresContext, aStyleContext);
}
NS_METHOD nsTableOuterFrame::VerifyTree() const
@ -1373,8 +1380,10 @@ void nsTableOuterFrame::CreateInnerTableFrame(nsIPresContext* aPresContext)
if (nsnull==mInnerTableFrame)
{
nsIFrame* continuingFrame;
prevInnerTable->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
prevInnerTable->GetStyleContext(aPresContext, kidSC);
prevInnerTable->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
mInnerTableFrame = (nsTableFrame*)continuingFrame;
mChildCount++;
}

View File

@ -97,9 +97,10 @@ public:
ReflowStatus& aStatus);
/** @see nsContainerFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
/** destructor */
virtual ~nsTableOuterFrame();
@ -206,9 +207,10 @@ protected:
/** overridden here to handle special caption-table relationship
* @see nsContainerFrame::PrepareContinuingFrame
*/
virtual void PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsTableOuterFrame* aContFrame);
void PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsTableOuterFrame* aContFrame);
/**
* Remove and delete aChild's next-in-flow(s). Updates the sibling and flow

View File

@ -391,8 +391,11 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
// No the child isn't complete, and it doesn't have a next in flow so
// create a continuing frame. This hooks the child into the flow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
// Insert the frame. We'll reflow it next pass through the loop
nsIFrame* nextSib;
@ -654,8 +657,11 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
// continuing frame. The creation appends it to the flow and
// prepares it for reflow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to our sibling list and then push
@ -808,11 +814,12 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
if (nsnull == kidPrevInFlow) {
nsIContentDelegate* kidDel = nsnull;
kidDel = cell->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, cell, this);
nsresult rv = kidDel->CreateFrame(aPresContext, cell,
this, kidStyleContext, kidFrame);
NS_RELEASE(kidDel);
kidFrame->SetStyleContext(aPresContext,kidStyleContext);
} else {
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame);
kidPrevInFlow->CreateContinuingFrame(aPresContext, this,
kidStyleContext, kidFrame);
}
NS_RELEASE(kidStyleContext);
@ -1030,13 +1037,18 @@ nsTableRowFrame::IncrementalReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
if (gsDebug1==PR_TRUE) printf("nsTableRowFrame::CreateContinuingFrame\n");
nsTableRowFrame* cf = new nsTableRowFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
aContinuingFrame = cf;
return NS_OK;
}

View File

@ -91,9 +91,10 @@ public:
ReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
/** set mTallestCell to 0 in anticipation of recalculating it */
void ResetMaxChildHeight();

View File

@ -359,8 +359,11 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
// No the child isn't complete, and it doesn't have a next in flow so
// create a continuing frame. This hooks the child into the flow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
// Insert the frame. We'll reflow it next pass through the loop
nsIFrame* nextSib;
@ -587,8 +590,11 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
// continuing frame. The creation appends it to the flow and
// prepares it for reflow.
nsIFrame* continuingFrame;
kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame);
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
continuingFrame);
NS_RELEASE(kidSC);
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
// Add the continuing frame to our sibling list and then push
@ -739,11 +745,12 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
if (nsnull == kidPrevInFlow) {
nsIContentDelegate* kidDel = nsnull;
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, this);
nsresult rv = kidDel->CreateFrame(aPresContext, kid, this, kidSC,
kidFrame);
NS_RELEASE(kidDel);
kidFrame->SetStyleContext(aPresContext,kidSC);
} else {
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame);
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidSC,
kidFrame);
}
// Try to reflow the child into the available space. It might not
@ -922,12 +929,17 @@ nsTableRowGroupFrame::IncrementalReflow(nsIPresContext* aPresContext,
return NS_OK;
}
NS_METHOD nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame)
NS_METHOD
nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame)
{
nsTableRowGroupFrame* cf = new nsTableRowGroupFrame(mContent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
if (nsnull == cf) {
return NS_ERROR_OUT_OF_MEMORY;
}
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
if (PR_TRUE==gsDebug1) printf("nsTableRowGroupFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf);
aContinuingFrame = cf;
return NS_OK;

View File

@ -85,9 +85,10 @@ public:
ReflowStatus& aStatus);
/** @see nsContainerFrame::CreateContinuingFrame */
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIFrame*& aContinuingFrame);
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsIFrame*& aContinuingFrame);
/** returns the type of the mapped row group content in aType.
* caller MUST call release on the returned object if it is not null.