Improve error handling in nsCSSFrameConstructor::CreateContinuingFrame() and its callers. b=337419 r+sr=roc

This commit is contained in:
mats.palmgren%bredband.net 2006-08-22 01:33:46 +00:00
Родитель d87b89a373
Коммит 602cf781cd
6 изменённых файлов: 89 добавлений и 37 удалений

Просмотреть файл

@ -10864,7 +10864,13 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresShell* aPresShe
nsIFrame* childFrame = aFrame->GetFirstChild(nsnull);
if (childFrame) {
nsIFrame* continuingTableFrame;
CreateContinuingFrame(aPresContext, childFrame, newFrame, &continuingTableFrame);
nsresult rv = CreateContinuingFrame(aPresContext, childFrame, newFrame,
&continuingTableFrame);
if (NS_FAILED(rv)) {
newFrame->Destroy();
*aContinuingFrame = nsnull;
return rv;
}
newChildFrames.AddChild(continuingTableFrame);
NS_ASSERTION(!childFrame->GetNextSibling(),"there can be only one inner table frame");
@ -11064,8 +11070,15 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
// See if it's a table cell frame
if (IS_TABLE_CELL(cellFrame->GetType())) {
nsIFrame* continuingCellFrame;
CreateContinuingFrame(aPresContext, cellFrame, newFrame, &continuingCellFrame);
rv = CreateContinuingFrame(aPresContext, cellFrame, newFrame,
&continuingCellFrame);
if (NS_FAILED(rv)) {
nsFrameList tmp(newChildList.childList);
tmp.DestroyFrames();
newFrame->Destroy();
*aContinuingFrame = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
newChildList.AddChild(continuingCellFrame);
}
cellFrame = cellFrame->GetNextSibling();
@ -11086,7 +11099,13 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
// Create a continuing area frame
nsIFrame* continuingAreaFrame;
nsIFrame* areaFrame = aFrame->GetFirstChild(nsnull);
CreateContinuingFrame(aPresContext, areaFrame, newFrame, &continuingAreaFrame);
rv = CreateContinuingFrame(aPresContext, areaFrame, newFrame,
&continuingAreaFrame);
if (NS_FAILED(rv)) {
newFrame->Destroy();
*aContinuingFrame = nsnull;
return rv;
}
// Set the table cell's initial child list
newFrame->SetInitialChildList(nsnull, continuingAreaFrame);
@ -11120,15 +11139,20 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
// create a continuing out of flow frame
nsIFrame* oofFrame = nsPlaceholderFrame::GetRealFrameForPlaceholder(aFrame);
nsIFrame* oofContFrame;
CreateContinuingFrame(aPresContext, oofFrame, aParentFrame, &oofContFrame);
if (!oofContFrame)
return NS_ERROR_NULL_POINTER;
rv = CreateContinuingFrame(aPresContext, oofFrame, aParentFrame, &oofContFrame);
if (NS_FAILED(rv)) {
*aContinuingFrame = nsnull;
return rv;
}
// create a continuing placeholder frame
CreatePlaceholderFrameFor(shell, aPresContext,
shell->FrameManager(), content,
oofContFrame, styleContext, aParentFrame, &newFrame);
if (!newFrame)
return NS_ERROR_NULL_POINTER;
rv = CreatePlaceholderFrameFor(shell, aPresContext, shell->FrameManager(),
content, oofContFrame, styleContext,
aParentFrame, &newFrame);
if (NS_FAILED(rv)) {
oofContFrame->Destroy();
*aContinuingFrame = nsnull;
return rv;
}
newFrame->Init(content, aParentFrame, aFrame);
} else if (nsLayoutAtoms::fieldSetFrame == frameType) {
newFrame = NS_NewFieldSetFrame(shell, styleContext);
@ -11143,13 +11167,19 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
// XXXbz we really shouldn't have to do this by hand!
nsIFrame* continuingAreaFrame;
nsIFrame* areaFrame = GetFieldSetAreaFrame(aFrame);
CreateContinuingFrame(aPresContext, areaFrame, newFrame, &continuingAreaFrame);
rv = CreateContinuingFrame(aPresContext, areaFrame, newFrame,
&continuingAreaFrame);
if (NS_FAILED(rv)) {
newFrame->Destroy();
*aContinuingFrame = nsnull;
return rv;
}
// Set the fieldset's initial child list
newFrame->SetInitialChildList(nsnull, continuingAreaFrame);
}
} else {
NS_ASSERTION(PR_FALSE, "unexpected frame type");
NS_NOTREACHED("unexpected frame type");
*aContinuingFrame = nsnull;
return NS_ERROR_UNEXPECTED;
}
@ -11194,6 +11224,8 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
nsIFrame* pageFrame = aParentFrame->GetParent();
if (!pageFrame) {
NS_ERROR("pageContentFrame does not have parent!");
newFrame->Destroy();
*aContinuingFrame = nsnull;
return NS_ERROR_UNEXPECTED;
}
@ -11207,6 +11239,8 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
nsIFrame* prevPageContentFrame = prevPage->GetFirstChild(nsnull);
if (!prevPageContentFrame) {
newFrame->Destroy();
*aContinuingFrame = nsnull;
return NS_ERROR_UNEXPECTED;
}
@ -11224,8 +11258,11 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
for (nsIFrame* fixed = firstFixed; fixed; fixed = fixed->GetNextSibling()) {
rv = ConstructFrame(state, fixed->GetContent(),
newFrame, fixedPlaceholders);
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
newFrame->Destroy();
*aContinuingFrame = nsnull;
return rv;
}
}
// Add the placeholders to our primary child list.
@ -12220,6 +12257,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame(
nsFrameItems& aResult)
{
// Create the first-letter-frame
nsresult rv;
nsIFrame* letterFrame;
nsStyleSet *styleSet = mPresShell->StyleSet();
@ -12247,9 +12285,12 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame(
nsIFrame* nextTextFrame = nsnull;
if (NeedFirstLetterContinuation(aTextContent)) {
// Create continuation
CreateContinuingFrame(aState.mPresContext, aTextFrame, aParentFrame,
&nextTextFrame);
rv = CreateContinuingFrame(aState.mPresContext, aTextFrame, aParentFrame,
&nextTextFrame);
if (NS_FAILED(rv)) {
letterFrame->Destroy();
return;
}
// Repair the continuations style context
nsStyleContext* parentStyleContext = aStyleContext->GetParent();
if (parentStyleContext) {
@ -12264,10 +12305,9 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame(
NS_ASSERTION(aResult.childList == nsnull,
"aResult should be an empty nsFrameItems!");
nsresult rv = aState.AddChild(letterFrame, aResult,
letterFrame->GetStyleDisplay(),
aTextContent, aStyleContext, aParentFrame,
PR_FALSE, PR_TRUE);
rv = aState.AddChild(letterFrame, aResult, letterFrame->GetStyleDisplay(),
aTextContent, aStyleContext, aParentFrame, PR_FALSE,
PR_TRUE);
if (nextTextFrame) {
if (NS_FAILED(rv)) {

Просмотреть файл

@ -348,17 +348,16 @@ nsHTMLContainerFrame::CreateNextInFlow(nsPresContext* aPresContext,
// into our lines child list.
nsIFrame* nextFrame = aFrame->GetNextSibling();
aPresContext->PresShell()->FrameConstructor()->
nsresult rv = aPresContext->PresShell()->FrameConstructor()->
CreateContinuingFrame(aPresContext, aFrame, aOuterFrame, &nextInFlow);
if (nsnull == nextInFlow) {
return NS_ERROR_OUT_OF_MEMORY;
if (NS_FAILED(rv)) {
return rv;
}
aFrame->SetNextSibling(nextInFlow);
nextInFlow->SetNextSibling(nextFrame);
NS_FRAME_LOG(NS_FRAME_TRACE_NEW_FRAMES,
("nsHTMLContainerFrame::MaybeCreateNextInFlow: frame=%p nextInFlow=%p",
("nsHTMLContainerFrame::CreateNextInFlow: frame=%p nextInFlow=%p",
aFrame, nextInFlow));
aNextInFlowResult = nextInFlow;

Просмотреть файл

@ -108,10 +108,12 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsPresContext* aPresContext,
// Create a continuing child of the previous page's last child
nsIFrame* newFrame;
aPresContext->PresShell()->FrameConstructor()->
nsresult rv = aPresContext->PresShell()->FrameConstructor()->
CreateContinuingFrame(aPresContext, prevLastChild,
contentPage, &newFrame);
if (NS_FAILED(rv)) {
return rv;
}
// Make the new area frame the 1st child of the page content frame. There may already be
// children placeholders which don't get reflowed but must not be destroyed until the
// page content frame is destroyed.

Просмотреть файл

@ -328,9 +328,12 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
} else if (nsnull == kidNextInFlow) {
// The page isn't complete and it doesn't have a next-in-flow, so
// create a continuing page
nsIFrame* continuingPage;
CreateContinuingPageFrame(aPresContext, kidFrame, &continuingPage);
nsIFrame* continuingPage;
nsresult rv = CreateContinuingPageFrame(aPresContext, kidFrame,
&continuingPage);
if (NS_FAILED(rv)) {
break;
}
// Add it to our child list
kidFrame->SetNextSibling(continuingPage);
reflowReason = eReflowReason_Initial;

Просмотреть файл

@ -22,6 +22,7 @@
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Mats Palmgren <mats.palmgren@bredband.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -3289,10 +3290,13 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
// frame. This hooks the child into the flow
nsIFrame* continuingFrame;
presContext->PresShell()->FrameConstructor()->
rv = presContext->PresShell()->FrameConstructor()->
CreateContinuingFrame(presContext, kidFrame, this,
&continuingFrame);
if (NS_FAILED(rv)) {
aStatus = NS_FRAME_COMPLETE;
break;
}
// Add the continuing frame to the sibling list
continuingFrame->SetNextSibling(kidFrame->GetNextSibling());
kidFrame->SetNextSibling(continuingFrame);

Просмотреть файл

@ -20,6 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mats Palmgren <mats.palmgren@bredband.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -883,9 +884,12 @@ nsTableRowGroupFrame::CreateContinuingRowFrame(nsPresContext& aPresContext,
// XXX what is the row index?
if (!aContRowFrame) {NS_ASSERTION(PR_FALSE, "bad call"); return;}
// create the continuing frame which will create continuing cell frames
aPresContext.PresShell()->FrameConstructor()->
nsresult rv = aPresContext.PresShell()->FrameConstructor()->
CreateContinuingFrame(&aPresContext, &aRowFrame, this, aContRowFrame);
if (!*aContRowFrame) return;
if (NS_FAILED(rv)) {
*aContRowFrame = nsnull;
return;
}
// Add the continuing row frame to the child list
nsIFrame* nextRow;