Bug 1193086 - Remove some null checks of infallible new code in XUL. r=baku

This commit is contained in:
Andrew McCreight 2015-08-13 14:24:59 -07:00
parent bae50e0bdc
commit b9d631ee33
4 changed files with 1 additions and 39 deletions

View File

@ -240,9 +240,6 @@ NS_NewXULDocument(nsIXULDocument** result)
return NS_ERROR_NULL_POINTER;
XULDocument* doc = new XULDocument();
if (! doc)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(doc);
nsresult rv;
@ -449,8 +446,6 @@ XULDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
// the interesting work happens below XULDocument::EndLoad, from
// the call there to mCurrentPrototype->NotifyLoadDone().
*aDocListener = new CachedChromeStreamListener(this, loaded);
if (! *aDocListener)
return NS_ERROR_OUT_OF_MEMORY;
}
else {
bool useXULCache = nsXULPrototypeCache::GetInstance()->IsEnabled();
@ -1635,9 +1630,6 @@ XULDocument::AddElementToDocumentPre(Element* aElement)
// later.
if (listener && !resolved && (mResolutionPhase != nsForwardReference::eDone)) {
BroadcasterHookup* hookup = new BroadcasterHookup(this, aElement);
if (! hookup)
return NS_ERROR_OUT_OF_MEMORY;
rv = AddForwardReference(hookup);
if (NS_FAILED(rv)) return rv;
}
@ -1668,9 +1660,6 @@ XULDocument::AddElementToDocumentPost(Element* aElement)
}
else {
TemplateBuilderHookup* hookup = new TemplateBuilderHookup(aElement);
if (! hookup)
return NS_ERROR_OUT_OF_MEMORY;
rv = AddForwardReference(hookup);
if (NS_FAILED(rv))
return rv;
@ -1875,7 +1864,6 @@ XULDocument::Init()
// Create our command dispatcher and hook it up.
mCommandDispatcher = new nsXULCommandDispatcher(this);
NS_ENSURE_TRUE(mCommandDispatcher, NS_ERROR_OUT_OF_MEMORY);
if (gRefCnt++ == 0) {
// ensure that the XUL prototype cache is instantiated successfully,
@ -2007,7 +1995,6 @@ XULDocument::PrepareToLoadPrototype(nsIURI* aURI, const char* aCommand,
// Create a XUL content sink, a parser, and kick off a load for
// the overlay.
nsRefPtr<XULContentSinkImpl> sink = new XULContentSinkImpl();
if (!sink) return NS_ERROR_OUT_OF_MEMORY;
rv = sink->Init(this, mCurrentPrototype);
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to initialize datasource sink");
@ -2195,9 +2182,6 @@ XULDocument::ContextStack::Push(nsXULPrototypeElement* aPrototype,
nsIContent* aElement)
{
Entry* entry = new Entry;
if (! entry)
return NS_ERROR_OUT_OF_MEMORY;
entry->mPrototype = aPrototype;
entry->mElement = aElement;
NS_IF_ADDREF(entry->mElement);
@ -2652,9 +2636,6 @@ XULDocument::LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic,
// and will let us recover from a missing overlay.
ParserObserver* parserObserver =
new ParserObserver(this, mCurrentPrototype);
if (! parserObserver)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(parserObserver);
parser->Parse(aURI, parserObserver);
NS_RELEASE(parserObserver);
@ -3632,8 +3613,6 @@ XULDocument::CreateOverlayElement(nsXULPrototypeElement* aPrototype,
OverlayForwardReference* fwdref =
new OverlayForwardReference(this, element);
if (! fwdref)
return NS_ERROR_OUT_OF_MEMORY;
// transferring ownership to ya...
rv = AddForwardReference(fwdref);

View File

@ -310,11 +310,7 @@ nsXULCommandDispatcher::AddCommandUpdater(nsIDOMElement* aElement,
#endif
// If we get here, this is a new updater. Append it to the list.
updater = new Updater(aElement, aEvents, aTargets);
if (! updater)
return NS_ERROR_OUT_OF_MEMORY;
*link = updater;
*link = new Updater(aElement, aEvents, aTargets);
return NS_OK;
}

View File

@ -52,9 +52,6 @@ NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult)
return NS_ERROR_NO_AGGREGATION;
nsXULControllers* controllers = new nsXULControllers();
if (! controllers)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
NS_ADDREF(controllers);
rv = controllers->QueryInterface(aIID, aResult);
@ -121,7 +118,6 @@ NS_IMETHODIMP
nsXULControllers::InsertControllerAt(uint32_t aIndex, nsIController *controller)
{
nsXULControllerData* controllerData = new nsXULControllerData(++mCurControllerID, controller);
if (!controllerData) return NS_ERROR_OUT_OF_MEMORY;
#ifdef DEBUG
nsXULControllerData** inserted =
#endif
@ -165,7 +161,6 @@ nsXULControllers::AppendController(nsIController *controller)
{
// This assigns controller IDs starting at 1 so we can use 0 to test if an ID was obtained
nsXULControllerData* controllerData = new nsXULControllerData(++mCurControllerID, controller);
if (!controllerData) return NS_ERROR_OUT_OF_MEMORY;
#ifdef DEBUG
nsXULControllerData** appended =

View File

@ -54,8 +54,6 @@ nsresult
nsXULPrototypeDocument::Init()
{
mNodeInfoManager = new nsNodeInfoManager();
NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_OUT_OF_MEMORY);
return mNodeInfoManager->Init(nullptr);
}
@ -149,8 +147,6 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream)
mNodeInfoManager->SetDocumentPrincipal(principal);
mRoot = new nsXULPrototypeElement();
if (! mRoot)
return NS_ERROR_OUT_OF_MEMORY;
// mozilla::dom::NodeInfo table
nsTArray<nsRefPtr<mozilla::dom::NodeInfo>> nodeInfos;
@ -208,10 +204,6 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream)
if ((nsXULPrototypeNode::Type)type == nsXULPrototypeNode::eType_PI) {
nsRefPtr<nsXULPrototypePI> pi = new nsXULPrototypePI();
if (! pi) {
rv = NS_ERROR_OUT_OF_MEMORY;
break;
}
tmp = pi->Deserialize(aStream, this, mURI, &nodeInfos);
if (NS_FAILED(tmp)) {