/* 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 KeyframeEffectOptionsAtoms;
class KeyframeEffectReadOnly;
struct KeyframeEffectReadOnlyAtoms;
struct NativePropertyHooks;
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);


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 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);

  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
