/* THIS FILE IS AUTOGENERATED FROM TimelineRangeOffset.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "TimelineRangeOffsetBinding.h"
#include "js/CallAndConstruct.h"
#include "js/Exception.h"
#include "js/MapAndSet.h"
#include "js/Object.h"
#include "js/PropertyAndElement.h"
#include "js/PropertyDescriptor.h"
#include "js/experimental/JitInfo.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/dom/BindingCallContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/ScriptSettings.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
TimelineRangeOffset::TimelineRangeOffset()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
TimelineRangeOffset::InitIds(JSContext* cx, TimelineRangeOffsetAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->rangeName_id.init(cx, "rangeName") ||
!atomsCache->offset_id.init(cx, "offset")) {
return false;
}
return true;
}
bool
TimelineRangeOffset::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// Passing a null JSContext is OK only if we're initing from null,
// Since in that case we will not have to do any property gets
// Also evaluate isNullOrUndefined in order to avoid false-positive
// checkers by static analysis tools
MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
TimelineRangeOffsetAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<TimelineRangeOffsetAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
}
if (!IsConvertibleToDictionary(val)) {
return cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>(sourceDescription, "dictionary");
}
bool isNull = val.isNullOrUndefined();
// We only need these if !isNull, in which case we have |cx|.
Maybe<JS::Rooted<JSObject *> > object;
Maybe<JS::Rooted<JS::Value> > temp;
if (!isNull) {
MOZ_ASSERT(cx);
object.emplace(cx, &val.toObject());
temp.emplace(cx);
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->offset_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mOffset.Construct();
if (temp.ref().isObject()) {
static_assert(IsRefcounted<mozilla::dom::CSSNumericValue>::value, "We can only store refcounted classes.");
{
// Our JSContext should be in the right global to do unwrapping in.
nsresult rv = UnwrapObject<prototypes::id::CSSNumericValue, mozilla::dom::CSSNumericValue>(temp.ptr(), (mOffset.Value()), cx);
if (NS_FAILED(rv)) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'offset' member of TimelineRangeOffset", "CSSNumericValue");
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'offset' member of TimelineRangeOffset");
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->rangeName_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mRangeName.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, (mRangeName.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
TimelineRangeOffset::Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// We don't want to use sourceDescription for our context here;
// that's not really what it's formatted for.
BindingCallContext cx(cx_, nullptr);
return Init(cx, val, sourceDescription, passedToJSImpl);
}
bool
TimelineRangeOffset::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
TimelineRangeOffsetAtoms* atomsCache = GetAtomCache<TimelineRangeOffsetAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
if (mOffset.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
OwningNonNull<mozilla::dom::CSSNumericValue> const & currentValue = mOffset.InternalValue();
if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
MOZ_ASSERT(JS_IsExceptionPending(cx));
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->offset_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mRangeName.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsCString const & currentValue = mRangeName.InternalValue();
if (!UTF8StringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->rangeName_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
TimelineRangeOffset::TraceDictionary(JSTracer* trc)
{
}
TimelineRangeOffset&
TimelineRangeOffset::operator=(const TimelineRangeOffset& aOther)
{
MaybeEmptyDictionaryBase::operator=(aOther);
mOffset.Reset();
if (aOther.mOffset.WasPassed()) {
mOffset.Construct(aOther.mOffset.Value());
}
mRangeName.Reset();
if (aOther.mRangeName.WasPassed()) {
mRangeName.Construct(aOther.mRangeName.Value());
}
return *this;
}
} // namespace mozilla::dom