/* THIS FILE IS AUTOGENERATED FROM KeyframeEffect.webidl BY Codegen.py - DO NOT EDIT */

#ifndef mozilla_dom_KeyframeEffectBinding_h
#define mozilla_dom_KeyframeEffectBinding_h

#include "AnimationEffectReadOnlyBinding.h"
#include "KeyframeBinding.h"
#include "js/RootingAPI.h"
#include "jspubtd.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/UnionMember.h"
#include "mozilla/dom/UnionTypes.h"

namespace mozilla {
namespace dom {

struct AnimationPropertyStateAtoms;
class CSSPseudoElement;
class Element;
class KeyframeEffect;
struct KeyframeEffectAtoms;
struct KeyframeEffectOptionsAtoms;
class KeyframeEffectReadOnly;
struct KeyframeEffectReadOnlyAtoms;
struct NativePropertyHooks;
class OwningElementOrCSSPseudoElement;
class OwningUnrestrictedDoubleOrString;
class ProtoAndIfaceCache;
class UnrestrictedDoubleOrString;

} // namespace dom
} // namespace mozilla

namespace mozilla {
namespace dom {

enum class IterationCompositeOperation : uint32_t {
  Replace,
  Accumulate,
  EndGuard_
};

namespace IterationCompositeOperationValues {
extern const EnumEntry strings[3];
} // namespace IterationCompositeOperationValues

bool
ToJSValue(JSContext* aCx, IterationCompositeOperation aArgument, JS::MutableHandle<JS::Value> aValue);


void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningElementOrCSSPseudoElement& aUnion, const char* aName, uint32_t aFlags = 0);


void
ImplCycleCollectionUnlink(OwningElementOrCSSPseudoElement& aUnion);


struct AnimationPropertyState : public DictionaryBase
{
  Optional<nsString> mProperty;
  Optional<bool> mRunningOnCompositor;
  Optional<nsString> mWarning;

  AnimationPropertyState();

  explicit inline AnimationPropertyState(const FastDictionaryInitializer& )
  {
    // Do nothing here; this is used by our "Fast" subclass
  }

  explicit inline AnimationPropertyState(const AnimationPropertyState& aOther)
  {
    *this = aOther;
  }

  bool
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);

  bool
  Init(const nsAString& aJSON);

  bool
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;

  bool
  ToJSON(nsAString& aJSON) const;

  void
  TraceDictionary(JSTracer* trc);

  void
  operator=(const AnimationPropertyState& aOther);

private:
  static bool
  InitIds(JSContext* cx, AnimationPropertyStateAtoms* atomsCache);
};

namespace binding_detail {
struct FastAnimationPropertyState : public AnimationPropertyState
{
  inline FastAnimationPropertyState()
    : AnimationPropertyState(FastDictionaryInitializer())
  {
    // Doesn't matter what int we pass to the parent constructor
  }
};
} // namespace binding_detail


class ElementOrCSSPseudoElement
{
  friend class ElementOrCSSPseudoElementArgument;
  enum Type
  {
    eUninitialized,
    eElement,
    eCSSPseudoElement
  };

  union Value
  {
    UnionMember<NonNull<mozilla::dom::Element> > mElement;
    UnionMember<NonNull<mozilla::dom::CSSPseudoElement> > mCSSPseudoElement;

  };

  Type mType;
  Value mValue;

  ElementOrCSSPseudoElement(const ElementOrCSSPseudoElement&) = delete;
  void operator=(const ElementOrCSSPseudoElement) = delete;
public:
  explicit inline ElementOrCSSPseudoElement()
    : mType(eUninitialized)
  {
  }

  inline ~ElementOrCSSPseudoElement()
  {
    Uninit();
  }

  inline NonNull<mozilla::dom::Element>&
  RawSetAsElement()
  {
    if (mType == eElement) {
      return mValue.mElement.Value();
    }
    MOZ_ASSERT(mType == eUninitialized);
    mType = eElement;
    return mValue.mElement.SetValue();
  }

  inline NonNull<mozilla::dom::Element>&
  SetAsElement()
  {
    if (mType == eElement) {
      return mValue.mElement.Value();
    }
    Uninit();
    mType = eElement;
    return mValue.mElement.SetValue();
  }

  inline bool
  IsElement() const
  {
    return mType == eElement;
  }

  inline NonNull<mozilla::dom::Element>&
  GetAsElement()
  {
    MOZ_ASSERT(IsElement(), "Wrong type!");
    return mValue.mElement.Value();
  }

  inline mozilla::dom::Element&
  GetAsElement() const
  {
    MOZ_ASSERT(IsElement(), "Wrong type!");
    return mValue.mElement.Value();
  }

  inline NonNull<mozilla::dom::CSSPseudoElement>&
  RawSetAsCSSPseudoElement()
  {
    if (mType == eCSSPseudoElement) {
      return mValue.mCSSPseudoElement.Value();
    }
    MOZ_ASSERT(mType == eUninitialized);
    mType = eCSSPseudoElement;
    return mValue.mCSSPseudoElement.SetValue();
  }

  inline NonNull<mozilla::dom::CSSPseudoElement>&
  SetAsCSSPseudoElement()
  {
    if (mType == eCSSPseudoElement) {
      return mValue.mCSSPseudoElement.Value();
    }
    Uninit();
    mType = eCSSPseudoElement;
    return mValue.mCSSPseudoElement.SetValue();
  }

  inline bool
  IsCSSPseudoElement() const
  {
    return mType == eCSSPseudoElement;
  }

  inline NonNull<mozilla::dom::CSSPseudoElement>&
  GetAsCSSPseudoElement()
  {
    MOZ_ASSERT(IsCSSPseudoElement(), "Wrong type!");
    return mValue.mCSSPseudoElement.Value();
  }

  inline mozilla::dom::CSSPseudoElement&
  GetAsCSSPseudoElement() const
  {
    MOZ_ASSERT(IsCSSPseudoElement(), "Wrong type!");
    return mValue.mCSSPseudoElement.Value();
  }

  inline void
  Uninit()
  {
    switch (mType) {
      case eUninitialized: {
        break;
      }
      case eElement: {
        DestroyElement();
        break;
      }
      case eCSSPseudoElement: {
        DestroyCSSPseudoElement();
        break;
      }
    }
  }

  bool
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;

private:
  inline void
  DestroyElement()
  {
    MOZ_ASSERT(IsElement(), "Wrong type!");
    mValue.mElement.Destroy();
    mType = eUninitialized;
  }

  inline void
  DestroyCSSPseudoElement()
  {
    MOZ_ASSERT(IsCSSPseudoElement(), "Wrong type!");
    mValue.mCSSPseudoElement.Destroy();
    mType = eUninitialized;
  }
};


class OwningElementOrCSSPseudoElement : public AllOwningUnionBase
{
  friend void ImplCycleCollectionUnlink(OwningElementOrCSSPseudoElement& aUnion);
  enum Type
  {
    eUninitialized,
    eElement,
    eCSSPseudoElement
  };

  union Value
  {
    UnionMember<OwningNonNull<mozilla::dom::Element> > mElement;
    UnionMember<OwningNonNull<mozilla::dom::CSSPseudoElement> > mCSSPseudoElement;

  };

  Type mType;
  Value mValue;

public:
  explicit inline OwningElementOrCSSPseudoElement()
    : mType(eUninitialized)
  {
  }

  explicit inline OwningElementOrCSSPseudoElement(const OwningElementOrCSSPseudoElement& aOther)
    : mType(eUninitialized)
  {
    *this = aOther;
  }

  inline ~OwningElementOrCSSPseudoElement()
  {
    Uninit();
  }

  OwningNonNull<mozilla::dom::Element>&
  RawSetAsElement();

  OwningNonNull<mozilla::dom::Element>&
  SetAsElement();

  bool
  TrySetToElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);

  inline bool
  IsElement() const
  {
    return mType == eElement;
  }

  inline OwningNonNull<mozilla::dom::Element>&
  GetAsElement()
  {
    MOZ_ASSERT(IsElement(), "Wrong type!");
    return mValue.mElement.Value();
  }

  inline OwningNonNull<mozilla::dom::Element> const &
  GetAsElement() const
  {
    MOZ_ASSERT(IsElement(), "Wrong type!");
    return mValue.mElement.Value();
  }

  OwningNonNull<mozilla::dom::CSSPseudoElement>&
  RawSetAsCSSPseudoElement();

  OwningNonNull<mozilla::dom::CSSPseudoElement>&
  SetAsCSSPseudoElement();

  bool
  TrySetToCSSPseudoElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);

  inline bool
  IsCSSPseudoElement() const
  {
    return mType == eCSSPseudoElement;
  }

  inline OwningNonNull<mozilla::dom::CSSPseudoElement>&
  GetAsCSSPseudoElement()
  {
    MOZ_ASSERT(IsCSSPseudoElement(), "Wrong type!");
    return mValue.mCSSPseudoElement.Value();
  }

  inline OwningNonNull<mozilla::dom::CSSPseudoElement> const &
  GetAsCSSPseudoElement() const
  {
    MOZ_ASSERT(IsCSSPseudoElement(), "Wrong type!");
    return mValue.mCSSPseudoElement.Value();
  }

  void
  Uninit();

  bool
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;

  void
  TraceUnion(JSTracer* trc);

  void
  operator=(const OwningElementOrCSSPseudoElement& aOther);

private:
  void
  DestroyElement();

  void
  DestroyCSSPseudoElement();
};


struct KeyframeEffectOptions : public AnimationEffectTimingProperties
{
  CompositeOperation mComposite;
  IterationCompositeOperation mIterationComposite;
  nsString mSpacing;

  KeyframeEffectOptions();

  explicit inline KeyframeEffectOptions(const FastDictionaryInitializer& )
    : AnimationEffectTimingProperties(FastDictionaryInitializer())
  {
    // Do nothing here; this is used by our "Fast" subclass
  }

  explicit inline KeyframeEffectOptions(const KeyframeEffectOptions& aOther)
  {
    *this = aOther;
  }

  bool
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);

  bool
  Init(const nsAString& aJSON);

  bool
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;

  bool
  ToJSON(nsAString& aJSON) const;

  void
  TraceDictionary(JSTracer* trc);

  void
  operator=(const KeyframeEffectOptions& aOther);

private:
  static bool
  InitIds(JSContext* cx, KeyframeEffectOptionsAtoms* atomsCache);
};

namespace binding_detail {
struct FastKeyframeEffectOptions : public KeyframeEffectOptions
{
  inline FastKeyframeEffectOptions()
    : KeyframeEffectOptions(FastDictionaryInitializer())
  {
    // Doesn't matter what int we pass to the parent constructor
  }
};
} // namespace binding_detail


class UnrestrictedDoubleOrKeyframeEffectOptions
{
  friend class UnrestrictedDoubleOrKeyframeEffectOptionsArgument;
  enum Type
  {
    eUninitialized,
    eUnrestrictedDouble,
    eKeyframeEffectOptions
  };

  union Value
  {
    UnionMember<double > mUnrestrictedDouble;
    UnionMember<binding_detail::FastKeyframeEffectOptions > mKeyframeEffectOptions;

  };

  Type mType;
  Value mValue;

  UnrestrictedDoubleOrKeyframeEffectOptions(const UnrestrictedDoubleOrKeyframeEffectOptions&) = delete;
  void operator=(const UnrestrictedDoubleOrKeyframeEffectOptions) = delete;
public:
  explicit inline UnrestrictedDoubleOrKeyframeEffectOptions()
    : mType(eUninitialized)
  {
  }

  inline ~UnrestrictedDoubleOrKeyframeEffectOptions()
  {
    Uninit();
  }

  inline double&
  RawSetAsUnrestrictedDouble()
  {
    if (mType == eUnrestrictedDouble) {
      return mValue.mUnrestrictedDouble.Value();
    }
    MOZ_ASSERT(mType == eUninitialized);
    mType = eUnrestrictedDouble;
    return mValue.mUnrestrictedDouble.SetValue();
  }

  inline double&
  SetAsUnrestrictedDouble()
  {
    if (mType == eUnrestrictedDouble) {
      return mValue.mUnrestrictedDouble.Value();
    }
    Uninit();
    mType = eUnrestrictedDouble;
    return mValue.mUnrestrictedDouble.SetValue();
  }

  inline bool
  IsUnrestrictedDouble() const
  {
    return mType == eUnrestrictedDouble;
  }

  inline double&
  GetAsUnrestrictedDouble()
  {
    MOZ_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
    return mValue.mUnrestrictedDouble.Value();
  }

  inline double
  GetAsUnrestrictedDouble() const
  {
    MOZ_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
    return mValue.mUnrestrictedDouble.Value();
  }

  inline binding_detail::FastKeyframeEffectOptions&
  RawSetAsKeyframeEffectOptions()
  {
    if (mType == eKeyframeEffectOptions) {
      return mValue.mKeyframeEffectOptions.Value();
    }
    MOZ_ASSERT(mType == eUninitialized);
    mType = eKeyframeEffectOptions;
    return mValue.mKeyframeEffectOptions.SetValue();
  }

  inline binding_detail::FastKeyframeEffectOptions&
  SetAsKeyframeEffectOptions()
  {
    if (mType == eKeyframeEffectOptions) {
      return mValue.mKeyframeEffectOptions.Value();
    }
    Uninit();
    mType = eKeyframeEffectOptions;
    return mValue.mKeyframeEffectOptions.SetValue();
  }

  inline bool
  IsKeyframeEffectOptions() const
  {
    return mType == eKeyframeEffectOptions;
  }

  inline binding_detail::FastKeyframeEffectOptions&
  GetAsKeyframeEffectOptions()
  {
    MOZ_ASSERT(IsKeyframeEffectOptions(), "Wrong type!");
    return mValue.mKeyframeEffectOptions.Value();
  }

  inline const KeyframeEffectOptions&
  GetAsKeyframeEffectOptions() const
  {
    MOZ_ASSERT(IsKeyframeEffectOptions(), "Wrong type!");
    return mValue.mKeyframeEffectOptions.Value();
  }

  inline void
  Uninit()
  {
    switch (mType) {
      case eUninitialized: {
        break;
      }
      case eUnrestrictedDouble: {
        DestroyUnrestrictedDouble();
        break;
      }
      case eKeyframeEffectOptions: {
        DestroyKeyframeEffectOptions();
        break;
      }
    }
  }

  bool
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;

private:
  inline void
  DestroyUnrestrictedDouble()
  {
    MOZ_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
    mValue.mUnrestrictedDouble.Destroy();
    mType = eUninitialized;
  }

  inline void
  DestroyKeyframeEffectOptions()
  {
    MOZ_ASSERT(IsKeyframeEffectOptions(), "Wrong type!");
    mValue.mKeyframeEffectOptions.Destroy();
    mType = eUninitialized;
  }
};


class OwningUnrestrictedDoubleOrKeyframeEffectOptions : public AllOwningUnionBase
{
  friend void ImplCycleCollectionUnlink(OwningUnrestrictedDoubleOrKeyframeEffectOptions& aUnion);
  enum Type
  {
    eUninitialized,
    eUnrestrictedDouble,
    eKeyframeEffectOptions
  };

  union Value
  {
    UnionMember<double > mUnrestrictedDouble;
    UnionMember<KeyframeEffectOptions > mKeyframeEffectOptions;

  };

  Type mType;
  Value mValue;

public:
  explicit inline OwningUnrestrictedDoubleOrKeyframeEffectOptions()
    : mType(eUninitialized)
  {
  }

  explicit inline OwningUnrestrictedDoubleOrKeyframeEffectOptions(const OwningUnrestrictedDoubleOrKeyframeEffectOptions& aOther)
    : mType(eUninitialized)
  {
    *this = aOther;
  }

  inline ~OwningUnrestrictedDoubleOrKeyframeEffectOptions()
  {
    Uninit();
  }

  double&
  RawSetAsUnrestrictedDouble();

  double&
  SetAsUnrestrictedDouble();

  bool
  TrySetToUnrestrictedDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);

  inline bool
  IsUnrestrictedDouble() const
  {
    return mType == eUnrestrictedDouble;
  }

  inline double&
  GetAsUnrestrictedDouble()
  {
    MOZ_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
    return mValue.mUnrestrictedDouble.Value();
  }

  inline double const &
  GetAsUnrestrictedDouble() const
  {
    MOZ_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
    return mValue.mUnrestrictedDouble.Value();
  }

  KeyframeEffectOptions&
  RawSetAsKeyframeEffectOptions();

  KeyframeEffectOptions&
  SetAsKeyframeEffectOptions();

  bool
  TrySetToKeyframeEffectOptions(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);

  inline bool
  IsKeyframeEffectOptions() const
  {
    return mType == eKeyframeEffectOptions;
  }

  inline KeyframeEffectOptions&
  GetAsKeyframeEffectOptions()
  {
    MOZ_ASSERT(IsKeyframeEffectOptions(), "Wrong type!");
    return mValue.mKeyframeEffectOptions.Value();
  }

  inline KeyframeEffectOptions const &
  GetAsKeyframeEffectOptions() const
  {
    MOZ_ASSERT(IsKeyframeEffectOptions(), "Wrong type!");
    return mValue.mKeyframeEffectOptions.Value();
  }

  void
  Uninit();

  bool
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;

  void
  TraceUnion(JSTracer* trc);

  void
  operator=(const OwningUnrestrictedDoubleOrKeyframeEffectOptions& aOther);

private:
  void
  DestroyUnrestrictedDouble();

  void
  DestroyKeyframeEffectOptions();
};


namespace KeyframeEffectBinding {

  typedef mozilla::dom::KeyframeEffect NativeType;

  // We declare this as an array so that retrieving a pointer to this
  // binding's property hooks only requires compile/link-time resolvable
  // address arithmetic.  Declaring it as a pointer instead would require
  // doing a run-time load to fetch a pointer to this binding's property
  // hooks.  And then structures which embedded a pointer to this structure
  // would require a run-time load for proper initialization, which would
  // then induce static constructors.  Lots of static constructors.
  extern const NativePropertyHooks sNativePropertyHooks[];

  JSObject*
  DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);

  bool
  ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);

  const JSClass*
  GetJSClass();

  bool
  Wrap(JSContext* aCx, mozilla::dom::KeyframeEffect* 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, bool aDefineOnGlobal);

  JS::Handle<JSObject*>
  GetProtoObjectHandle(JSContext* aCx, JS::Handle<JSObject*> aGlobal);

  JS::Handle<JSObject*>
  GetConstructorObjectHandle(JSContext* aCx, JS::Handle<JSObject*> aGlobal, bool aDefineOnGlobal = true);

  JSObject*
  GetConstructorObject(JSContext* aCx, JS::Handle<JSObject*> aGlobal);

} // namespace KeyframeEffectBinding



namespace KeyframeEffectReadOnlyBinding {

  typedef mozilla::dom::KeyframeEffectReadOnly NativeType;

  // We declare this as an array so that retrieving a pointer to this
  // binding's property hooks only requires compile/link-time resolvable
  // address arithmetic.  Declaring it as a pointer instead would require
  // doing a run-time load to fetch a pointer to this binding's property
  // hooks.  And then structures which embedded a pointer to this structure
  // would require a run-time load for proper initialization, which would
  // then induce static constructors.  Lots of static constructors.
  extern const NativePropertyHooks sNativePropertyHooks[];

  JSObject*
  DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);

  bool
  ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);

  const JSClass*
  GetJSClass();

  bool
  Wrap(JSContext* aCx, mozilla::dom::KeyframeEffectReadOnly* 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, bool aDefineOnGlobal);

  JS::Handle<JSObject*>
  GetProtoObjectHandle(JSContext* aCx, JS::Handle<JSObject*> aGlobal);

  JSObject*
  GetProtoObject(JSContext* aCx, JS::Handle<JSObject*> aGlobal);

  JS::Handle<JSObject*>
  GetConstructorObjectHandle(JSContext* aCx, JS::Handle<JSObject*> aGlobal, bool aDefineOnGlobal = true);

  JSObject*
  GetConstructorObject(JSContext* aCx, JS::Handle<JSObject*> aGlobal);

} // namespace KeyframeEffectReadOnlyBinding



} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_KeyframeEffectBinding_h
