Ejemplo n.º 1
0
void
FontFace::InitializeSource(const StringOrArrayBufferOrArrayBufferView& aSource)
{
  if (aSource.IsString()) {
    if (!ParseDescriptor(eCSSFontDesc_Src,
                         aSource.GetAsString(),
                         mDescriptors->mSrc)) {
      Reject(NS_ERROR_DOM_SYNTAX_ERR);

      SetStatus(FontFaceLoadStatus::Error);
      return;
    }

    mSourceType = eSourceType_URLs;
    return;
  }

  mSourceType = FontFace::eSourceType_Buffer;

  if (aSource.IsArrayBuffer()) {
    GetDataFrom(aSource.GetAsArrayBuffer(),
                mSourceBuffer, mSourceBufferLength);
  } else {
    MOZ_ASSERT(aSource.IsArrayBufferView());
    GetDataFrom(aSource.GetAsArrayBufferView(),
                mSourceBuffer, mSourceBufferLength);
  }

  SetStatus(FontFaceLoadStatus::Loading);
  DoLoad();
}
Ejemplo n.º 2
0
void
FontFace::InitializeSource(const StringOrArrayBufferOrArrayBufferView& aSource)
{
  if (aSource.IsString()) {
    if (!ParseDescriptor(eCSSFontDesc_Src,
                         aSource.GetAsString(),
                         mDescriptors->mSrc)) {
      if (mLoaded) {
        // The SetStatus call we are about to do assumes that for
        // FontFace objects with sources other than ArrayBuffer(View)s, that the
        // mLoaded Promise is rejected with a network error.  We get
        // in here beforehand to set it to the required syntax error.
        mLoaded->MaybeReject(NS_ERROR_DOM_SYNTAX_ERR);
      }

      SetStatus(FontFaceLoadStatus::Error);
      return;
    }

    mSourceType = eSourceType_URLs;
    return;
  }

  mSourceType = FontFace::eSourceType_Buffer;

  if (aSource.IsArrayBuffer()) {
    GetDataFrom(aSource.GetAsArrayBuffer(),
                mSourceBuffer, mSourceBufferLength);
  } else {
    MOZ_ASSERT(aSource.IsArrayBufferView());
    GetDataFrom(aSource.GetAsArrayBufferView(),
                mSourceBuffer, mSourceBufferLength);
  }

  SetStatus(FontFaceLoadStatus::Loading);
  DoLoad();
}
Ejemplo n.º 3
0
void
FontFaceInitializer::SetSource(const ArrayBufferView& aArrayBufferView)
{
  mSourceType = FontFace::eSourceType_Buffer;
  GetDataFrom(aArrayBufferView, mSourceBuffer, mSourceBufferLength);
}