コード例 #1
0
// 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;
}
コード例 #2
0
// 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;
}
コード例 #3
0
void nsDocShellLoadState::GetMaybeResultPrincipalURI(
    mozilla::Maybe<nsCOMPtr<nsIURI>>& aRPURI) const {
  bool isSome = ResultPrincipalURIIsSome();
  aRPURI.reset();

  if (!isSome) {
    return;
  }

  nsCOMPtr<nsIURI> uri = ResultPrincipalURI();
  aRPURI.emplace(std::move(uri));
}
コード例 #4
0
void nsDocShellLoadState::SetMaybeResultPrincipalURI(
    mozilla::Maybe<nsCOMPtr<nsIURI>> const& aRPURI) {
  SetResultPrincipalURI(aRPURI.refOr(nullptr));
  SetResultPrincipalURIIsSome(aRPURI.isSome());
}