diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 01bdb1b4dab..c91c49b81e1 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1600,8 +1600,6 @@ nsCSSFrameConstructor::CreateGeneratedContent(nsFrameConstructorState& aState, nsCounterUseNode* node = new nsCounterUseNode(counters, aContentIndex, type == eStyleContentType_Counters); - if (!node) - return nsnull; nsGenConInitializer* initializer = new nsGenConInitializer(node, counterList, @@ -1621,8 +1619,6 @@ nsCSSFrameConstructor::CreateGeneratedContent(nsFrameConstructorState& aState, { nsQuoteNode* node = new nsQuoteNode(type, aContentIndex); - if (!node) - return nsnull; nsGenConInitializer* initializer = new nsGenConInitializer(node, &mQuoteList, @@ -5072,9 +5068,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState PRBool resolveStyle; nsAutoPtr newPendingBinding(new PendingBinding()); - if (!newPendingBinding) { - return; - } + nsresult rv = xblService->LoadBindings(aContent, display->mBinding->GetURI(), display->mBinding->mOriginPrincipal, PR_FALSE, @@ -9405,10 +9399,6 @@ nsCSSFrameConstructor::CreateNeededTablePseudos(nsFrameConstructorState& aState, wrapperStyle.forget(), PR_TRUE); - if (!newItem) { - return NS_ERROR_OUT_OF_MEMORY; - } - // Here we're cheating a tad... technically, table-internal items should be // inline if aParentFrame is inline, but they'll get wrapped in an // inline-table in the end, so it'll all work out. In any case, arguably diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index c16c7e86de5..7a66e40e6b4 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -856,14 +856,9 @@ private: new FrameConstructionItem(aFCData, aContent, aTag, aNameSpaceID, aPendingBinding, aStyleContext, aSuppressWhiteSpaceOptimizations); - if (item) { - PR_APPEND_LINK(item, &mItems); - ++mItemCount; - ++mDesiredParentCounts[item->DesiredParentType()]; - } else { - // Clean up the style context - nsRefPtr sc(aStyleContext); - } + PR_APPEND_LINK(item, &mItems); + ++mItemCount; + ++mDesiredParentCounts[item->DesiredParentType()]; return item; } diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 23cab9e52ef..301f4f92e72 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -2121,7 +2121,7 @@ nsCSSRendering::PaintGradient(nsPresContext* aPresContext, } gradientPattern = new gfxPattern(lineStart.x, lineStart.y, innerRadius, lineStart.x, lineStart.y, outerRadius); - if (gradientPattern && radiusX != radiusY) { + if (radiusX != radiusY) { // Stretch the circles into ellipses vertically by setting a transform // in the pattern. // Recall that this is the transform from user space to pattern space. @@ -2134,7 +2134,7 @@ nsCSSRendering::PaintGradient(nsPresContext* aPresContext, gradientPattern->SetMatrix(matrix); } } - if (!gradientPattern || gradientPattern->CairoStatus()) + if (gradientPattern->CairoStatus()) return; // Now set normalized color stops in pattern. diff --git a/layout/base/nsCounterManager.cpp b/layout/base/nsCounterManager.cpp index 340075be111..9233376e57a 100644 --- a/layout/base/nsCounterManager.cpp +++ b/layout/base/nsCounterManager.cpp @@ -244,8 +244,6 @@ nsCounterManager::AddResetOrIncrement(nsIFrame *aFrame, PRInt32 aIndex, { nsCounterChangeNode *node = new nsCounterChangeNode(aFrame, aType, aCounterData->mValue, aIndex); - if (!node) - return PR_FALSE; nsCounterList *counterList = CounterListFor(aCounterData->mCounter); if (!counterList) { @@ -277,8 +275,6 @@ nsCounterManager::CounterListFor(const nsSubstring& aCounterName) nsCounterList *counterList; if (!mNames.Get(aCounterName, &counterList)) { counterList = new nsCounterList(); - if (!counterList) - return nsnull; if (!mNames.Put(aCounterName, counterList)) { delete counterList; return nsnull; diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index b843c416600..81e312727bf 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -574,8 +574,6 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder, return; } layerManager = new BasicLayerManager(); - if (!layerManager) - return; } if (aFlags & PAINT_FLUSH_LAYERS) { diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 8016ff1607f..376baac8d56 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -545,9 +545,6 @@ nsresult NS_NewDocumentViewer(nsIDocumentViewer** aResult) { *aResult = new DocumentViewerImpl(); - if (!*aResult) { - return NS_ERROR_OUT_OF_MEMORY; - } NS_ADDREF(*aResult); @@ -800,7 +797,6 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow) if (!mSelectionListener) { nsDocViewerSelectionListener *selectionListener = new nsDocViewerSelectionListener(); - NS_ENSURE_TRUE(selectionListener, NS_ERROR_OUT_OF_MEMORY); selectionListener->Init(this); @@ -825,7 +821,6 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow) // now register ourselves as a focus listener, so that we get called // when the focus changes in the window nsDocViewerFocusListener *focusListener = new nsDocViewerFocusListener(); - NS_ENSURE_TRUE(focusListener, NS_ERROR_OUT_OF_MEMORY); focusListener->Init(this); @@ -2180,9 +2175,6 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument, // this should eventually get expanded to allow for creating // different sets for different media nsStyleSet *styleSet = new nsStyleSet(); - if (!styleSet) { - return NS_ERROR_OUT_OF_MEMORY; - } styleSet->BeginUpdate(); @@ -3684,7 +3676,6 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings, if (!mPrintEngine) { mPrintEngine = new nsPrintEngine(); - NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_OUT_OF_MEMORY); rv = mPrintEngine->Initialize(this, mContainer, mDocument, float(mDeviceContext->AppUnitsPerCSSInch()) / @@ -3751,7 +3742,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings, nsPrintEventDispatcher beforeAndAfterPrint(doc); if (!mPrintEngine) { mPrintEngine = new nsPrintEngine(); - NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_OUT_OF_MEMORY); rv = mPrintEngine->Initialize(this, mContainer, doc, float(mDeviceContext->AppUnitsPerCSSInch()) / diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index 7859cbc1468..58593686bed 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -380,14 +380,12 @@ nsFrameManager::SetUndisplayedContent(nsIContent* aContent, if (! mUndisplayedMap) { mUndisplayedMap = new UndisplayedMap; } - if (mUndisplayedMap) { - nsIContent* parent = aContent->GetParent(); - NS_ASSERTION(parent || (mPresShell && mPresShell->GetDocument() && - mPresShell->GetDocument()->GetRootElement() == aContent), - "undisplayed content must have a parent, unless it's the root " - "element"); - mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext); - } + nsIContent* parent = aContent->GetParent(); + NS_ASSERTION(parent || (mPresShell && mPresShell->GetDocument() && + mPresShell->GetDocument()->GetRootElement() == aContent), + "undisplayed content must have a parent, unless it's the root " + "element"); + mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext); } void @@ -1900,9 +1898,6 @@ nsFrameManagerBase::UndisplayedMap::AddNodeFor(nsIContent* aParentContent, nsStyleContext* aStyle) { UndisplayedNode* node = new UndisplayedNode(aChild, aStyle); - if (! node) { - return NS_ERROR_OUT_OF_MEMORY; - } AppendNodeFor(node, aParentContent); return NS_OK; diff --git a/layout/base/nsFrameTraversal.cpp b/layout/base/nsFrameTraversal.cpp index 7b18636e76f..76c3793feae 100644 --- a/layout/base/nsFrameTraversal.cpp +++ b/layout/base/nsFrameTraversal.cpp @@ -151,8 +151,6 @@ nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult) *aResult = nsnull; nsCOMPtr t(new nsFrameTraversal()); - if (!t) - return NS_ERROR_OUT_OF_MEMORY; *aResult = t; NS_ADDREF(*aResult); @@ -179,10 +177,7 @@ NS_NewFrameTraversal(nsIFrameEnumerator **aEnumerator, trav = new nsFrameIterator(aPresContext, aStart, aType, aLockInScrollView, aFollowOOFs); } - if (!trav) - return NS_ERROR_OUT_OF_MEMORY; - *aEnumerator = trav; - NS_ADDREF(trav); + trav.forget(aEnumerator); return NS_OK; } diff --git a/layout/base/nsLayoutDebugger.cpp b/layout/base/nsLayoutDebugger.cpp index de70226f342..9b160cd38a6 100644 --- a/layout/base/nsLayoutDebugger.cpp +++ b/layout/base/nsLayoutDebugger.cpp @@ -84,9 +84,6 @@ NS_NewLayoutDebugger(nsILayoutDebugger** aResult) return NS_ERROR_NULL_POINTER; } nsLayoutDebugger* it = new nsLayoutDebugger(); - if (!it) { - return NS_ERROR_OUT_OF_MEMORY; - } return it->QueryInterface(NS_GET_IID(nsILayoutDebugger), (void**)aResult); } diff --git a/layout/base/nsLayoutHistoryState.cpp b/layout/base/nsLayoutHistoryState.cpp index 5c5a28710d6..894c3c6fcdf 100644 --- a/layout/base/nsLayoutHistoryState.cpp +++ b/layout/base/nsLayoutHistoryState.cpp @@ -77,8 +77,6 @@ NS_NewLayoutHistoryState(nsILayoutHistoryState** aState) *aState = nsnull; state = new nsLayoutHistoryState(); - if (!state) - return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(state); nsresult rv = state->Init(); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index b7581846283..283033ced56 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1811,10 +1811,6 @@ nsLayoutUtils::RectListBuilder::RectListBuilder(nsClientRectList* aList) void nsLayoutUtils::RectListBuilder::AddRect(const nsRect& aRect) { nsRefPtr rect = new nsClientRect(); - if (!rect) { - mRV = NS_ERROR_OUT_OF_MEMORY; - return; - } rect->SetLayoutRect(aRect); mRectList->Append(rect); @@ -3876,12 +3872,8 @@ nsLayoutUtils::SurfaceFromElement(nsIDOMElement *aElement, if (wantImageSurface && surf->GetType() != gfxASurface::SurfaceTypeImage) { nsRefPtr imgSurf = new gfxImageSurface(size, gfxASurface::ImageFormatARGB32); - if (!imgSurf) - return result; nsRefPtr ctx = new gfxContext(imgSurf); - if (!ctx) - return result; ctx->SetOperator(gfxContext::OPERATOR_SOURCE); ctx->DrawSurface(surf, size); surf = imgSurf; diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 22936eb9603..1b5b6e79163 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -912,18 +912,11 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext) } mEventManager = new nsEventStateManager(); - if (!mEventManager) - return NS_ERROR_OUT_OF_MEMORY; - NS_ADDREF(mEventManager); mTransitionManager = new nsTransitionManager(this); - if (!mTransitionManager) - return NS_ERROR_OUT_OF_MEMORY; mAnimationManager = new nsAnimationManager(this); - if (!mAnimationManager) - return NS_ERROR_OUT_OF_MEMORY; if (mDocument->GetDisplayDocument()) { NS_ASSERTION(mDocument->GetDisplayDocument()->GetShell() && @@ -959,8 +952,6 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext) if (!mRefreshDriver) { mRefreshDriver = new nsRefreshDriver(this); - if (!mRefreshDriver) - return NS_ERROR_OUT_OF_MEMORY; } } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 448a891c7c3..f6fec5924de 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1244,10 +1244,8 @@ protected: aEvent->widget, aEvent->reason, aEvent->context); - if (mEvent) { - Init(aEvent); - static_cast(mEvent)->clickCount = aEvent->clickCount; - } + Init(aEvent); + static_cast(mEvent)->clickCount = aEvent->clickCount; } virtual ~nsDelayedMouseEvent() @@ -1264,14 +1262,12 @@ protected: mEvent = new nsKeyEvent(NS_IS_TRUSTED_EVENT(aEvent), aEvent->message, aEvent->widget); - if (mEvent) { - Init(aEvent); - static_cast(mEvent)->keyCode = aEvent->keyCode; - static_cast(mEvent)->charCode = aEvent->charCode; - static_cast(mEvent)->alternativeCharCodes = - aEvent->alternativeCharCodes; - static_cast(mEvent)->isChar = aEvent->isChar; - } + Init(aEvent); + static_cast(mEvent)->keyCode = aEvent->keyCode; + static_cast(mEvent)->charCode = aEvent->charCode; + static_cast(mEvent)->alternativeCharCodes = + aEvent->alternativeCharCodes; + static_cast(mEvent)->isChar = aEvent->isChar; } virtual ~nsDelayedKeyEvent() @@ -1664,8 +1660,6 @@ NS_NewPresShell(nsIPresShell** aInstancePtrResult) return NS_ERROR_NULL_POINTER; *aInstancePtrResult = new PresShell(); - if (!*aInstancePtrResult) - return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(*aInstancePtrResult); return NS_OK; @@ -1801,7 +1795,6 @@ PresShell::Init(nsIDocument* aDocument, // Create our frame constructor. mFrameConstructor = new nsCSSFrameConstructor(mDocument, this); - NS_ENSURE_TRUE(mFrameConstructor, NS_ERROR_OUT_OF_MEMORY); // The document viewer owns both view manager and pres shell. mViewManager->SetViewObserver(this); @@ -5486,8 +5479,6 @@ PresShell::CreateRangePaintInfo(nsIDOMRange* aRange, return nsnull; info = new RangePaintInfo(range, ancestorFrame); - if (!info) - return nsnull; nsRect ancestorRect = ancestorFrame->GetVisualOverflowRect(); @@ -5589,7 +5580,7 @@ PresShell::PaintRangePaintInfo(nsTArray >* aItems, gfxImageSurface* surface = new gfxImageSurface(gfxIntSize(pixelArea.width, pixelArea.height), gfxImageSurface::ImageFormatARGB32); - if (!surface || surface->CairoStatus()) { + if (surface->CairoStatus()) { delete surface; return nsnull; } @@ -6565,7 +6556,7 @@ PresShell::HandleEvent(nsIView *aView, } else if (!mNoDelayedKeyEvents) { nsDelayedEvent* event = new nsDelayedKeyEvent(static_cast(aEvent)); - if (event && !mDelayedEvents.AppendElement(event)) { + if (!mDelayedEvents.AppendElement(event)) { delete event; } } @@ -8595,7 +8586,6 @@ DumpToPNG(nsIPresShell* shell, nsAString& name) { nsRefPtr imgSurface = new gfxImageSurface(gfxIntSize(width, height), gfxImageSurface::ImageFormatARGB32); - NS_ENSURE_TRUE(imgSurface, NS_ERROR_OUT_OF_MEMORY); nsRefPtr imgContext = new gfxContext(imgSurface); @@ -8606,7 +8596,6 @@ DumpToPNG(nsIPresShell* shell, nsAString& name) { NS_ENSURE_TRUE(surface, NS_ERROR_OUT_OF_MEMORY); nsRefPtr context = new gfxContext(surface); - NS_ENSURE_TRUE(context, NS_ERROR_OUT_OF_MEMORY); shell->RenderDocument(r, 0, NS_RGB(255, 255, 0), context); @@ -8979,7 +8968,6 @@ void ReflowCountMgr::Add(const char * aName, nsIFrame * aFrame) ReflowCounter * counter = (ReflowCounter *)PL_HashTableLookup(mCounts, aName); if (counter == nsnull) { counter = new ReflowCounter(this); - NS_ASSERTION(counter != nsnull, "null ptr"); char * name = NS_strdup(aName); NS_ASSERTION(name != nsnull, "null ptr"); PL_HashTableAdd(mCounts, name, counter); @@ -8995,7 +8983,6 @@ void ReflowCountMgr::Add(const char * aName, nsIFrame * aFrame) IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(mIndiFrameCounts, key); if (counter == nsnull) { counter = new IndiReflowCounter(this); - NS_ASSERTION(counter != nsnull, "null ptr"); counter->mFrame = aFrame; counter->mName.AssignASCII(aName); PL_HashTableAdd(mIndiFrameCounts, key, counter); diff --git a/layout/base/nsStyleSheetService.cpp b/layout/base/nsStyleSheetService.cpp index 0b62c8ec5e2..bc95d5a0707 100644 --- a/layout/base/nsStyleSheetService.cpp +++ b/layout/base/nsStyleSheetService.cpp @@ -169,7 +169,6 @@ nsStyleSheetService::LoadAndRegisterSheetInternal(nsIURI *aSheetURI, NS_ENSURE_ARG_POINTER(aSheetURI); nsRefPtr loader = new mozilla::css::Loader(); - NS_ENSURE_TRUE(loader, NS_ERROR_OUT_OF_MEMORY); nsRefPtr sheet; // Allow UA sheets, but not user sheets, to use unsafe rules