/* THIS FILE IS AUTOGENERATED FROM UserInteraction.webidl BY Codegen.py - DO NOT EDIT */ #include #include "MainThreadUtils.h" #include "UserInteractionBinding.h" #include "WrapperFactory.h" #include "js/CallAndConstruct.h" #include "js/Exception.h" #include "js/MapAndSet.h" #include "js/Object.h" #include "js/PropertyAndElement.h" #include "js/PropertyDescriptor.h" #include "js/experimental/JitInfo.h" #include "mozilla/Atomics.h" #include "mozilla/OwningNonNull.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/dom/BindingCallContext.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/DOMJSClass.h" #include "mozilla/dom/NonRefcountedDOMObject.h" #include "mozilla/dom/Nullable.h" #include "mozilla/dom/PrimitiveConversions.h" #include "mozilla/dom/XrayExpandoClass.h" #include "mozilla/telemetry/Stopwatch.h" #include "nsContentUtils.h" namespace mozilla::dom { namespace binding_detail {}; // Just to make sure it's known as a namespace using namespace mozilla::dom::binding_detail; namespace UserInteraction_Binding { MOZ_CAN_RUN_SCRIPT static bool start(JSContext* cx_, unsigned argc, JS::Value* vp) { BindingCallContext cx(cx_, "UserInteraction.start"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "UserInteraction", "start", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::Rooted obj(cx, &args.callee()); if (!args.requireAtLeast(cx, "UserInteraction.start", 2)) { return false; } GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); if (global.Failed()) { return false; } nsAutoString arg0; if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { return false; } nsAutoCString arg1; if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { return false; } JS::Rooted arg2(cx); if (args.hasDefined(2)) { if (args[2].isObject()) { arg2 = &args[2].toObject(); } else if (args[2].isNullOrUndefined()) { arg2 = nullptr; } else { cx.ThrowErrorMessage("Argument 3"); return false; } } else { arg2 = nullptr; } bool result(mozilla::telemetry::UserInteractionStopwatch::Start(global, NonNullHelper(Constify(arg0)), Constify(arg1), arg2)); MOZ_ASSERT(!JS_IsExceptionPending(cx)); args.rval().setBoolean(result); return true; } MOZ_CAN_RUN_SCRIPT static bool update(JSContext* cx_, unsigned argc, JS::Value* vp) { BindingCallContext cx(cx_, "UserInteraction.update"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "UserInteraction", "update", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::Rooted obj(cx, &args.callee()); if (!args.requireAtLeast(cx, "UserInteraction.update", 2)) { return false; } GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); if (global.Failed()) { return false; } nsAutoString arg0; if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { return false; } nsAutoCString arg1; if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { return false; } JS::Rooted arg2(cx); if (args.hasDefined(2)) { if (args[2].isObject()) { arg2 = &args[2].toObject(); } else if (args[2].isNullOrUndefined()) { arg2 = nullptr; } else { cx.ThrowErrorMessage("Argument 3"); return false; } } else { arg2 = nullptr; } bool result(mozilla::telemetry::UserInteractionStopwatch::Update(global, NonNullHelper(Constify(arg0)), Constify(arg1), arg2)); MOZ_ASSERT(!JS_IsExceptionPending(cx)); args.rval().setBoolean(result); return true; } MOZ_CAN_RUN_SCRIPT static bool cancel(JSContext* cx_, unsigned argc, JS::Value* vp) { BindingCallContext cx(cx_, "UserInteraction.cancel"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "UserInteraction", "cancel", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::Rooted obj(cx, &args.callee()); if (!args.requireAtLeast(cx, "UserInteraction.cancel", 1)) { return false; } GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); if (global.Failed()) { return false; } nsAutoString arg0; if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { return false; } JS::Rooted arg1(cx); if (args.hasDefined(1)) { if (args[1].isObject()) { arg1 = &args[1].toObject(); } else if (args[1].isNullOrUndefined()) { arg1 = nullptr; } else { cx.ThrowErrorMessage("Argument 2"); return false; } } else { arg1 = nullptr; } bool result(mozilla::telemetry::UserInteractionStopwatch::Cancel(global, NonNullHelper(Constify(arg0)), arg1)); MOZ_ASSERT(!JS_IsExceptionPending(cx)); args.rval().setBoolean(result); return true; } MOZ_CAN_RUN_SCRIPT static bool running(JSContext* cx_, unsigned argc, JS::Value* vp) { BindingCallContext cx(cx_, "UserInteraction.running"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "UserInteraction", "running", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::Rooted obj(cx, &args.callee()); if (!args.requireAtLeast(cx, "UserInteraction.running", 1)) { return false; } GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); if (global.Failed()) { return false; } nsAutoString arg0; if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { return false; } JS::Rooted arg1(cx); if (args.hasDefined(1)) { if (args[1].isObject()) { arg1 = &args[1].toObject(); } else if (args[1].isNullOrUndefined()) { arg1 = nullptr; } else { cx.ThrowErrorMessage("Argument 2"); return false; } } else { arg1 = nullptr; } bool result(mozilla::telemetry::UserInteractionStopwatch::Running(global, NonNullHelper(Constify(arg0)), arg1)); MOZ_ASSERT(!JS_IsExceptionPending(cx)); args.rval().setBoolean(result); return true; } MOZ_CAN_RUN_SCRIPT static bool finish(JSContext* cx_, unsigned argc, JS::Value* vp) { BindingCallContext cx(cx_, "UserInteraction.finish"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "UserInteraction", "finish", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::Rooted obj(cx, &args.callee()); if (!args.requireAtLeast(cx, "UserInteraction.finish", 1)) { return false; } GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); if (global.Failed()) { return false; } nsAutoString arg0; if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { return false; } JS::Rooted arg1(cx); if (args.hasDefined(1)) { if (args[1].isObject()) { arg1 = &args[1].toObject(); } else if (args[1].isNullOrUndefined()) { arg1 = nullptr; } else { cx.ThrowErrorMessage("Argument 2"); return false; } } else { arg1 = nullptr; } Optional arg2; nsAutoCString arg2_holder; if (args.hasDefined(2)) { if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2_holder)) { return false; } arg2 = &arg2_holder; } bool result(mozilla::telemetry::UserInteractionStopwatch::Finish(global, NonNullHelper(Constify(arg0)), arg1, Constify(arg2))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); args.rval().setBoolean(result); return true; } MOZ_GLOBINIT static const JSFunctionSpec sStaticMethods_specs[] = { JS_FNSPEC("start", start, nullptr, 2, JSPROP_ENUMERATE, nullptr), JS_FNSPEC("update", update, nullptr, 2, JSPROP_ENUMERATE, nullptr), JS_FNSPEC("cancel", cancel, nullptr, 1, JSPROP_ENUMERATE, nullptr), JS_FNSPEC("running", running, nullptr, 1, JSPROP_ENUMERATE, nullptr), JS_FNSPEC("finish", finish, nullptr, 1, JSPROP_ENUMERATE, nullptr), JS_FS_END }; static const Prefable sStaticMethods[] = { { nullptr, &sStaticMethods_specs[0] }, { nullptr, nullptr } }; static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); static uint16_t sNativeProperties_sortedPropertyIndices[5]; static PropertyInfo sNativeProperties_propertyInfos[5]; static const NativePropertiesN<1> sNativeProperties = { true, 0 /* sStaticMethods */, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, -1, 5, sNativeProperties_sortedPropertyIndices, { { sStaticMethods, &sNativeProperties_propertyInfos[0] } } }; static_assert(5 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount)), "We have a property info count that is oversized"); bool sNativePropertiesInited = false; const NativePropertyHooks sNativePropertyHooks = { nullptr, { sNativeProperties.Upcast(), nullptr, &sNativePropertiesInited }, prototypes::id::_ID_Count, constructors::id::UserInteraction, &DefaultXrayExpandoObjectClass }; static const DOMIfaceAndProtoJSClass sNamespaceObjectClass = { { "UserInteraction", JSCLASS_IS_DOMIFACEANDPROTOJSCLASS, JS_NULL_CLASS_OPS, JS_NULL_CLASS_SPEC, JS_NULL_CLASS_EXT, JS_NULL_OBJECT_OPS }, eNamespace, prototypes::id::_ID_Count, 0, &sNativePropertyHooks, // This isn't strictly following the spec (see // https://console.spec.whatwg.org/#ref-for-dfn-namespace-object), // but should be ok for Xrays. JS::GetRealmObjectPrototype }; bool ConstructorEnabled(JSContext* aCx, JS::Handle aObj) { return nsContentUtils::ThreadsafeIsSystemCaller(aCx); } void CreateInterfaceObjects(JSContext* aCx, JS::Handle aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal) { JS::Rooted constructorProto(aCx, JS::GetRealmObjectPrototype(aCx)); if (!constructorProto) { return; } JS::Heap* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::UserInteraction); dom::CreateNamespaceObject(aCx, aGlobal, constructorProto, sNamespaceObjectClass, interfaceCache, sNativeProperties.Upcast(), nullptr, "UserInteraction", ShouldExpose(aCx, aGlobal, aDefineOnGlobal)); } JS::Handle GetConstructorObjectHandle(JSContext* aCx) { /* Get the interface object for this class. This will create the object as needed. */ return GetPerInterfaceObjectHandle(aCx, constructors::id::UserInteraction, &CreateInterfaceObjects, DefineInterfaceProperty::CheckExposure); } } // namespace UserInteraction_Binding } // namespace mozilla::dom