void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptionState) { WTF_LOG(Media, "SourceBuffer::setMode %p newMode=%s", this, newMode.utf8().data()); // Section 3.1 On setting mode attribute steps. // 1. Let new mode equal the new value being assigned to this attribute. // 2. If this object has been removed from the sourceBuffers attribute of the parent media source, then throw // an INVALID_STATE_ERR exception and abort these steps. // 3. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps. if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionState)) return; // 4. If the readyState attribute of the parent media source is in the "ended" state then run the following steps: // 4.1 Set the readyState attribute of the parent media source to "open" // 4.2 Queue a task to fire a simple event named sourceopen at the parent media source. m_source->openIfInEndedState(); // 5. If the append state equals PARSING_MEDIA_SEGMENT, then throw an INVALID_STATE_ERR and abort these steps. // 6. If the new mode equals "sequence", then set the group start timestamp to the highest presentation end timestamp. WebSourceBuffer::AppendMode appendMode = WebSourceBuffer::AppendModeSegments; if (newMode == sequenceKeyword()) appendMode = WebSourceBuffer::AppendModeSequence; if (!m_webSourceBuffer->setMode(appendMode)) { MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "The mode may not be set while the SourceBuffer's append state is 'PARSING_MEDIA_SEGMENT'."); return; } // 7. Update the attribute to new mode. m_mode = newMode; }
static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Value>& info) { const CString& nameInUtf8 = name.utf8(); ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext, "TestInterface2", nameInUtf8.data()); TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); TestInterfaceEmpty* result = impl->namedItem(name, exceptionState); if (!result) return; v8SetReturnValueFast(info, result, impl); }
static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Integer>& info) { const CString& nameInUtf8 = name.utf8(); ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext, "TestSpecialOperations", nameInUtf8.data()); TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder()); bool result = impl->namedPropertyQuery(name, exceptionState); if (!result) return; v8SetReturnValueInt(info, v8::None); }
static void namedPropertyDeleter(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { const CString& nameInUtf8 = name.utf8(); ExceptionState exceptionState(info.GetIsolate(), ExceptionState::DeletionContext, "TestInterface2", nameInUtf8.data()); TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); DeleteResult result = impl->deleteNamedItem(name, exceptionState); if (exceptionState.hadException()) return; if (result == DeleteUnknownProperty) return; v8SetReturnValue(info, result == DeleteSuccess); }
static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { const CString& nameInUtf8 = name.utf8(); ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface2", nameInUtf8.data()); TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); TestInterfaceEmpty* propertyValue = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), v8Value); if (!propertyValue && !isUndefinedOrNull(v8Value)) { exceptionState.throwTypeError("The provided value is not of type 'TestInterfaceEmpty'."); return; } bool result = impl->setNamedItem(name, propertyValue, exceptionState); if (exceptionState.hadException()) return; if (!result) return; v8SetReturnValue(info, v8Value); }
sk_sp<SkTypeface> FontCache::createTypeface( const FontDescription& fontDescription, const FontFaceCreationParams& creationParams, CString& name) { AtomicString family = creationParams.family(); if (family.isEmpty()) { name = getFallbackFontFamily(fontDescription).string().utf8(); } else { name = family.utf8(); } fonts::FontRequest request; request.family = name.data(); request.weight = ToIntegerWeight(fontDescription.weight()); request.width = static_cast<uint32_t>(fontDescription.stretch()); request.slant = ToFontSlant(fontDescription.style()); fonts::FontResponsePtr response; auto& font_provider = GetFontProvider(); font_provider->GetFont( std::move(request), [&response](fonts::FontResponsePtr r) { response = std::move(r); }); font_provider.WaitForResponse(); FXL_DCHECK(response) << "Unable to contact the font provider. Did you run " "Flutter in an environment that has a font manager?\n" "See <https://fuchsia.googlesource.com/modular/+/master/README.md>."; if (!response) return nullptr; sk_sp<SkData> data = MakeSkDataFromBuffer(response->data.buffer); if (!data) return nullptr; return SkFontMgr::RefDefault()->makeFromData(std::move(data)); }