Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM PerformanceObserver.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_PERFORMANCEOBSERVERBINDING_H_
#define DOM_PERFORMANCEOBSERVERBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackFunction.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/ToJSValue.h"
namespace mozilla {
namespace dom {
struct NativePropertyHooks;
class PerformanceObserver;
class PerformanceObserverCallback;
class PerformanceObserverEntryList;
struct PerformanceObserverInitAtoms;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
class PerformanceObserverCallback : public CallbackFunction
{
public:
explicit inline PerformanceObserverCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline PerformanceObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline PerformanceObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline PerformanceObserverCallback(CallbackFunction* aOther)
: CallbackFunction(aOther)
{
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline void
Call(const T& thisVal, PerformanceObserverEntryList& entries, PerformanceObserver& observer, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "PerformanceObserverCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
JS::Rooted<JS::Value> thisValJS(s.GetContext());
if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
return Call(s.GetCallContext(), thisValJS, entries, observer, aRv);
}
MOZ_CAN_RUN_SCRIPT inline void
Call(PerformanceObserverEntryList& entries, PerformanceObserver& observer, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "PerformanceObserverCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
return Call(s.GetCallContext(), JS::UndefinedHandleValue, entries, observer, aRv);
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline void
Call(const T& thisVal, PerformanceObserverEntryList& entries, PerformanceObserver& observer, const char* aExecutionReason = nullptr)
{
return Call(thisVal, entries, observer, IgnoreErrors(), aExecutionReason);
}
MOZ_CAN_RUN_SCRIPT inline void
Call(PerformanceObserverEntryList& entries, PerformanceObserver& observer, const char* aExecutionReason = nullptr)
{
return Call(entries, observer, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const PerformanceObserverCallback& aOther) const
{
return CallbackFunction::operator==(aOther);
}
private:
MOZ_CAN_RUN_SCRIPT void Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, PerformanceObserverEntryList& entries, PerformanceObserver& observer, ErrorResult& aRv);
};
namespace binding_detail {
class FastPerformanceObserverCallback : public PerformanceObserverCallback
{
public:
explicit inline FastPerformanceObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
: PerformanceObserverCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
PerformanceObserverCallback::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
PerformanceObserverCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
struct PerformanceObserverInit : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mBuffered;
MOZ_INIT_OUTSIDE_CTOR Optional<double> mDurationThreshold;
MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<nsString>> mEntryTypes;
MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mType;
PerformanceObserverInit();
explicit inline PerformanceObserverInit(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
PerformanceObserverInit(PerformanceObserverInit&& aOther) = default;
explicit inline PerformanceObserverInit(const PerformanceObserverInit& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
PerformanceObserverInit&
operator=(const PerformanceObserverInit& aOther);
private:
static bool
InitIds(JSContext* cx, PerformanceObserverInitAtoms* atomsCache);
};
namespace binding_detail {
struct FastPerformanceObserverInit : public PerformanceObserverInit
{
inline FastPerformanceObserverInit()
: PerformanceObserverInit(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace PerformanceObserver_Binding {
typedef mozilla::dom::PerformanceObserver NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::PerformanceObserver* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::PerformanceObserver,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace PerformanceObserver_Binding
} // namespace mozilla::dom
#endif // DOM_PERFORMANCEOBSERVERBINDING_H_