Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM PaintWorkletGlobalScope.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "FunctionBinding.h"
#include "MainThreadUtils.h"
#include "PaintWorkletGlobalScopeBinding.h"
#include "WorkletGlobalScopeBinding.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/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/PaintWorkletGlobalScope.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
namespace PaintWorkletGlobalScope_Binding {
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<WorkletGlobalScope_Binding::NativeType>::value,
"Can't inherit from an interface with a different ownership model.");
MOZ_CAN_RUN_SCRIPT static bool
registerPaint(JSContext* cx_, JS::Handle<JSObject*> obj, void* void_self, const JSJitMethodCallArgs& args)
{
BindingCallContext cx(cx_, "PaintWorkletGlobalScope.registerPaint");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PaintWorkletGlobalScope", "registerPaint", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PaintWorkletGlobalScope*>(void_self);
if (!args.requireAtLeast(cx, "PaintWorkletGlobalScope.registerPaint", 2)) {
return false;
}
binding_detail::FakeString<char16_t> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
RootedCallback<OwningNonNull<binding_detail::FastVoidFunction>> arg1(cx);
if (args[1].isObject()) {
if (JS::IsCallable(&args[1].toObject())) {
{ // scope for tempRoot and tempGlobalRoot if needed
arg1 = new binding_detail::FastVoidFunction(&args[1].toObject(), JS::CurrentGlobalOrNull(cx));
}
} else {
cx.ThrowErrorMessage<MSG_NOT_CALLABLE>("Argument 2");
return false;
}
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 2");
return false;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->RegisterPaint(NonNullHelper(Constify(arg0)), MOZ_KnownLive(NonNullHelper(arg1))))>, "Should be returning void here");
MOZ_KnownLive(self)->RegisterPaint(NonNullHelper(Constify(arg0)), MOZ_KnownLive(NonNullHelper(arg1)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
static const JSJitInfo registerPaint_methodinfo = {
{ (JSJitGetterOp)registerPaint },
{ prototypes::id::PaintWorkletGlobalScope },
{ PrototypeTraits<prototypes::id::PaintWorkletGlobalScope>::Depth },
JSJitInfo::Method,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
static void
_finalize(JS::GCContext* gcx, JSObject* obj)
{
mozilla::dom::PaintWorkletGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PaintWorkletGlobalScope>(obj);
if (self) {
JS::SetReservedSlot(obj, DOM_OBJECT_SLOT, JS::UndefinedValue());
ClearWrapper(self, self, obj);
mozilla::dom::FinalizeGlobal(gcx, obj);
if (size_t mallocBytes = BindingJSObjectMallocBytes(self)) {
JS::RemoveAssociatedMemory(obj, mallocBytes,
JS::MemoryUse::DOMBinding);
}
AddForDeferredFinalization<mozilla::dom::PaintWorkletGlobalScope>(self);
}
}
static size_t
_objectMoved(JSObject* obj, JSObject* old)
{
mozilla::dom::PaintWorkletGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PaintWorkletGlobalScope>(obj);
if (self) {
UpdateWrapper(self, self, obj, old);
}
return 0;
}
static const JSFunctionSpec sMethods_specs[] = {
JS_FNSPEC("registerPaint", (GenericMethod<MaybeGlobalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&registerPaint_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
JS_FS_END
};
static const Prefable<const JSFunctionSpec> sMethods[] = {
{ nullptr, &sMethods_specs[0] },
{ nullptr, nullptr }
};
static const NativePropertiesN<1> sNativeProperties = {
false, 0,
false, 0,
true, 0 /* sMethods */,
false, 0,
false, 0,
false, 0,
false, 0,
-1,
0,
nullptr,
{
{ sMethods, nullptr }
}
};
static const DOMInterfaceInfo sInterfaceObjectInfo = {
{ ThrowingConstructor, &sEmptyNativePropertyHooks },
WorkletGlobalScope_Binding::GetConstructorObject,
prototypes::id::PaintWorkletGlobalScope,
PrototypeTraits<prototypes::id::PaintWorkletGlobalScope>::Depth,
true,
};
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
{
"PaintWorkletGlobalScopePrototype",
JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
JS_NULL_CLASS_OPS,
JS_NULL_CLASS_SPEC,
JS_NULL_CLASS_EXT,
JS_NULL_OBJECT_OPS
},
eGlobalInterfacePrototype,
prototypes::id::PaintWorkletGlobalScope,
PrototypeTraits<prototypes::id::PaintWorkletGlobalScope>::Depth,
&sEmptyNativePropertyHooks,
WorkletGlobalScope_Binding::GetProtoObject
};
static const JSClassOps sClassOps = {
nullptr, /* addProperty */
nullptr, /* delProperty */
nullptr, /* enumerate */
mozilla::dom::EnumerateGlobal, /* newEnumerate */
mozilla::dom::ResolveGlobal, /* resolve */
mozilla::dom::MayResolveGlobal, /* mayResolve */
_finalize, /* finalize */
nullptr, /* call */
nullptr, /* construct */
JS_GlobalObjectTraceHook, /* trace */
};
static const js::ClassExtension sClassExtension = {
_objectMoved /* objectMovedOp */
};
static const DOMJSClass sClass = {
{ "PaintWorkletGlobalScope",
JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS),
&sClassOps,
JS_NULL_CLASS_SPEC,
&sClassExtension,
JS_NULL_OBJECT_OPS
},
{ prototypes::id::WorkletGlobalScope, prototypes::id::PaintWorkletGlobalScope, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
std::is_base_of_v<nsISupports, mozilla::dom::PaintWorkletGlobalScope>,
&sEmptyNativePropertyHooks,
FindAssociatedGlobalForNative<mozilla::dom::PaintWorkletGlobalScope>::Get,
GetProtoObjectHandle,
GetCCParticipant<mozilla::dom::PaintWorkletGlobalScope>::Get(),
nullptr,
nullptr
};
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
"Must have the right minimal number of reserved slots.");
static_assert(JSCLASS_GLOBAL_APPLICATION_SLOTS >= 1,
"Must have enough reserved slots.");
bool
Wrap(JSContext* aCx, mozilla::dom::PaintWorkletGlobalScope* aObject, nsWrapperCache* aCache, JS::RealmOptions& aOptions, JSPrincipals* aPrincipal, JS::MutableHandle<JSObject*> aReflector)
{
static_assert(std::is_same_v<decltype(aObject), mozilla::dom::PaintWorkletGlobalScope*>);
MOZ_ASSERT(static_cast<mozilla::dom::WorkletGlobalScope*>(aObject) ==
reinterpret_cast<mozilla::dom::WorkletGlobalScope*>(aObject),
"Multiple inheritance for mozilla::dom::WorkletGlobalScope is broken.");
MOZ_ASSERT(ToSupportsIsCorrect(aObject));
MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
"nsISupports must be on our primary inheritance chain");
if (!CreateGlobal<mozilla::dom::PaintWorkletGlobalScope, GetProtoObjectHandle>(aCx,
aObject,
aCache,
sClass.ToJSClass(),
aOptions,
aPrincipal,
aReflector)) {
aCache->ReleaseWrapper(aObject);
aCache->ClearWrapper();
return false;
}
// aReflector is a new global, so has a new realm. Enter it
// before doing anything with it.
JSAutoRealm ar(aCx, aReflector);
if (!DefineProperties(aCx, aReflector, sNativeProperties.Upcast(), nullptr)) {
aCache->ReleaseWrapper(aObject);
aCache->ClearWrapper();
return false;
}
return true;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
{
JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PaintWorkletGlobalScope);
JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PaintWorkletGlobalScope);
JS::Handle<JSObject*> parentProto(WorkletGlobalScope_Binding::GetProtoObjectHandle(aCx));
if (!parentProto) {
return;
}
JS::Handle<JSObject*> constructorProto(WorkletGlobalScope_Binding::GetConstructorObjectHandle(aCx));
if (!constructorProto) {
return;
}
dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
&sPrototypeClass, protoCache,
constructorProto, &sInterfaceObjectInfo, 0, false, Span<const LegacyFactoryFunction, 0>{},
interfaceCache,
sNativeProperties.Upcast(),
nullptr,
"PaintWorkletGlobalScope", aDefineOnGlobal,
nullptr,
true,
nullptr);
JS::AssertObjectIsNotGray(*protoCache);
JS::Handle<JSObject*> proto = JS::Handle<JSObject*>::fromMarkedLocation(protoCache->address());
if (!proto) {
*protoCache = nullptr;
if (interfaceCache) {
*interfaceCache = nullptr;
}
return;
}
{
bool succeeded;
if (!JS_SetImmutablePrototype(aCx, proto, &succeeded)) {
*protoCache = nullptr;
if (interfaceCache) {
*interfaceCache = nullptr;
}
return;
}
MOZ_ASSERT(succeeded,
"making a fresh prototype object's [[Prototype]] "
"immutable can internally fail, but it should "
"never be unsuccessful");
}
}
JSObject*
GetConstructorObject(JSContext* aCx)
{
return GetConstructorObjectHandle(aCx);
}
} // namespace PaintWorkletGlobalScope_Binding
} // namespace mozilla::dom