Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM ResizeObserver.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_RESIZEOBSERVERBINDING_H_
#define DOM_RESIZEOBSERVERBINDING_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/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 ProtoAndIfaceCache;
class ResizeObserver;
class ResizeObserverCallback;
class ResizeObserverEntry;
struct ResizeObserverOptionsAtoms;
class ResizeObserverSize;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class ResizeObserverBoxOptions : uint8_t {
  Border_box,
  Content_box,
  Device_pixel_content_box,
};
namespace binding_detail {
template <> struct EnumStrings<ResizeObserverBoxOptions> {
  static constexpr nsLiteralCString Values[3] {
    "border-box"_ns,
    "content-box"_ns,
    "device-pixel-content-box"_ns,
  };
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, ResizeObserverBoxOptions aArgument, JS::MutableHandle<JS::Value> aValue);
class ResizeObserverCallback : public CallbackFunction
{
public:
  explicit inline ResizeObserverCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
    : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
  {
    MOZ_ASSERT(JS::IsCallable(mCallback));
  }
  explicit inline ResizeObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
    : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
  {
    MOZ_ASSERT(JS::IsCallable(mCallback));
  }
  explicit inline ResizeObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
    : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
  {
    MOZ_ASSERT(JS::IsCallable(mCallback));
  }
  explicit inline ResizeObserverCallback(CallbackFunction* aOther)
    : CallbackFunction(aOther)
  {
  }
  template <typename T>
  MOZ_CAN_RUN_SCRIPT inline void
  Call(const T& thisVal, const Sequence<OwningNonNull<ResizeObserverEntry>>& entries, ResizeObserver& 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 = "ResizeObserverCallback";
    }
    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(const Sequence<OwningNonNull<ResizeObserverEntry>>& entries, ResizeObserver& 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 = "ResizeObserverCallback";
    }
    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, const Sequence<OwningNonNull<ResizeObserverEntry>>& entries, ResizeObserver& observer, const char* aExecutionReason = nullptr)
  {
    return Call(thisVal, entries, observer, IgnoreErrors(), aExecutionReason);
  }
  MOZ_CAN_RUN_SCRIPT inline void
  Call(const Sequence<OwningNonNull<ResizeObserverEntry>>& entries, ResizeObserver& observer, const char* aExecutionReason = nullptr)
  {
    return Call(entries, observer, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
  }
  inline bool
  operator==(const ResizeObserverCallback& aOther) const
  {
    return CallbackFunction::operator==(aOther);
  }
private:
  MOZ_CAN_RUN_SCRIPT void Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, const Sequence<OwningNonNull<ResizeObserverEntry>>& entries, ResizeObserver& observer, ErrorResult& aRv);
};
namespace binding_detail {
class FastResizeObserverCallback : public ResizeObserverCallback
{
public:
  explicit inline FastResizeObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
    : ResizeObserverCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
  {
  }
  inline void
  Trace(JSTracer* aTracer)
  {
    ResizeObserverCallback::Trace(aTracer);
  }
  inline void
  FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
  {
    ResizeObserverCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
  }
};
} // namespace binding_detail
struct ResizeObserverOptions : public DictionaryBase
{
  MOZ_INIT_OUTSIDE_CTOR ResizeObserverBoxOptions mBox;
  ResizeObserverOptions();
  explicit inline ResizeObserverOptions(const FastDictionaryInitializer& )
  {
    // Do nothing here; this is used by our "Fast" subclass
  }
  ResizeObserverOptions(ResizeObserverOptions&& aOther) = default;
  explicit inline ResizeObserverOptions(const ResizeObserverOptions& 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);
  ResizeObserverOptions&
  operator=(const ResizeObserverOptions& aOther);
private:
  static bool
  InitIds(JSContext* cx, ResizeObserverOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct FastResizeObserverOptions : public ResizeObserverOptions
{
  inline FastResizeObserverOptions()
    : ResizeObserverOptions(FastDictionaryInitializer())
  {
    // Doesn't matter what int we pass to the parent constructor
  }
};
} // namespace binding_detail
namespace ResizeObserver_Binding {
  typedef mozilla::dom::ResizeObserver NativeType;
  bool
  Wrap(JSContext* aCx, mozilla::dom::ResizeObserver* 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::ResizeObserver,
                                       &CreateInterfaceObjects,
                                       DefineInterfaceProperty::Always);
  }
} // namespace ResizeObserver_Binding
namespace ResizeObserverEntry_Binding {
  typedef mozilla::dom::ResizeObserverEntry NativeType;
  bool
  Wrap(JSContext* aCx, mozilla::dom::ResizeObserverEntry* 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
  ClearCachedBorderBoxSizeValue(mozilla::dom::ResizeObserverEntry* aObject);
  void
  ClearCachedContentBoxSizeValue(mozilla::dom::ResizeObserverEntry* aObject);
  void
  ClearCachedDevicePixelContentBoxSizeValue(mozilla::dom::ResizeObserverEntry* aObject);
  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::ResizeObserverEntry,
                                       &CreateInterfaceObjects,
                                       DefineInterfaceProperty::Always);
  }
} // namespace ResizeObserverEntry_Binding
namespace ResizeObserverSize_Binding {
  typedef mozilla::dom::ResizeObserverSize NativeType;
  bool
  Wrap(JSContext* aCx, mozilla::dom::ResizeObserverSize* 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::ResizeObserverSize,
                                       &CreateInterfaceObjects,
                                       DefineInterfaceProperty::Always);
  }
} // namespace ResizeObserverSize_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::ResizeObserverBoxOptions>
{
  static constexpr dom::ResizeObserverBoxOptions value = dom::ResizeObserverBoxOptions::Device_pixel_content_box;
  static_assert(static_cast<uint8_t>(dom::ResizeObserverBoxOptions::Border_box) == 0,
                "We rely on this in ContiguousEnumValues");
  static_assert(std::size(dom::binding_detail::EnumStrings<dom::ResizeObserverBoxOptions>::Values) - 1 == UnderlyingValue(value),
                "Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_RESIZEOBSERVERBINDING_H_