// Caller must root *aJSVal! bool nsEventListenerInfo::GetJSVal(JSContext* aCx, mozilla::Maybe<JSAutoCompartment>& aAc, jsval* aJSVal) { *aJSVal = JSVAL_NULL; nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(mListener); if (wrappedJS) { JSObject* object = nullptr; if (NS_FAILED(wrappedJS->GetJSObject(&object))) { return false; } aAc.construct(aCx, object); *aJSVal = OBJECT_TO_JSVAL(object); return true; } nsCOMPtr<nsIJSEventListener> jsl = do_QueryInterface(mListener); if (jsl) { JSObject *handler = jsl->GetHandler(); if (handler) { aAc.construct(aCx, handler); *aJSVal = OBJECT_TO_JSVAL(handler); return true; } } return false; }
// Caller must root *aJSVal! bool nsEventListenerInfo::GetJSVal(JSContext* aCx, mozilla::Maybe<JSAutoCompartment>& aAc, JS::Value* aJSVal) { *aJSVal = JSVAL_NULL; nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(mListener); if (wrappedJS) { JS::Rooted<JSObject*> object(aCx, wrappedJS->GetJSObject()); if (!object) { return false; } aAc.construct(aCx, object); *aJSVal = OBJECT_TO_JSVAL(object); return true; } nsCOMPtr<nsIJSEventListener> jsl = do_QueryInterface(mListener); if (jsl) { JS::Handle<JSObject*> handler(jsl->GetHandler().Ptr()->Callable()); if (handler) { aAc.construct(aCx, handler); *aJSVal = OBJECT_TO_JSVAL(handler); return true; } } return false; }