Bug 1124261, part 2 - Make NS_NewXBLEventHandler infallible. r=smaug

This commit is contained in:
Andrew McCreight 2015-01-30 10:55:11 -08:00
parent 2e40389e4b
commit 69b2819df2
3 changed files with 10 additions and 16 deletions

View File

@ -160,30 +160,26 @@ nsXBLKeyEventHandler::HandleEvent(nsIDOMEvent* aEvent)
///////////////////////////////////////////////////////////////////////////////////
nsresult
already_AddRefed<nsXBLEventHandler>
NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler,
nsIAtom* aEventType,
nsXBLEventHandler** aResult)
nsIAtom* aEventType)
{
nsRefPtr<nsXBLEventHandler> handler;
switch (nsContentUtils::GetEventClassID(nsDependentAtomString(aEventType))) {
case eDragEventClass:
case eMouseEventClass:
case eMouseScrollEventClass:
case eWheelEventClass:
case eSimpleGestureEventClass:
*aResult = new nsXBLMouseEventHandler(aHandler);
handler = new nsXBLMouseEventHandler(aHandler);
break;
default:
*aResult = new nsXBLEventHandler(aHandler);
handler = new nsXBLEventHandler(aHandler);
break;
}
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
return handler.forget();
}
nsresult

View File

@ -113,10 +113,9 @@ private:
bool mUsingContentXBLScope;
};
nsresult
already_AddRefed<nsXBLEventHandler>
NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler,
nsIAtom* aEventType,
nsXBLEventHandler** aResult);
nsIAtom* aEventType);
nsresult
NS_NewXBLKeyEventHandler(nsIAtom* aEventType, uint8_t aPhase,

View File

@ -132,8 +132,7 @@ public:
nsXBLEventHandler* GetEventHandler()
{
if (!mHandler) {
NS_NewXBLEventHandler(this, mEventName, getter_AddRefs(mHandler));
// XXX Need to signal out of memory?
mHandler = NS_NewXBLEventHandler(this, mEventName);
}
return mHandler;