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(); }
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(); }