EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod2(ExecState* state) { JSValue thisValue = state->thisValue(); auto castedThis = jsDynamicCast<JSTestInterface*>(thisValue); if (UNLIKELY(!castedThis)) return throwThisTypeError(*state, "TestInterface", "supplementalMethod2"); ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestInterface::info()); auto& impl = castedThis->wrapped(); if (UNLIKELY(state->argumentCount() < 2)) return throwVMError(state, createNotEnoughArgumentsError(state)); ExceptionCode ec = 0; auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); if (!context) return JSValue::encode(jsUndefined()); auto strArg = state->argument(0).toWTFString(state); if (UNLIKELY(state->hadException())) return JSValue::encode(jsUndefined()); auto objArg = JSTestObj::toWrapped(state->argument(1)); if (UNLIKELY(!objArg)) return throwArgumentTypeError(*state, 1, "objArg", "TestInterface", "supplementalMethod2", "TestObj"); JSValue result = toJS(state, castedThis->globalObject(), WebCore::TestSupplemental::supplementalMethod2(impl, *context, WTFMove(strArg), *objArg, ec)); setDOMException(state, ec); return JSValue::encode(result); }
JSValue JSDocument::createTouchList(ExecState& state) { auto touchList = TouchList::create(); for (size_t i = 0; i < state.argumentCount(); ++i) { auto* item = JSTouch::toWrapped(state.uncheckedArgument(i)); if (!item) return JSValue::decode(throwArgumentTypeError(state, i, "touches", "Document", "createTouchList", "Touch")); touchList->append(*item); } return toJSNewlyCreated(&state, globalObject(), WTFMove(touchList)); }
EncodedJSValue JSC_HOST_CALL constructJSMutationObserver(ExecState& exec) { VM& vm = exec.vm(); auto scope = DECLARE_THROW_SCOPE(vm); if (exec.argumentCount() < 1) return throwVMError(&exec, scope, createNotEnoughArgumentsError(&exec)); JSObject* object = exec.uncheckedArgument(0).getObject(); CallData callData; if (!object || object->methodTable()->getCallData(object, callData) == CallType::None) return throwArgumentTypeError(exec, scope, 0, "callback", "MutationObserver", nullptr, "MutationCallback"); DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.jsCallee()); auto callback = JSMutationCallback::create(object, jsConstructor->globalObject()); JSObject* jsObserver = asObject(toJSNewlyCreated(&exec, jsConstructor->globalObject(), MutationObserver::create(WTFMove(callback)))); PrivateName propertyName; jsObserver->putDirect(vm, propertyName, object); return JSValue::encode(jsObserver); }
static inline JSC::EncodedJSValue jsTestActiveDOMObjectPrototypeFunctionExcitingFunctionBody(JSC::ExecState* state, typename IDLOperation<JSTestActiveDOMObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope) { UNUSED_PARAM(state); UNUSED_PARAM(throwScope); if (!BindingSecurity::shouldAllowAccessToDOMWindow(state, castedThis->wrapped().window(), ThrowSecurityError)) return JSValue::encode(jsUndefined()); auto& impl = castedThis->wrapped(); if (UNLIKELY(state->argumentCount() < 1)) return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); auto nextChild = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "nextChild", "TestActiveDOMObject", "excitingFunction", "Node"); }); RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); impl.excitingFunction(*nextChild); return JSValue::encode(jsUndefined()); }