void V8StringOrArrayBufferOrArrayBufferView::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrArrayBufferOrArrayBufferView& impl, UnionTypeConversionMode conversionMode, ExceptionState& exceptionState) { if (v8Value.IsEmpty()) return; if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull(v8Value)) return; if (V8ArrayBuffer::hasInstance(v8Value, isolate)) { TestArrayBuffer* cppValue = V8ArrayBuffer::toImpl(v8::Local<v8::Object>::Cast(v8Value)); impl.setArrayBuffer(cppValue); return; } if (V8ArrayBufferView::hasInstance(v8Value, isolate)) { TestArrayBufferView* cppValue = V8ArrayBufferView::toImpl(v8::Local<v8::Object>::Cast(v8Value)); impl.setArrayBufferView(cppValue); return; } { V8StringResource<> cppValue = v8Value; if (!cppValue.prepare(exceptionState)) return; impl.setString(cppValue); return; } }
v8::Local<v8::Value> toV8(const StringOrArrayBufferOrArrayBufferView& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) { switch (impl.m_type) { case StringOrArrayBufferOrArrayBufferView::SpecificTypeNone: return v8::Null(isolate); case StringOrArrayBufferOrArrayBufferView::SpecificTypeString: return v8String(isolate, impl.getAsString()); case StringOrArrayBufferOrArrayBufferView::SpecificTypeArrayBuffer: return toV8(impl.getAsArrayBuffer(), creationContext, isolate); case StringOrArrayBufferOrArrayBufferView::SpecificTypeArrayBufferView: return toV8(impl.getAsArrayBufferView(), creationContext, isolate); default: ASSERT_NOT_REACHED(); } return v8::Local<v8::Value>(); }
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(); }
PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString& family, StringOrArrayBufferOrArrayBufferView& source, const FontFaceDescriptors& descriptors) { if (source.isString()) return create(context, family, source.getAsString(), descriptors); if (source.isArrayBuffer()) return create(context, family, source.getAsArrayBuffer(), descriptors); if (source.isArrayBufferView()) return create(context, family, source.getAsArrayBufferView(), descriptors); ASSERT_NOT_REACHED(); return nullptr; }
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(); }
StringOrArrayBufferOrArrayBufferView StringOrArrayBufferOrArrayBufferView::fromArrayBufferView(TestArrayBufferView* value) { StringOrArrayBufferOrArrayBufferView container; container.setArrayBufferView(value); return container; }
StringOrArrayBufferOrArrayBufferView StringOrArrayBufferOrArrayBufferView::fromString(String value) { StringOrArrayBufferOrArrayBufferView container; container.setString(value); return container; }