Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM NavigateEvent.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_NAVIGATEEVENTBINDING_H_
#define DOM_NAVIGATEEVENTBINDING_H_
#include "EventBinding.h"
#include "NavigationBinding.h"
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/EnumTypeTraits.h"
#include "mozilla/Span.h"
#include "mozilla/dom/AbortSignal.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackFunction.h"
#include "mozilla/dom/FormData.h"
#include "mozilla/dom/NavigationDestination.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/ToJSValue.h"
namespace mozilla {
namespace dom {
class AbortSignal;
class FormData;
struct NativePropertyHooks;
class NavigateEvent;
struct NavigateEventInitAtoms;
class NavigationDestination;
class NavigationInterceptHandler;
struct NavigationInterceptOptionsAtoms;
class Promise;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class NavigationFocusReset : uint8_t {
After_transition,
Manual,
};
namespace binding_detail {
template <> struct EnumStrings<NavigationFocusReset> {
static constexpr nsLiteralCString Values[2] {
"after-transition"_ns,
"manual"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, NavigationFocusReset aArgument, JS::MutableHandle<JS::Value> aValue);
enum class NavigationScrollBehavior : uint8_t {
After_transition,
Manual,
};
namespace binding_detail {
template <> struct EnumStrings<NavigationScrollBehavior> {
static constexpr nsLiteralCString Values[2] {
"after-transition"_ns,
"manual"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, NavigationScrollBehavior aArgument, JS::MutableHandle<JS::Value> aValue);
struct NavigateEventInit : public EventInit
{
MOZ_INIT_OUTSIDE_CTOR bool mCanIntercept;
MOZ_INIT_OUTSIDE_CTOR OwningNonNull<mozilla::dom::NavigationDestination> mDestination;
MOZ_INIT_OUTSIDE_CTOR nsString mDownloadRequest;
MOZ_INIT_OUTSIDE_CTOR RefPtr<mozilla::dom::FormData> mFormData;
MOZ_INIT_OUTSIDE_CTOR bool mHasUAVisualTransition;
MOZ_INIT_OUTSIDE_CTOR bool mHashChange;
MOZ_INIT_OUTSIDE_CTOR JS::Value mInfo;
MOZ_INIT_OUTSIDE_CTOR NavigationType mNavigationType;
MOZ_INIT_OUTSIDE_CTOR OwningNonNull<mozilla::dom::AbortSignal> mSignal;
MOZ_INIT_OUTSIDE_CTOR bool mUserInitiated;
NavigateEventInit();
explicit inline NavigateEventInit(const FastDictionaryInitializer& )
: EventInit(FastDictionaryInitializer())
{
// Do nothing here; this is used by our "Fast" subclass
}
NavigateEventInit(NavigateEventInit&& aOther) = default;
private:
NavigateEventInit(const NavigateEventInit&) = delete;
NavigateEventInit& operator=(const NavigateEventInit&) = delete;
static bool
InitIds(JSContext* cx, NavigateEventInitAtoms* atomsCache);
public:
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);
inline void
TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
{
ImplCycleCollectionTraverse(aCallback, mDestination, "mDestination", aFlags);
ImplCycleCollectionTraverse(aCallback, mFormData, "mFormData", aFlags);
ImplCycleCollectionTraverse(aCallback, mSignal, "mSignal", aFlags);
}
inline void
UnlinkForCC()
{
ImplCycleCollectionUnlink(mDestination);
ImplCycleCollectionUnlink(mFormData);
ImplCycleCollectionUnlink(mSignal);
}
};
namespace binding_detail {
struct FastNavigateEventInit : public NavigateEventInit
{
inline FastNavigateEventInit()
: NavigateEventInit(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
class NavigationInterceptHandler : public CallbackFunction
{
public:
explicit inline NavigationInterceptHandler(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline NavigationInterceptHandler(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline NavigationInterceptHandler(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline NavigationInterceptHandler(CallbackFunction* aOther)
: CallbackFunction(aOther)
{
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(const T& thisVal, 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 = "NavigationInterceptHandler";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return nullptr;
}
JS::Rooted<JS::Value> thisValJS(s.GetContext());
if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
return Call(s.GetCallContext(), thisValJS, aRv);
}
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(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 = "NavigationInterceptHandler";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return nullptr;
}
return Call(s.GetCallContext(), JS::UndefinedHandleValue, aRv);
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(const T& thisVal, const char* aExecutionReason = nullptr)
{
return Call(thisVal, IgnoreErrors(), aExecutionReason);
}
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(const char* aExecutionReason = nullptr)
{
return Call(IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const NavigationInterceptHandler& aOther) const
{
return CallbackFunction::operator==(aOther);
}
private:
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv);
};
namespace binding_detail {
class FastNavigationInterceptHandler : public NavigationInterceptHandler
{
public:
explicit inline FastNavigationInterceptHandler(JSObject* aCallback, JSObject* aCallbackGlobal)
: NavigationInterceptHandler(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
NavigationInterceptHandler::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
NavigationInterceptHandler::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
struct NavigationInterceptOptions : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<NavigationFocusReset> mFocusReset;
MOZ_INIT_OUTSIDE_CTOR Optional<OwningNonNull<NavigationInterceptHandler>> mHandler;
MOZ_INIT_OUTSIDE_CTOR Optional<NavigationScrollBehavior> mScroll;
NavigationInterceptOptions();
explicit inline NavigationInterceptOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
NavigationInterceptOptions(NavigationInterceptOptions&& aOther) = default;
private:
NavigationInterceptOptions(const NavigationInterceptOptions&) = delete;
NavigationInterceptOptions& operator=(const NavigationInterceptOptions&) = delete;
static bool
InitIds(JSContext* cx, NavigationInterceptOptionsAtoms* atomsCache);
public:
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);
inline void
TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
{
ImplCycleCollectionTraverse(aCallback, mHandler, "mHandler", aFlags);
}
inline void
UnlinkForCC()
{
ImplCycleCollectionUnlink(mHandler);
}
};
namespace binding_detail {
struct FastNavigationInterceptOptions : public NavigationInterceptOptions
{
inline FastNavigationInterceptOptions()
: NavigationInterceptOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace NavigateEvent_Binding {
typedef mozilla::dom::NavigateEvent NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::NavigateEvent* 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::NavigateEvent,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace NavigateEvent_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::NavigationFocusReset>
{
static constexpr dom::NavigationFocusReset value = dom::NavigationFocusReset::Manual;
static_assert(static_cast<uint8_t>(dom::NavigationFocusReset::After_transition) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::NavigationFocusReset>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
template <>
struct MaxContiguousEnumValue<dom::NavigationScrollBehavior>
{
static constexpr dom::NavigationScrollBehavior value = dom::NavigationScrollBehavior::Manual;
static_assert(static_cast<uint8_t>(dom::NavigationScrollBehavior::After_transition) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::NavigationScrollBehavior>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_NAVIGATEEVENTBINDING_H_