Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM MutationObserver.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_MUTATIONOBSERVERBINDING_H_
#define DOM_MUTATIONOBSERVERBINDING_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"
#include "nsIContent.h"
class nsDOMMutationObserver;
class nsDOMMutationRecord;
class nsINode;
namespace mozilla {
namespace dom {
class MutationCallback;
struct MutationObserverInitAtoms;
struct MutationObservingInfoAtoms;
struct NativePropertyHooks;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
class MutationCallback : public CallbackFunction
{
public:
explicit inline MutationCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline MutationCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline MutationCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline MutationCallback(CallbackFunction* aOther)
: CallbackFunction(aOther)
{
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline void
Call(const T& thisVal, const Sequence<OwningNonNull<nsDOMMutationRecord>>& mutations, nsDOMMutationObserver& 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 = "MutationCallback";
}
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, mutations, observer, aRv);
}
MOZ_CAN_RUN_SCRIPT inline void
Call(const Sequence<OwningNonNull<nsDOMMutationRecord>>& mutations, nsDOMMutationObserver& 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 = "MutationCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
return Call(s.GetCallContext(), JS::UndefinedHandleValue, mutations, observer, aRv);
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline void
Call(const T& thisVal, const Sequence<OwningNonNull<nsDOMMutationRecord>>& mutations, nsDOMMutationObserver& observer, const char* aExecutionReason = nullptr)
{
return Call(thisVal, mutations, observer, IgnoreErrors(), aExecutionReason);
}
MOZ_CAN_RUN_SCRIPT inline void
Call(const Sequence<OwningNonNull<nsDOMMutationRecord>>& mutations, nsDOMMutationObserver& observer, const char* aExecutionReason = nullptr)
{
return Call(mutations, observer, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const MutationCallback& aOther) const
{
return CallbackFunction::operator==(aOther);
}
private:
MOZ_CAN_RUN_SCRIPT void Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, const Sequence<OwningNonNull<nsDOMMutationRecord>>& mutations, nsDOMMutationObserver& observer, ErrorResult& aRv);
};
namespace binding_detail {
class FastMutationCallback : public MutationCallback
{
public:
explicit inline FastMutationCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
: MutationCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
MutationCallback::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
MutationCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
struct MutationObserverInit : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR bool mAnimations;
MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<nsString>> mAttributeFilter;
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mAttributeOldValue;
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mAttributes;
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mCharacterData;
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mCharacterDataOldValue;
MOZ_INIT_OUTSIDE_CTOR bool mChildList;
MOZ_INIT_OUTSIDE_CTOR bool mChromeOnlyNodes;
MOZ_INIT_OUTSIDE_CTOR bool mSubtree;
MutationObserverInit();
explicit inline MutationObserverInit(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
MutationObserverInit(MutationObserverInit&& aOther) = default;
explicit inline MutationObserverInit(const MutationObserverInit& 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);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
MutationObserverInit&
operator=(const MutationObserverInit& aOther);
private:
static bool
InitIds(JSContext* cx, MutationObserverInitAtoms* atomsCache);
};
namespace binding_detail {
struct FastMutationObserverInit : public MutationObserverInit
{
inline FastMutationObserverInit()
: MutationObserverInit(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MutationObservingInfo : public MutationObserverInit
{
MOZ_INIT_OUTSIDE_CTOR RefPtr<nsINode> mObservedNode;
MutationObservingInfo();
explicit inline MutationObservingInfo(const FastDictionaryInitializer& )
: MutationObserverInit(FastDictionaryInitializer())
{
// Do nothing here; this is used by our "Fast" subclass
}
MutationObservingInfo(MutationObservingInfo&& aOther) = default;
explicit inline MutationObservingInfo(const MutationObservingInfo& aOther)
: MutationObserverInit(FastDictionaryInitializer())
{
*this = aOther;
}
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
inline void
TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
{
ImplCycleCollectionTraverse(aCallback, mObservedNode, "mObservedNode", aFlags);
}
inline void
UnlinkForCC()
{
ImplCycleCollectionUnlink(mObservedNode);
}
MutationObservingInfo&
operator=(const MutationObservingInfo& aOther);
private:
static bool
InitIds(JSContext* cx, MutationObservingInfoAtoms* atomsCache);
};
namespace binding_detail {
struct FastMutationObservingInfo : public MutationObservingInfo
{
inline FastMutationObservingInfo()
: MutationObservingInfo(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace MutationObserver_Binding {
typedef nsDOMMutationObserver NativeType;
bool
Wrap(JSContext* aCx, nsDOMMutationObserver* 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::MutationObserver,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace MutationObserver_Binding
namespace MutationRecord_Binding {
typedef nsDOMMutationRecord NativeType;
bool
Wrap(JSContext* aCx, nsDOMMutationRecord* 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::MutationRecord,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace MutationRecord_Binding
} // namespace mozilla::dom
#endif // DOM_MUTATIONOBSERVERBINDING_H_