Beispiel #1
0
// Parent ourselves to the global of the target. This achieves the desirable
// effects of parenting to the target, but avoids making the touch inaccessible
// when the target happens to be NAC and therefore reflected into the XBL scope.
nsIGlobalObject*
Touch::GetParentObject()
{
  if (!mTarget) {
    return nullptr;
  }
  return mTarget->GetOwnerGlobal();
}
Beispiel #2
0
// Parent ourselves to the window of the target. This achieves the desirable
// effects of parenting to the target, but avoids making the touch inaccessible
// when the target happens to be NAC and therefore reflected into the XBL scope.
EventTarget*
Touch::GetParentObject()
{
  if (!mTarget) {
    return nullptr;
  }
  nsCOMPtr<nsPIDOMWindow> outer = do_QueryInterface(mTarget->GetOwnerGlobal());
  if (!outer) {
    return nullptr;
  }
  MOZ_ASSERT(outer->IsOuterWindow());
  return static_cast<nsGlobalWindow*>(outer->GetCurrentInnerWindow());
}
Beispiel #3
0
Promise*
Animation::GetFinished(ErrorResult& aRv)
{
  nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal();
  if (!mFinished && global) {
    mFinished = Promise::Create(global, aRv); // Lazily create on demand
  }
  if (!mFinished) {
    aRv.Throw(NS_ERROR_FAILURE);
  } else if (mFinishedIsResolved) {
    MaybeResolveFinishedPromise();
  }
  return mFinished;
}
Beispiel #4
0
Promise*
Animation::GetReady(ErrorResult& aRv)
{
  nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal();
  if (!mReady && global) {
    mReady = Promise::Create(global, aRv); // Lazily create on demand
  }
  if (!mReady) {
    aRv.Throw(NS_ERROR_FAILURE);
  } else if (PlayState() != AnimationPlayState::Pending) {
    mReady->MaybeResolve(this);
  }
  return mReady;
}
Beispiel #5
0
nsresult
UDPSocket::InitRemote(const nsAString& aLocalAddress,
                      const uint16_t& aLocalPort)
{
  nsresult rv;

  nsCOMPtr<nsIUDPSocketChild> sock =
    do_CreateInstance("@mozilla.org/udp-socket-child;1", &rv);
  if (NS_FAILED(rv)) {
    return rv;
  }

  mListenerProxy = new ListenerProxy(this);

  nsCOMPtr<nsIGlobalObject> obj = do_QueryInterface(GetOwner(), &rv);
  if (NS_FAILED(rv)) {
    return rv;
  }

  nsCOMPtr<nsIPrincipal> principal = obj->PrincipalOrNull();
  if (!principal) {
    return NS_ERROR_FAILURE;
  }

  nsCOMPtr<nsIEventTarget> target;
  if (nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal()) {
    target = global->EventTargetFor(TaskCategory::Other);
  }

  rv = sock->Bind(mListenerProxy,
                  principal,
                  NS_ConvertUTF16toUTF8(aLocalAddress),
                  aLocalPort,
                  mAddressReuse,
                  mLoopback,
                  0,
                  0,
                  target);

  if (NS_FAILED(rv)) {
    return rv;
  }

  mSocketChild = sock;

  return NS_OK;
}
Beispiel #6
0
MediaSource::MediaSource(nsPIDOMWindowInner* aWindow)
  : DOMEventTargetHelper(aWindow)
  , mDecoder(nullptr)
  , mPrincipal(nullptr)
  , mAbstractMainThread(GetOwnerGlobal()->AbstractMainThreadFor(TaskCategory::Other))
  , mReadyState(MediaSourceReadyState::Closed)
{
  MOZ_ASSERT(NS_IsMainThread());
  mSourceBuffers = new SourceBufferList(this);
  mActiveSourceBuffers = new SourceBufferList(this);

  nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(aWindow);
  if (sop) {
    mPrincipal = sop->GetPrincipal();
  }

  MSE_API("MediaSource(aWindow=%p) mSourceBuffers=%p mActiveSourceBuffers=%p",
          aWindow, mSourceBuffers.get(), mActiveSourceBuffers.get());
}