本文整理汇总了C++中ExecState::thisValue方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecState::thisValue方法的具体用法?C++ ExecState::thisValue怎么用?C++ ExecState::thisValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecState
的用法示例。
在下文中一共展示了ExecState::thisValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSettings
JSC::JSValue JSMediaStreamTrack::getSettings(ExecState& state)
{
JSValue thisValue = state.thisValue();
JSMediaStreamTrack* castedThis = jsDynamicCast<JSMediaStreamTrack*>(thisValue);
if (UNLIKELY(!castedThis))
return JSValue::decode(throwThisTypeError(state, "MediaStreamTrack", "getSettings"));
JSObject* object = constructEmptyObject(&state);
auto& impl = castedThis->wrapped();
RefPtr<MediaSourceSettings> settings = WTF::getPtr(impl.getSettings());
if (settings->supportsWidth())
object->putDirect(state.vm(), Identifier::fromString(&state, "width"), jsNumber(settings->width()), DontDelete | ReadOnly);
if (settings->supportsHeight())
object->putDirect(state.vm(), Identifier::fromString(&state, "height"), jsNumber(settings->height()), DontDelete | ReadOnly);
if (settings->supportsAspectRatio())
object->putDirect(state.vm(), Identifier::fromString(&state, "aspectRatio"), jsDoubleNumber(settings->aspectRatio()), DontDelete | ReadOnly);
if (settings->supportsFrameRate())
object->putDirect(state.vm(), Identifier::fromString(&state, "frameRate"), jsDoubleNumber(settings->frameRate()), DontDelete | ReadOnly);
if (settings->supportsFacingMode())
object->putDirect(state.vm(), Identifier::fromString(&state, "facingMode"), jsStringWithCache(&state, settings->facingMode()), DontDelete | ReadOnly);
if (settings->supportsVolume())
object->putDirect(state.vm(), Identifier::fromString(&state, "volume"), jsDoubleNumber(settings->volume()), DontDelete | ReadOnly);
if (settings->supportsSampleRate())
object->putDirect(state.vm(), Identifier::fromString(&state, "sampleRate"), jsNumber(settings->sampleRate()), DontDelete | ReadOnly);
if (settings->supportsSampleSize())
object->putDirect(state.vm(), Identifier::fromString(&state, "sampleSize"), jsNumber(settings->sampleSize()), DontDelete | ReadOnly);
if (settings->supportsEchoCancellation())
object->putDirect(state.vm(), Identifier::fromString(&state, "echoCancellation"), jsBoolean(settings->echoCancellation()), DontDelete | ReadOnly);
if (settings->supportsDeviceId())
object->putDirect(state.vm(), Identifier::fromString(&state, "deviceId"), jsStringWithCache(&state, settings->deviceId()), DontDelete | ReadOnly);
if (settings->supportsGroupId())
object->putDirect(state.vm(), Identifier::fromString(&state, "groupId"), jsStringWithCache(&state, settings->groupId()), DontDelete | ReadOnly);
return object;
}
示例2: constructJSHTMLElement
EncodedJSValue JSC_HOST_CALL constructJSHTMLElement(ExecState& exec)
{
VM& vm = exec.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
auto* jsConstructor = jsCast<JSDOMConstructorBase*>(exec.jsCallee());
ASSERT(jsConstructor);
auto* context = jsConstructor->scriptExecutionContext();
if (!context)
return throwConstructorScriptExecutionContextUnavailableError(exec, scope, "HTMLElement");
ASSERT(context->isDocument());
JSValue newTargetValue = exec.thisValue();
auto* newTarget = newTargetValue.getObject();
auto* globalObject = jsCast<JSDOMGlobalObject*>(newTarget->globalObject(vm));
JSValue htmlElementConstructorValue = JSHTMLElement::getConstructor(vm, globalObject);
if (newTargetValue == htmlElementConstructorValue)
return throwVMTypeError(&exec, scope, "new.target is not a valid custom element constructor"_s);
auto& document = downcast<Document>(*context);
auto* window = document.domWindow();
if (!window)
return throwVMTypeError(&exec, scope, "new.target is not a valid custom element constructor"_s);
auto* registry = window->customElementRegistry();
if (!registry)
return throwVMTypeError(&exec, scope, "new.target is not a valid custom element constructor"_s);
auto* elementInterface = registry->findInterface(newTarget);
if (!elementInterface)
return throwVMTypeError(&exec, scope, "new.target does not define a custom element"_s);
if (!elementInterface->isUpgradingElement()) {
Structure* baseStructure = getDOMStructure<JSHTMLElement>(vm, *globalObject);
auto* newElementStructure = InternalFunction::createSubclassStructure(&exec, newTargetValue, baseStructure);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
Ref<HTMLElement> element = HTMLElement::create(elementInterface->name(), document);
element->setIsDefinedCustomElement(*elementInterface);
auto* jsElement = JSHTMLElement::create(newElementStructure, globalObject, element.get());
cacheWrapper(globalObject->world(), element.ptr(), jsElement);
return JSValue::encode(jsElement);
}
Element* elementToUpgrade = elementInterface->lastElementInConstructionStack();
if (!elementToUpgrade) {
throwInvalidStateError(exec, scope, "Cannot instantiate a custom element inside its own constructor during upgrades"_s);
return JSValue::encode(jsUndefined());
}
JSValue elementWrapperValue = toJS(&exec, jsConstructor->globalObject(), *elementToUpgrade);
ASSERT(elementWrapperValue.isObject());
JSValue newPrototype = newTarget->get(&exec, vm.propertyNames->prototype);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSObject* elementWrapperObject = asObject(elementWrapperValue);
JSObject::setPrototype(elementWrapperObject, &exec, newPrototype, true /* shouldThrowIfCantSet */);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
elementInterface->didUpgradeLastElementInConstructionStack();
return JSValue::encode(elementWrapperValue);
}