Exemple #1
0
void
nsSpeechTask::Cancel()
{
  MOZ_ASSERT(XRE_IsParentProcess());

  LOG(LogLevel::Debug, ("nsSpeechTask::Cancel"));

  if (mCallback) {
    DebugOnly<nsresult> rv = mCallback->OnCancel();
    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Unable to call onCancel() callback");
  }

  if (mStream) {
    mStream->ChangeExplicitBlockerCount(1);
    DispatchEndImpl(GetCurrentTime(), GetCurrentCharOffset());
  }
}
void
nsXFormsSwitchElement::Init(nsIDOMElement* aDeselected)
{
    nsCOMPtr<nsIDOMElement> firstCase = FindFirstSelectedCase(aDeselected);
    mSelected = firstCase;
    nsCOMPtr<nsIXFormsCaseElement> selected(do_QueryInterface(mSelected));
    if (selected) {
        nsresult rv = selected->SetSelected(PR_TRUE);

        // it is ok to fail if Init is called during the initialization phase since
        // XBL might not have attached on the xf:case, yet.
        // nsXFormsCaseElement::SetSelected will fail if it cannot QI the case
        // element to nsIXFormsCaseElementUI.
        NS_WARN_IF_FALSE(mAddingChildren || NS_SUCCEEDED(rv),
                         "Failed to select case");
    }
}
// helper to get the presentation data of a frame, by possibly walking up
// the frame hierarchy if we happen to be surrounded by non-MathML frames.
/* static */ void
nsMathMLFrame::GetPresentationDataFrom(nsIFrame*           aFrame,
                                       nsPresentationData& aPresentationData,
                                       bool                aClimbTree)
{
  // initialize OUT params
  aPresentationData.flags = 0;
  aPresentationData.baseFrame = nullptr;
  aPresentationData.mstyle = nullptr;

  nsIFrame* frame = aFrame;
  while (frame) {
    if (frame->IsFrameOfType(nsIFrame::eMathML)) {
      nsIMathMLFrame* mathMLFrame = do_QueryFrame(frame);
      if (mathMLFrame) {
        mathMLFrame->GetPresentationData(aPresentationData);
        break;
      }
    }
    // stop if the caller doesn't want to lookup beyond the frame
    if (!aClimbTree) {
      break;
    }
    // stop if we reach the root <math> tag
    nsIContent* content = frame->GetContent();
    NS_ASSERTION(content || !frame->GetParent(), // no assert for the root
                 "dangling frame without a content node"); 
    if (!content)
      break;

    if (content->Tag() == nsGkAtoms::math) {
      const nsStyleDisplay* display = frame->GetStyleDisplay();
      if (display->mDisplay == NS_STYLE_DISPLAY_BLOCK) {
        aPresentationData.flags |= NS_MATHML_DISPLAYSTYLE;
      }
      FindAttrDisplaystyle(content, aPresentationData);
      FindAttrDirectionality(content, aPresentationData);
      aPresentationData.mstyle = frame->GetFirstContinuation();
      break;
    }
    frame = frame->GetParent();
  }
  NS_WARN_IF_FALSE(frame && frame->GetContent(),
                   "bad MathML markup - could not find the top <math> element");
}
void
RPCChannel::DumpRPCStack(const char* const pfx) const
{
    NS_WARN_IF_FALSE(MessageLoop::current() != mWorkerLoop,
                     "The worker thread had better be paused in a debugger!");

    printf_stderr("%sRPCChannel 'backtrace':\n", pfx);

    // print a python-style backtrace, first frame to last
    for (uint32_t i = 0; i < mCxxStackFrames.size(); ++i) {
        int32_t id;
        const char* dir, *sems, *name;
        mCxxStackFrames[i].Describe(&id, &dir, &sems, &name);

        printf_stderr("%s[(%u) %s %s %s(actor=%d) ]\n", pfx,
                      i, dir, sems, name, id);
    }
}
nsresult
nsInProcessTabChildGlobal::Init()
{
#ifdef DEBUG
  nsresult rv =
#endif
  InitTabChildGlobal();
  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
                   "Couldn't initialize nsInProcessTabChildGlobal");
  mMessageManager = new nsFrameMessageManager(PR_FALSE,
                                              SendSyncMessageToParent,
                                              SendAsyncMessageToParent,
                                              nsnull,
                                              this,
                                              nsnull,
                                              mCx);
  return NS_OK;
}
void
nsSpeechTask::Cancel()
{
  MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);

  LOG(PR_LOG_DEBUG, ("nsSpeechTask::Cancel"));

  if (mCallback) {
    DebugOnly<nsresult> rv = mCallback->OnCancel();
    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Unable to call onCancel() callback");
  }

  if (mStream) {
    mStream->ChangeExplicitBlockerCount(1);
  }

  DispatchEndImpl(GetCurrentTime(), GetCurrentCharOffset());
}
Exemple #7
0
nsresult
nsQueryInterfaceWithError::operator()( const nsIID& aIID, void** answer ) const
	{
		nsresult status;
		if ( mRawPtr )
			{
				status = mRawPtr->QueryInterface(aIID, answer);
#ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS
				NS_WARN_IF_FALSE(NS_SUCCEEDED(status), "interface not found---were you expecting that?");
#endif
			}
		else
			status = NS_ERROR_NULL_POINTER;
		
		if ( mErrorPtr )
			*mErrorPtr = status;
		return status;
	}
void
nsSynthVoiceRegistry::Speak(const nsAString& aText,
                            const nsAString& aLang,
                            const nsAString& aUri,
                            const float& aVolume,
                            const float& aRate,
                            const float& aPitch,
                            nsSpeechTask* aTask)
{
  LOG(LogLevel::Debug,
      ("nsSynthVoiceRegistry::Speak text='%s' lang='%s' uri='%s' rate=%f pitch=%f",
       NS_ConvertUTF16toUTF8(aText).get(), NS_ConvertUTF16toUTF8(aLang).get(),
       NS_ConvertUTF16toUTF8(aUri).get(), aRate, aPitch));

  VoiceData* voice = FindBestMatch(aUri, aLang);

  if (!voice) {
    NS_WARNING("No voices found.");
    aTask->DispatchError(0, 0);
    return;
  }

  aTask->SetChosenVoiceURI(voice->mUri);

  LOG(LogLevel::Debug, ("nsSynthVoiceRegistry::Speak - Using voice URI: %s",
                     NS_ConvertUTF16toUTF8(voice->mUri).get()));

  SpeechServiceType serviceType;

  DebugOnly<nsresult> rv = voice->mService->GetServiceType(&serviceType);
  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to get speech service type");

  if (serviceType == nsISpeechService::SERVICETYPE_INDIRECT_AUDIO) {
    aTask->SetIndirectAudio(true);
  } else {
    if (!mStream) {
      mStream = MediaStreamGraph::GetInstance()->CreateTrackUnionStream(nullptr);
    }
    aTask->BindStream(mStream);
  }

  voice->mService->Speak(aText, voice->mUri, aVolume, aRate, aPitch, aTask);
}
Exemple #9
0
nsresult
LookupCache::WriteFile()
{
  nsCOMPtr<nsIFile> storeFile;
  nsresult rv = mStoreDirectory->Clone(getter_AddRefs(storeFile));
  NS_ENSURE_SUCCESS(rv, rv);
  rv = storeFile->AppendNative(mTableName + NS_LITERAL_CSTRING(CACHE_SUFFIX));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIOutputStream> out;
  rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(out), storeFile,
                                       PR_WRONLY | PR_TRUNCATE | PR_CREATE_FILE);
  NS_ENSURE_SUCCESS(rv, rv);

  UpdateHeader();
  LOG(("Writing %d completions", mHeader.numCompletions));

  uint32_t written;
  rv = out->Write(reinterpret_cast<char*>(&mHeader), sizeof(mHeader), &written);
  NS_ENSURE_SUCCESS(rv, rv);

  rv = WriteTArray(out, mCompletions);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsISafeOutputStream> safeOut = do_QueryInterface(out);
  rv = safeOut->Finish();
  NS_ENSURE_SUCCESS(rv, rv);

  rv = EnsureSizeConsistent();
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIFile> psFile;
  rv = mStoreDirectory->Clone(getter_AddRefs(psFile));
  NS_ENSURE_SUCCESS(rv, rv);

  rv = psFile->AppendNative(mTableName + NS_LITERAL_CSTRING(PREFIXSET_SUFFIX));
  NS_ENSURE_SUCCESS(rv, rv);

  rv = mPrefixSet->StoreToFile(psFile);
  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to store the prefixset");

  return NS_OK;
}
NS_IMETHODIMP
sbMockCDService::NotifyEject(sbICDDevice *aCDDevice)
{
  NS_ENSURE_ARG_POINTER(aCDDevice);

  // Ensure that a mock CD device was removed.
  nsresult rv;
  nsCOMPtr<sbIMockCDDevice> mockDevice = do_QueryInterface(aCDDevice, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  // Inform the listeners
  for (PRInt32 i = 0; i < mListeners.Count(); i++) {
    rv = mListeners[i]->OnMediaEjected(aCDDevice);
    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
        "Could not inform the listener of media eject!");
  }

  return NS_OK;
}
Exemple #11
0
/* static */
void
WinUtils::WaitForMessage()
{
  DWORD result = ::MsgWaitForMultipleObjectsEx(0, NULL, INFINITE, QS_ALLINPUT,
                                               MWMO_INPUTAVAILABLE);
  NS_WARN_IF_FALSE(result != WAIT_FAILED, "Wait failed");

  // This idiom is taken from the Chromium ipc code, see
  // ipc/chromium/src/base/message+puimp_win.cpp:270.
  // The intent is to avoid a busy wait when MsgWaitForMultipleObjectsEx
  // returns quickly but PeekMessage would not return a message.
  if (result == WAIT_OBJECT_0) {
    MSG msg = {0};
    DWORD queue_status = ::GetQueueStatus(QS_MOUSE);
    if (HIWORD(queue_status) & QS_MOUSE &&
        !PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE)) {
      ::WaitMessage();
    }
  }
}
void
nsSpeechTask::Resume()
{
  MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);

  if (!mUtterance->IsPaused()) {
    return;
  }

  if (mCallback) {
    DebugOnly<nsresult> rv = mCallback->OnResume();
    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Unable to call onResume() callback");
  }

  if (mStream) {
    mStream->ChangeExplicitBlockerCount(-1);
  }

  DispatchResumeImpl(GetCurrentTime(), GetCurrentCharOffset());
}
NS_IMETHODIMP
nsXTFElementWrapper::SetIntrinsicState(nsEventStates::InternalType aNewState)
{
  nsIDocument *doc = GetCurrentDoc();
  nsEventStates newStates(aNewState);
  nsEventStates bits = mIntrinsicState ^ newStates;

  if (!doc || bits.IsEmpty())
    return NS_OK;

  NS_WARN_IF_FALSE(!newStates.HasAllStates(NS_EVENT_STATE_MOZ_READONLY |
                                           NS_EVENT_STATE_MOZ_READWRITE),
                   "Both READONLY and READWRITE are being set.  Yikes!!!");

  mIntrinsicState = newStates;
  mozAutoDocUpdate upd(doc, UPDATE_CONTENT_STATE, PR_TRUE);
  doc->ContentStateChanged(this, bits);

  return NS_OK;
}
/**
 * Place below-current-line floats.
 */
PRBool
nsBlockReflowState::PlaceBelowCurrentLineFloats(nsFloatCacheFreeList& aList, PRBool aForceFit)
{
  nsFloatCache* fc = aList.Head();
  while (fc) {
    {
#ifdef DEBUG
      if (nsBlockFrame::gNoisyReflow) {
        nsFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent);
        printf("placing bcl float: ");
        nsFrame::ListTag(stdout, fc->mFloat);
        printf("\n");
      }
#endif
      // Place the float
      nsReflowStatus reflowStatus;
      PRBool placed = FlowAndPlaceFloat(fc->mFloat, reflowStatus, aForceFit);
      NS_ASSERTION(placed || !aForceFit,
                   "If we're in force-fit mode, we should have placed the float");

      if (!placed || (NS_FRAME_IS_TRUNCATED(reflowStatus) && !aForceFit)) {
        // return before processing all of the floats, since the line will be pushed.
        return PR_FALSE;
      }
      else if (!NS_FRAME_IS_FULLY_COMPLETE(reflowStatus)) {
        // Create a continuation for the incomplete float
        nsresult rv = mBlock->SplitFloat(*this, fc->mFloat, reflowStatus);
        if (NS_FAILED(rv))
          return PR_FALSE;
      } else {
        // XXX We could deal with truncated frames better by breaking before
        // the associated placeholder
        NS_WARN_IF_FALSE(!NS_FRAME_IS_TRUNCATED(reflowStatus),
                         "This situation currently leads to data not printing");
        // Float is complete.
      }
    }
    fc = fc->Next();
  }
  return PR_TRUE;
}
void
AudioCallbackDriver::MixerCallback(AudioDataValue* aMixedBuffer,
                                   AudioSampleFormat aFormat,
                                   uint32_t aChannels,
                                   uint32_t aFrames,
                                   uint32_t aSampleRate)
{
    uint32_t toWrite = mBuffer.Available();

    if (!mBuffer.Available()) {
        NS_WARNING("DataCallback buffer full, expect frame drops.");
    }

    MOZ_ASSERT(mBuffer.Available() <= aFrames);

    mBuffer.WriteFrames(aMixedBuffer, mBuffer.Available());
    MOZ_ASSERT(mBuffer.Available() == 0, "Missing frames to fill audio callback's buffer.");

    DebugOnly<uint32_t> written = mScratchBuffer.Fill(aMixedBuffer + toWrite * aChannels, aFrames - toWrite);
    NS_WARN_IF_FALSE(written == aFrames - toWrite, "Dropping frames.");
};
void
nsSpeechTask::Pause()
{
  MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);

  if (mUtterance->IsPaused() ||
      mUtterance->GetState() == SpeechSynthesisUtterance::STATE_ENDED) {
    return;
  }

  if (mCallback) {
    DebugOnly<nsresult> rv = mCallback->OnPause();
    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Unable to call onPause() callback");
  }

  if (mStream) {
    mStream->ChangeExplicitBlockerCount(1);
  }

  DispatchPauseImpl(GetCurrentTime(), GetCurrentCharOffset());
}
nsresult
sbDeviceFirmwareUpdater::PutRunningHandler(sbIDevice *aDevice, 
                                           sbIDeviceFirmwareHandler *aHandler)
{
  NS_ENSURE_ARG_POINTER(aDevice);
  NS_ENSURE_ARG_POINTER(aHandler);

  nsCOMPtr<sbIDeviceFirmwareHandler> handler;
  if(!mRunningHandlers.Get(aDevice, getter_AddRefs(handler))) {
    PRBool success = mRunningHandlers.Put(aDevice, aHandler);
    NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);
  }
#if defined PR_LOGGING
  else {
    NS_WARN_IF_FALSE(handler == aHandler, 
      "Attempting to replace a running firmware handler!");
  }
#endif

  return NS_OK;
}
// nsISimpleEnumerator implementation
NS_IMETHODIMP
sbMediaListEnumeratorWrapper::HasMoreElements(bool *aMore)
{
  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
  NS_ENSURE_TRUE(mEnumerator, NS_ERROR_NOT_INITIALIZED);
  
  nsAutoMonitor mon(mMonitor);
  nsresult rv = mEnumerator->HasMoreElements(aMore);
  NS_ENSURE_SUCCESS(rv, rv);

  if(mListener) {
    nsCOMPtr<nsISimpleEnumerator> grip(mEnumerator);
    nsCOMPtr<sbIMediaListEnumeratorWrapperListener> listener(mListener);
    mon.Exit();

    rv = listener->OnHasMoreElements(grip, *aMore);
    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "onHasMoreElements returned an error");
  }

  return NS_OK;
}
Exemple #19
0
void
nsSpeechTask::Pause()
{
  MOZ_ASSERT(XRE_IsParentProcess());

  if (mCallback) {
    DebugOnly<nsresult> rv = mCallback->OnPause();
    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Unable to call onPause() callback");
  }

  if (mStream) {
    mStream->Suspend();
  }

  if (!mInited) {
    mPrePaused = true;
  }

  if (!mIndirectAudio) {
    DispatchPauseImpl(GetCurrentTime(), GetCurrentCharOffset());
  }
}
PRInt32
nsSVGGradientFrame::GetStopFrame(PRInt32 aIndex, nsIFrame * *aStopFrame)
{
  PRInt32 stopCount = 0;
  nsIFrame *stopFrame = nsnull;
  for (stopFrame = mFrames.FirstChild(); stopFrame;
       stopFrame = stopFrame->GetNextSibling()) {
    if (stopFrame->GetType() == nsGkAtoms::svgStopFrame) {
      // Is this the one we're looking for?
      if (stopCount++ == aIndex)
        break; // Yes, break out of the loop
    }
  }
  if (stopCount > 0) {
    if (aStopFrame)
      *aStopFrame = stopFrame;
    return stopCount;
  }

  // Our gradient element doesn't have stops - try to "inherit" them

  nsSVGGradientFrame *next = GetReferencedGradient();
  if (!next) {
    if (aStopFrame)
      *aStopFrame = nsnull;
    return 0;
  }

  // Set mLoopFlag before checking mNextGrad->mLoopFlag in case we are mNextGrad
  mLoopFlag = PR_TRUE;
  // XXXjwatt: we should really send an error to the JavaScript Console here:
  NS_WARN_IF_FALSE(!next->mLoopFlag, "gradient reference loop detected "
                                     "while inheriting stop!");
  if (!next->mLoopFlag)
    stopCount = next->GetStopFrame(aIndex, aStopFrame);
  mLoopFlag = PR_FALSE;

  return stopCount;
}
void
nsDOMWorkerScriptLoader::Cancel()
{
  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

  NS_ASSERTION(!mCanceled, "Cancel called more than once!");
  mCanceled = PR_TRUE;

  for (PRUint32 index = 0; index < mScriptCount; index++) {
    ScriptLoadInfo& loadInfo = mLoadInfos[index];

    nsIRequest* request =
      static_cast<nsIRequest*>(loadInfo.channel.get());
    if (request) {
#ifdef DEBUG
      nsresult rv =
#endif
      request->Cancel(NS_BINDING_ABORTED);
      NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to cancel channel!");
    }
  }

  nsAutoTArray<ScriptLoaderRunnable*, 10> runnables;
  {
    nsAutoLock lock(mWorker->Lock());
    runnables.AppendElements(mPendingRunnables);
    mPendingRunnables.Clear();
  }

  PRUint32 runnableCount = runnables.Length();
  for (PRUint32 index = 0; index < runnableCount; index++) {
    runnables[index]->Revoke();
  }

  // We're about to post a revoked event to the worker thread, which seems
  // silly, but we have to do this because the worker thread may be sleeping
  // waiting on its event queue.
  NotifyDone();
}
// ----------------------------------------------------------------------------
// nsIObserver
// ----------------------------------------------------------------------------
NS_IMETHODIMP
sbDeviceFirmwareUpdater::Observe(nsISupports* aSubject,
                                 const char* aTopic,
                                 const PRUnichar* aData)
{
  LOG(("[sbDeviceFirmwareUpdater] - Observe: %s", this, aTopic));

  nsresult rv;
  nsCOMPtr<nsIObserverService> observerService =
    do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  if (strcmp(aTopic, SB_LIBRARY_MANAGER_SHUTDOWN_TOPIC) == 0) {
    rv = observerService->RemoveObserver(this, SB_LIBRARY_MANAGER_SHUTDOWN_TOPIC);
    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to remove shutdown observer");

    rv = Shutdown();
    NS_ENSURE_SUCCESS(rv, rv);
  }

  return NS_OK;
}
NS_IMETHODIMP
sbWindowMoveService::StartWatchingWindow(nsISupports *aWindow,
                                         sbIWindowMoveListener *aListener)
{
  NS_ENSURE_ARG_POINTER(aWindow);
  NS_ENSURE_ARG_POINTER(aListener);
  
  NS_WARN_IF_FALSE(NS_IsMainThread(), "This service is MAIN THREAD ONLY!");

  HWND windowHandle = NULL;
  
  windowHandle = NativeWindowFromNode::get(aWindow);
  NS_ENSURE_TRUE(windowHandle, NS_ERROR_INVALID_ARG);

  // Already hooked. Can only hook once.
  if(IsHooked(windowHandle)) {
    NS_WARNING("Window already hooked. Can only hook a window once.");
    return NS_OK;
  }

  BOOL success = ::SetPropW(windowHandle, PROP_WMS_INST, (HANDLE) this);
  NS_ENSURE_TRUE(success != 0, NS_ERROR_UNEXPECTED);

  HHOOK hookHandle = ::SetWindowsHookEx(WH_CALLWNDPROC, 
                                        sbWindowMoveService::CallWndProc,
                                        NULL,
                                        ::GetCurrentThreadId());
  NS_ENSURE_TRUE(hookHandle, NS_ERROR_FAILURE);

  nsCOMPtr<sbIWindowMoveListener> listener(aListener);
  mListeners.insert(
    std::make_pair<HWND, nsCOMPtr<sbIWindowMoveListener> >(windowHandle, 
                                                           listener));

  mHooks.insert(std::make_pair<HWND, HHOOK>(windowHandle, hookHandle));

  return NS_OK;
}
Exemple #24
0
static PLDHashOperator
PicoAddVoiceTraverser(const nsAString& aUri,
                      nsRefPtr<PicoVoice>& aVoice,
                      void* aUserArg)
{
  // If we are missing either a language or a voice resource, it is invalid.
  if (aVoice->mTaFile.IsEmpty() || aVoice->mSgFile.IsEmpty()) {
    return PL_DHASH_REMOVE;
  }

  VoiceTraverserData* data = static_cast<VoiceTraverserData*>(aUserArg);

  nsAutoString name;
  name.AssignLiteral("Pico ");
  name.Append(aVoice->mLanguage);

  DebugOnly<nsresult> rv =
    data->mRegistry->AddVoice(
      data->mService, aUri, name, aVoice->mLanguage, true);
  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to add voice");

  return PL_DHASH_NEXT;
}
Exemple #25
0
void
nsSpeechTask::Resume()
{
  MOZ_ASSERT(XRE_IsParentProcess());

  if (mCallback) {
    DebugOnly<nsresult> rv = mCallback->OnResume();
    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Unable to call onResume() callback");
  }

  if (mStream) {
    mStream->Resume();
  }

  if (mPrePaused) {
    mPrePaused = false;
    nsSynthVoiceRegistry::GetInstance()->ResumeQueue();
  }

  if (!mIndirectAudio) {
    DispatchResumeImpl(GetCurrentTime(), GetCurrentCharOffset());
  }
}
nsSVGGradientElement *
nsSVGGradientFrame::GetGradientWithAttr(nsIAtom *aAttrName, nsIContent *aDefault)
{
  if (mContent->HasAttr(kNameSpaceID_None, aAttrName))
    return static_cast<nsSVGGradientElement *>(mContent);

  nsSVGGradientElement *grad = static_cast<nsSVGGradientElement *>(aDefault);

  nsSVGGradientFrame *next = GetReferencedGradient();
  if (!next)
    return grad;

  // Set mLoopFlag before checking mNextGrad->mLoopFlag in case we are mNextGrad
  mLoopFlag = PR_TRUE;
  // XXXjwatt: we should really send an error to the JavaScript Console here:
  NS_WARN_IF_FALSE(!next->mLoopFlag, "gradient reference loop detected "
                                     "while inheriting attribute!");
  if (!next->mLoopFlag)
    grad = next->GetGradientWithAttr(aAttrName, aDefault);
  mLoopFlag = PR_FALSE;

  return grad;
}
Exemple #27
0
// helper to get the presentation data of a frame, by possibly walking up
// the frame hierarchy if we happen to be surrounded by non-MathML frames.
/* static */ void
nsMathMLFrame::GetPresentationDataFrom(nsIFrame*           aFrame,
                                       nsPresentationData& aPresentationData,
                                       bool                aClimbTree)
{
  // initialize OUT params
  aPresentationData.flags = 0;
  aPresentationData.baseFrame = nullptr;

  nsIFrame* frame = aFrame;
  while (frame) {
    if (frame->IsFrameOfType(nsIFrame::eMathML)) {
      nsIMathMLFrame* mathMLFrame = do_QueryFrame(frame);
      if (mathMLFrame) {
        mathMLFrame->GetPresentationData(aPresentationData);
        break;
      }
    }
    // stop if the caller doesn't want to lookup beyond the frame
    if (!aClimbTree) {
      break;
    }
    // stop if we reach the root <math> tag
    nsIContent* content = frame->GetContent();
    NS_ASSERTION(content || !frame->GetParent(), // no assert for the root
                 "dangling frame without a content node"); 
    if (!content)
      break;

    if (content->Tag() == nsGkAtoms::math) {
      break;
    }
    frame = frame->GetParent();
  }
  NS_WARN_IF_FALSE(frame && frame->GetContent(),
                   "bad MathML markup - could not find the top <math> element");
}
Exemple #28
0
void
HTMLVideoElement::UpdateScreenWakeLock()
{
  bool hidden = OwnerDoc()->Hidden();

  if (mScreenWakeLock && (mPaused || hidden)) {
    ErrorResult rv;
    mScreenWakeLock->Unlock(rv);
    NS_WARN_IF_FALSE(!rv.Failed(), "Failed to unlock the wakelock.");
    mScreenWakeLock = nullptr;
    return;
  }

  if (!mScreenWakeLock && !mPaused && !hidden && HasVideo()) {
    nsRefPtr<power::PowerManagerService> pmService =
      power::PowerManagerService::GetInstance();
    NS_ENSURE_TRUE_VOID(pmService);

    ErrorResult rv;
    mScreenWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("screen"),
                                             OwnerDoc()->GetInnerWindow(),
                                             rv);
  }
}
Exemple #29
0
void
nsSpeechTask::Cancel()
{
  MOZ_ASSERT(XRE_IsParentProcess());

  LOG(LogLevel::Debug, ("nsSpeechTask::Cancel"));

  if (mCallback) {
    DebugOnly<nsresult> rv = mCallback->OnCancel();
    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Unable to call onCancel() callback");
  }

  if (mStream) {
    mStream->Suspend();
  }

  if (!mInited) {
    mPreCanceled = true;
  }

  if (!mIndirectAudio) {
    DispatchEndInner(GetCurrentTime(), GetCurrentCharOffset());
  }
}
Exemple #30
0
uint32_t
AudioSink::PlayFromAudioQueue()
{
  AssertOnAudioThread();
  NS_ASSERTION(!mAudioStream->IsPaused(), "Don't play when paused");
  nsAutoPtr<AudioData> audio(AudioQueue().PopFront());
  {
    ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
    NS_WARN_IF_FALSE(mPlaying, "Should be playing");
    // Awaken the decode loop if it's waiting for space to free up in the
    // audio queue.
    GetReentrantMonitor().NotifyAll();
  }
  SINK_LOG_V("playing %u frames of audio at time %lld",
             this, audio->mFrames, audio->mTime);
  mAudioStream->Write(audio->mAudioData, audio->mFrames);

  StartAudioStreamPlaybackIfNeeded();

  if (audio->mOffset != -1) {
    mStateMachine->OnPlaybackOffsetUpdate(audio->mOffset);
  }
  return audio->mFrames;
}