From a5f65bfee71870f2cfc8088fd6576d117db00d55 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Tue, 1 Nov 2005 20:40:54 +0000 Subject: [PATCH] Bug 313817. DeCOMtaminate more NS_New*Frame functions. r+sr=roc, patch by Marc Liddell --- layout/base/nsCSSFrameConstructor.cpp | 87 +++++++++++++---------- layout/base/nsCSSFrameConstructor.h | 2 +- layout/forms/nsHTMLButtonControlFrame.cpp | 15 +--- layout/forms/nsImageControlFrame.cpp | 15 +--- layout/forms/nsIsIndexFrame.cpp | 15 +--- layout/forms/nsLegendFrame.cpp | 15 +--- layout/forms/nsTextControlFrame.cpp | 15 +--- layout/generic/nsBRFrame.cpp | 15 +--- layout/generic/nsFrame.cpp | 15 +--- layout/generic/nsFrame.h | 2 +- layout/generic/nsFrameSetFrame.cpp | 21 ++---- layout/generic/nsHTMLCanvasFrame.cpp | 11 +-- layout/generic/nsHTMLCanvasFrame.h | 2 +- layout/generic/nsHTMLParts.h | 50 ++++++------- layout/generic/nsImageFrame.cpp | 15 +--- layout/generic/nsObjectFrame.cpp | 19 ++--- layout/generic/nsSpacerFrame.cpp | 17 ++--- 17 files changed, 121 insertions(+), 210 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 1e3757428af0..5dfc8c5c7881 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -163,8 +163,8 @@ NS_NewXTFSVGDisplayFrame(nsIPresShell*, nsIContent*, nsIFrame**); #endif #endif -nsresult -NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell, nsIFrame** aNewFrame); +nsIFrame* +NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell); #ifdef MOZ_SVG #include "nsSVGAtoms.h" @@ -2092,10 +2092,9 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIFrame* aParentFram content->SetNativeAnonymous(PR_TRUE); // Create an image frame and initialize it - nsIFrame* imageFrame = nsnull; - rv = NS_NewImageFrame(mPresShell, &imageFrame); - if (!imageFrame) { - return rv; + nsIFrame* imageFrame = NS_NewImageFrame(mPresShell); + if (NS_UNLIKELY(!imageFrame)) { + return NS_ERROR_OUT_OF_MEMORY; } rv = imageFrame->Init(presContext, content, aParentFrame, aStyleContext, @@ -2437,7 +2436,11 @@ nsCSSFrameConstructor::CreateInputFrame(nsIContent *aContent, case NS_FORM_INPUT_TEXT: case NS_FORM_INPUT_PASSWORD: - return NS_NewTextControlFrame(mPresShell, aFrame); + { + *aFrame = NS_NewTextControlFrame(mPresShell); + + return NS_UNLIKELY(!*aFrame) ? NS_ERROR_OUT_OF_MEMORY : NS_OK; + } default: NS_ASSERTION(0, "Unknown input type!"); @@ -2453,7 +2456,9 @@ nsCSSFrameConstructor::CreateHTMLImageFrame(nsIContent* aContent, { // Make sure to keep IsSpecialContent in synch with this code if (nsImageFrame::ShouldCreateImageFrameFor(aContent, aStyleContext)) { - return (*aFunc)(mPresShell, aFrame); + *aFrame = (*aFunc)(mPresShell); + + return NS_UNLIKELY(!*aFrame) ? NS_ERROR_OUT_OF_MEMORY : NS_OK; } *aFrame = nsnull; @@ -5489,6 +5494,8 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState, PRBool isFloatContainer = PR_FALSE; PRBool addedToFrameList = PR_FALSE; nsresult rv = NS_OK; + + PRBool triedFrame = PR_FALSE; // See if the element is absolute or fixed positioned const nsStyleDisplay* display = aStyleContext->GetStyleDisplay(); @@ -5509,7 +5516,9 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState, if (!aHasPseudoParent && !aState.mPseudoFrames.IsEmpty()) { ProcessPseudoFrames(aState, aFrameItems); } - rv = NS_NewBRFrame(mPresShell, &newFrame); + newFrame = NS_NewBRFrame(mPresShell); + triedFrame = PR_TRUE; + isReplaced = PR_TRUE; // BR frames don't go in the content->frame hash table: typically // there are many BR content objects and this would increase the size @@ -5520,7 +5529,8 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState, if (!aHasPseudoParent && !aState.mPseudoFrames.IsEmpty()) { ProcessPseudoFrames(aState, aFrameItems); } - rv = NS_NewWBRFrame(mPresShell, &newFrame); + newFrame = NS_NewWBRFrame(mPresShell); + triedFrame = PR_TRUE; } else if (nsHTMLAtoms::input == aTag) { // Make sure to keep IsSpecialContent in synch with this code @@ -5537,7 +5547,8 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState, ProcessPseudoFrames(aState, aFrameItems); } isReplaced = PR_TRUE; - rv = NS_NewTextControlFrame(mPresShell, &newFrame); + newFrame = NS_NewTextControlFrame(mPresShell); + triedFrame = PR_TRUE; } else if (nsHTMLAtoms::select == aTag) { if (!gUseXBLForms) { @@ -5579,25 +5590,21 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState, objContent->GetDisplayedType(&type); if (type == nsIObjectLoadingContent::TYPE_LOADING) { // Ideally, this should show the standby attribute - rv = NS_NewEmptyFrame(mPresShell, &newFrame); + newFrame = NS_NewEmptyFrame(mPresShell); } else if (type == nsIObjectLoadingContent::TYPE_PLUGIN) - rv = NS_NewObjectFrame(mPresShell, &newFrame); + newFrame = NS_NewObjectFrame(mPresShell); else if (type == nsIObjectLoadingContent::TYPE_IMAGE) - rv = NS_NewImageFrame(mPresShell, &newFrame); - else if (type == nsIObjectLoadingContent::TYPE_DOCUMENT) { + newFrame = NS_NewImageFrame(mPresShell); + else if (type == nsIObjectLoadingContent::TYPE_DOCUMENT) newFrame = NS_NewSubDocumentFrame(mPresShell); - - // xxx marc - if (!newFrame) { - rv = NS_ERROR_OUT_OF_MEMORY; - } - } #ifdef DEBUG else NS_ERROR("Shouldn't get here if we're not broken and not " "suppressed and not blocked"); #endif + + triedFrame = PR_TRUE; } } else if (nsHTMLAtoms::fieldset == aTag) { @@ -5619,7 +5626,9 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState, if (!aHasPseudoParent && !aState.mPseudoFrames.IsEmpty()) { ProcessPseudoFrames(aState, aFrameItems); } - rv = NS_NewLegendFrame(mPresShell, &newFrame); + newFrame = NS_NewLegendFrame(mPresShell); + triedFrame = PR_TRUE; + isFloatContainer = PR_TRUE; } else if (nsHTMLAtoms::frameset == aTag) { @@ -5630,7 +5639,8 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState, ProcessPseudoFrames(aState, aFrameItems); } - rv = NS_NewHTMLFramesetFrame(mPresShell, &newFrame); + newFrame = NS_NewHTMLFramesetFrame(mPresShell); + triedFrame = PR_TRUE; } else if (nsHTMLAtoms::iframe == aTag) { if (!aHasPseudoParent && !aState.mPseudoFrames.IsEmpty()) { @@ -5639,12 +5649,8 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState, isReplaced = PR_TRUE; newFrame = NS_NewSubDocumentFrame(mPresShell); - - // xxx marc - if (!newFrame) { - rv = NS_ERROR_OUT_OF_MEMORY; - } - + triedFrame = PR_TRUE; + if (newFrame) { // the nsSubDocumentFrame needs to know about its content parent during ::Init. // there is no reasonable way to get the value there. @@ -5661,13 +5667,16 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState, if (!aHasPseudoParent && !aState.mPseudoFrames.IsEmpty()) { ProcessPseudoFrames(aState, aFrameItems); } - rv = NS_NewSpacerFrame(mPresShell, &newFrame); + newFrame = NS_NewSpacerFrame(mPresShell); + triedFrame = PR_TRUE; } else if (nsHTMLAtoms::button == aTag) { if (!aHasPseudoParent && !aState.mPseudoFrames.IsEmpty()) { ProcessPseudoFrames(aState, aFrameItems); } - rv = NS_NewHTMLButtonControlFrame(mPresShell, &newFrame); + newFrame = NS_NewHTMLButtonControlFrame(mPresShell); + triedFrame = PR_TRUE; + // the html4 button needs to act just like a // regular button except contain html content // so it must be replaced or html outside it will @@ -5680,18 +5689,24 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState, ProcessPseudoFrames(aState, aFrameItems); } isReplaced = PR_TRUE; - rv = NS_NewIsIndexFrame(mPresShell, &newFrame); + newFrame = NS_NewIsIndexFrame(mPresShell); + triedFrame = PR_TRUE; } else if (nsHTMLAtoms::canvas == aTag) { if (!aHasPseudoParent && !aState.mPseudoFrames.IsEmpty()) { ProcessPseudoFrames(aState, aFrameItems); } isReplaced = PR_TRUE; - rv = NS_NewHTMLCanvasFrame(mPresShell, &newFrame); + newFrame = NS_NewHTMLCanvasFrame(mPresShell); + triedFrame = PR_TRUE; } - if (NS_FAILED(rv) || !newFrame) + if (NS_UNLIKELY(triedFrame && !newFrame)) { + return NS_ERROR_OUT_OF_MEMORY; + } + else if (NS_FAILED(rv) || !newFrame) { return rv; + } // If we succeeded in creating a frame then initialize it, process its // children (if requested), and set the initial child list @@ -11101,8 +11116,8 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext, } } else if (nsLayoutAtoms::imageFrame == frameType) { - rv = NS_NewImageFrame(shell, &newFrame); - if (NS_SUCCEEDED(rv)) { + newFrame = NS_NewImageFrame(shell); + if (NS_LIKELY(newFrame != nsnull)) { newFrame->Init(aPresContext, content, aParentFrame, styleContext, aFrame); } } else if (nsLayoutAtoms::placeholderFrame == frameType) { diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index b507887e240e..0ea475156243 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -654,7 +654,7 @@ private: nsStyleContext* aStyleContext); // A function that can be invoked to create some sort of image frame. - typedef nsresult (* ImageFrameCreatorFunc)(nsIPresShell*, nsIFrame**); + typedef nsIFrame* (* ImageFrameCreatorFunc)(nsIPresShell*); /** * CreateHTMLImageFrame will do some tests on aContent, and if it determines diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index 2127b3ebc459..4f5ee1e97752 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -71,19 +71,10 @@ #include "nsIAccessibilityService.h" #endif -nsresult -NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsHTMLButtonControlFrame* it = new (aPresShell) nsHTMLButtonControlFrame; - if (!it) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = it; - return NS_OK; + return new (aPresShell) nsHTMLButtonControlFrame; } nsHTMLButtonControlFrame::nsHTMLButtonControlFrame() diff --git a/layout/forms/nsImageControlFrame.cpp b/layout/forms/nsImageControlFrame.cpp index a1f4d923a753..f23be69aa457 100644 --- a/layout/forms/nsImageControlFrame.cpp +++ b/layout/forms/nsImageControlFrame.cpp @@ -151,19 +151,10 @@ nsImageControlFrame::Destroy(nsPresContext *aPresContext) return nsImageControlFrameSuper::Destroy(aPresContext); } -nsresult -NS_NewImageControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewImageControlFrame(nsIPresShell* aPresShell) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsImageControlFrame* it = new (aPresShell) nsImageControlFrame; - if (!it) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = it; - return NS_OK; + return new (aPresShell) nsImageControlFrame; } // Frames are not refcounted, no need to AddRef diff --git a/layout/forms/nsIsIndexFrame.cpp b/layout/forms/nsIsIndexFrame.cpp index a4a5f9d74b99..635689405dfa 100644 --- a/layout/forms/nsIsIndexFrame.cpp +++ b/layout/forms/nsIsIndexFrame.cpp @@ -82,19 +82,10 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); -nsresult -NS_NewIsIndexFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewIsIndexFrame(nsIPresShell* aPresShell) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsIsIndexFrame* it = new (aPresShell) nsIsIndexFrame(); - if (!it) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = it; - return NS_OK; + return new (aPresShell) nsIsIndexFrame(); } nsIsIndexFrame::nsIsIndexFrame() diff --git a/layout/forms/nsLegendFrame.cpp b/layout/forms/nsLegendFrame.cpp index 15ac0fb901ef..5010cf06e818 100644 --- a/layout/forms/nsLegendFrame.cpp +++ b/layout/forms/nsLegendFrame.cpp @@ -55,19 +55,10 @@ static NS_DEFINE_IID(kLegendFrameCID, NS_LEGEND_FRAME_CID); -nsresult -NS_NewLegendFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewLegendFrame(nsIPresShell* aPresShell) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsLegendFrame* it = new (aPresShell) nsLegendFrame; - if (!it) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = it; - return NS_OK; + return new (aPresShell) nsLegendFrame; } nsIAtom* diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 3d144f048460..e040586b2635 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -1223,19 +1223,10 @@ NS_IMETHODIMP nsTextInputSelectionImpl::GetFrameFromLevel(nsPresContext *aPresCo -nsresult -NS_NewTextControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewTextControlFrame(nsIPresShell* aPresShell) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsTextControlFrame* it = new (aPresShell) nsTextControlFrame(aPresShell); - if (!it) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = it; - return NS_OK; + return new (aPresShell) nsTextControlFrame(aPresShell); } NS_IMPL_ADDREF_INHERITED(nsTextControlFrame, nsBoxFrame) diff --git a/layout/generic/nsBRFrame.cpp b/layout/generic/nsBRFrame.cpp index 740ae30834ff..c3648d0defc9 100644 --- a/layout/generic/nsBRFrame.cpp +++ b/layout/generic/nsBRFrame.cpp @@ -80,19 +80,10 @@ protected: virtual ~BRFrame(); }; -nsresult -NS_NewBRFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewBRFrame(nsIPresShell* aPresShell) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsIFrame* frame = new (aPresShell) BRFrame; - if (nsnull == frame) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = frame; - return NS_OK; + return new (aPresShell) BRFrame; } BRFrame::~BRFrame() diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 0fc2b588aaad..8741290f9736 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -442,19 +442,10 @@ void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC) aRC->SetFont(font->mFont, visibility->mLangGroup); } -nsresult -NS_NewEmptyFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewEmptyFrame(nsIPresShell* aPresShell) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsFrame* it = new (aPresShell) nsFrame; - if (nsnull == it) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = it; - return NS_OK; + new (aPresShell) nsFrame; } MOZ_DECL_CTOR_COUNTER(nsFrame) diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index c3d93144005d..5991f4bd6da8 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -135,7 +135,7 @@ public: * Create a new "empty" frame that maps a given piece of content into a * 0,0 area. */ - friend nsresult NS_NewEmptyFrame(nsIPresShell* aShell, nsIFrame** aInstancePtrResult); + friend nsIFrame* NS_NewEmptyFrame(nsIPresShell* aShell); // Overloaded new operator. Initializes the memory to 0 and relies on an arena // (which comes from the presShell) to perform the allocation. diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index 990ec5c1a67a..6b68ad00d99c 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -408,9 +408,9 @@ nsHTMLFramesetFrame::Init(nsPresContext* aPresContext, kidSC = shell->StyleSet()->ResolveStyleFor(child, mStyleContext); if (tag == nsHTMLAtoms::frameset) { - result = NS_NewHTMLFramesetFrame(shell, &frame); - if (NS_FAILED(result)) - return result; + frame = NS_NewHTMLFramesetFrame(shell); + if (NS_UNLIKELY(!frame)) + return NS_ERROR_OUT_OF_MEMORY; mChildTypes[mChildCount] = FRAMESET; nsHTMLFramesetFrame* childFrame = (nsHTMLFramesetFrame*)frame; @@ -1571,19 +1571,10 @@ nsHTMLFramesetFrame::EndMouseDrag(nsPresContext* aPresContext) gDragInProgress = PR_FALSE; } -nsresult -NS_NewHTMLFramesetFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewHTMLFramesetFrame(nsIPresShell* aPresShell) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsHTMLFramesetFrame* it = new (aPresShell) nsHTMLFramesetFrame; - if (!it) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = it; - return NS_OK; + return new (aPresShell) nsHTMLFramesetFrame; } /******************************************************************************* diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 3a23587a767d..3ffcc8ba9bb7 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -44,15 +44,10 @@ #include "nsHTMLCanvasFrame.h" #include "nsICanvasElement.h" -nsresult -NS_NewHTMLCanvasFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewHTMLCanvasFrame(nsIPresShell* aPresShell) { - nsHTMLCanvasFrame* it = new (aPresShell) nsHTMLCanvasFrame; - if (nsnull == it) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = it; - return NS_OK; + return new (aPresShell) nsHTMLCanvasFrame; } nsHTMLCanvasFrame::nsHTMLCanvasFrame() diff --git a/layout/generic/nsHTMLCanvasFrame.h b/layout/generic/nsHTMLCanvasFrame.h index a1402a8e7f2b..47866a01c9d0 100644 --- a/layout/generic/nsHTMLCanvasFrame.h +++ b/layout/generic/nsHTMLCanvasFrame.h @@ -46,7 +46,7 @@ #include "gfxIImageFrame.h" #include "imgIContainer.h" -nsresult NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell, nsIFrame** aNewFrame); +nsIFrame* NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell); class nsHTMLCanvasFrame : public nsSplittableFrame { diff --git a/layout/generic/nsHTMLParts.h b/layout/generic/nsHTMLParts.h index 70727f7e7f60..38208b11a64d 100644 --- a/layout/generic/nsHTMLParts.h +++ b/layout/generic/nsHTMLParts.h @@ -138,8 +138,8 @@ NS_NewRelativeItemWrapperFrame(nsIPresShell* aPresShell) { return NS_NewAreaFrame(aPresShell, 0); } -nsresult -NS_NewBRFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); +nsIFrame* +NS_NewBRFrame(nsIPresShell* aPresShell); nsresult NS_NewCommentFrame(nsIPresShell* aPresShell, nsIFrame** aFrameResult); @@ -148,32 +148,32 @@ NS_NewCommentFrame(nsIPresShell* aPresShell, nsIFrame** aFrameResult); nsIFrame* NS_NewSubDocumentFrame(nsIPresShell* aPresShell); // -nsresult -NS_NewHTMLFramesetFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); +nsIFrame* +NS_NewHTMLFramesetFrame(nsIPresShell* aPresShell); nsresult NS_NewViewportFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); nsresult NS_NewCanvasFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); -nsresult -NS_NewImageFrame(nsIPresShell* aPresShell, nsIFrame** aFrameResult); +nsIFrame* +NS_NewImageFrame(nsIPresShell* aPresShell); nsresult NS_NewInlineFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); nsresult NS_NewPositionedInlineFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); -nsresult -NS_NewObjectFrame(nsIPresShell* aPresShell, nsIFrame** aFrameResult); -nsresult -NS_NewSpacerFrame(nsIPresShell* aPresShell, nsIFrame** aResult); +nsIFrame* +NS_NewObjectFrame(nsIPresShell* aPresShell); +nsIFrame* +NS_NewSpacerFrame(nsIPresShell* aPresShell); nsresult NS_NewTextFrame(nsIPresShell* aPresShell, nsIFrame** aResult); nsresult NS_NewContinuingTextFrame(nsIPresShell* aPresShell, nsIFrame** aResult); -nsresult -NS_NewEmptyFrame(nsIPresShell* aPresShell, nsIFrame** aResult); -inline nsresult -NS_NewWBRFrame(nsIPresShell* aPresShell, nsIFrame** aResult) { - return NS_NewEmptyFrame(aPresShell, aResult); +nsIFrame* +NS_NewEmptyFrame(nsIPresShell* aPresShell); +inline nsIFrame* +NS_NewWBRFrame(nsIPresShell* aPresShell) { + return NS_NewEmptyFrame(aPresShell); } nsresult @@ -197,10 +197,10 @@ nsresult NS_NewGfxButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aResult); nsresult NS_NewNativeButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aResult); -nsresult -NS_NewImageControlFrame(nsIPresShell* aPresShell, nsIFrame** aResult); -nsresult -NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aResult); +nsIFrame* +NS_NewImageControlFrame(nsIPresShell* aPresShell); +nsIFrame* +NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell); nsresult NS_NewGfxCheckboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aResult); nsresult @@ -209,12 +209,12 @@ nsresult NS_NewFieldSetFrame(nsIPresShell* aPresShell, nsIFrame** aResult, PRUint32 aFlags); nsresult NS_NewFileControlFrame(nsIPresShell* aPresShell, nsIFrame** aResult); -nsresult -NS_NewLegendFrame(nsIPresShell* aPresShell, nsIFrame** aResult); +nsIFrame* +NS_NewLegendFrame(nsIPresShell* aPresShell); nsresult NS_NewNativeTextControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); -nsresult -NS_NewTextControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); +nsIFrame* +NS_NewTextControlFrame(nsIPresShell* aPresShell); nsresult NS_NewGfxAutoTextControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); nsresult @@ -227,8 +227,8 @@ nsresult NS_NewListControlFrame(nsIPresShell* aPresShell, nsIFrame** aResult); nsresult NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aResult, PRUint32 aFlags); -nsresult -NS_NewIsIndexFrame(nsIPresShell* aPresShell, nsIFrame** aResult); +nsIFrame* +NS_NewIsIndexFrame(nsIPresShell* aPresShell); // Table frame factories nsresult diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 288c3681223f..3db46359af9f 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -167,19 +167,10 @@ inline PRBool HaveFixedSize(const nsHTMLReflowState& aReflowState) : HaveFixedSize(aReflowState.mStylePosition); } -nsresult -NS_NewImageFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewImageFrame(nsIPresShell* aPresShell) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsImageFrame* it = new (aPresShell) nsImageFrame; - if (nsnull == it) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = it; - return NS_OK; + return new (aPresShell) nsImageFrame; } diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index fd4f1cf6eef8..46f323b03d80 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -1208,8 +1208,8 @@ nsObjectFrame::CreateDefaultFrames(nsPresContext *aPresContext, nsHTMLContainerFrame::CreateViewForFrame(anchorFrame, this, PR_FALSE); - rv = NS_NewImageFrame(shell, &imgFrame); - if (NS_FAILED(rv)) + imgFrame = NS_NewImageFrame(shell); + if (NS_UNLIKELY(!imgFrame)) return; rv = imgFrame->Init(aPresContext, img, anchorFrame, imgStyleContext, PR_FALSE); @@ -1850,19 +1850,10 @@ nsObjectFrame::GetNextObjectFrame(nsPresContext* aPresContext, nsIFrame* aRoot) return nsnull; } -nsresult -NS_NewObjectFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewObjectFrame(nsIPresShell* aPresShell) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsObjectFrame* it = new (aPresShell) nsObjectFrame; - if (nsnull == it) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = it; - return NS_OK; + return new (aPresShell) nsObjectFrame; } diff --git a/layout/generic/nsSpacerFrame.cpp b/layout/generic/nsSpacerFrame.cpp index e20e7a42e60f..83d6008bbf82 100644 --- a/layout/generic/nsSpacerFrame.cpp +++ b/layout/generic/nsSpacerFrame.cpp @@ -50,7 +50,7 @@ class SpacerFrame : public nsFrame { public: - friend nsresult NS_NewSpacerFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); + friend nsIFrame* NS_NewSpacerFrame(nsIPresShell* aPresShell); // nsIHTMLReflow NS_IMETHOD Reflow(nsPresContext* aPresContext, @@ -65,19 +65,10 @@ protected: virtual ~SpacerFrame(); }; -nsresult -NS_NewSpacerFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) +nsIFrame* +NS_NewSpacerFrame(nsIPresShell* aPresShell) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - SpacerFrame* it = new (aPresShell) SpacerFrame; - if (nsnull == it) { - return NS_ERROR_OUT_OF_MEMORY; - } - *aNewFrame = it; - return NS_OK; + return new (aPresShell) SpacerFrame; } SpacerFrame::SpacerFrame()