Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM LoadURIOptions.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "LoadURIOptionsBinding.h"
#include "MainThreadUtils.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/PrimitiveConversions.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;
LoadURIOptions::LoadURIOptions()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
LoadURIOptions::InitIds(JSContext* cx, LoadURIOptionsAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->wasSchemelessInput_id.init(cx, "wasSchemelessInput") ||
!atomsCache->triggeringWindowId_id.init(cx, "triggeringWindowId") ||
!atomsCache->triggeringStorageAccess_id.init(cx, "triggeringStorageAccess") ||
!atomsCache->triggeringSandboxFlags_id.init(cx, "triggeringSandboxFlags") ||
!atomsCache->triggeringRemoteType_id.init(cx, "triggeringRemoteType") ||
!atomsCache->triggeringPrincipal_id.init(cx, "triggeringPrincipal") ||
!atomsCache->remoteTypeOverride_id.init(cx, "remoteTypeOverride") ||
!atomsCache->referrerInfo_id.init(cx, "referrerInfo") ||
!atomsCache->postData_id.init(cx, "postData") ||
!atomsCache->loadFlags_id.init(cx, "loadFlags") ||
!atomsCache->headers_id.init(cx, "headers") ||
!atomsCache->hasValidUserGestureActivation_id.init(cx, "hasValidUserGestureActivation") ||
!atomsCache->csp_id.init(cx, "csp") ||
!atomsCache->cancelContentJSEpoch_id.init(cx, "cancelContentJSEpoch") ||
!atomsCache->baseURI_id.init(cx, "baseURI")) {
return false;
}
return true;
}
bool
LoadURIOptions::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());
LoadURIOptionsAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<LoadURIOptionsAtoms>(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->baseURI_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (temp.ref().isObject()) {
static_assert(IsRefcounted<nsIURI>::value, "We can only store refcounted classes.");
RefPtr<nsIURI> holder;
JS::Rooted<JSObject*> source(cx, &temp.ref().toObject());
if (NS_FAILED(UnwrapArg<nsIURI>(cx, source, getter_AddRefs(holder)))) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'baseURI' member of LoadURIOptions", "URI");
return false;
}
MOZ_ASSERT(holder);
mBaseURI = holder;
} else if (temp.ref().isNullOrUndefined()) {
mBaseURI = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'baseURI' member of LoadURIOptions");
return false;
}
} else {
mBaseURI = nullptr;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->cancelContentJSEpoch_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), "'cancelContentJSEpoch' member of LoadURIOptions", &mCancelContentJSEpoch)) {
return false;
}
} else {
mCancelContentJSEpoch = 0;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->csp_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (temp.ref().isObject()) {
static_assert(IsRefcounted<nsIContentSecurityPolicy>::value, "We can only store refcounted classes.");
RefPtr<nsIContentSecurityPolicy> holder;
JS::Rooted<JSObject*> source(cx, &temp.ref().toObject());
if (NS_FAILED(UnwrapArg<nsIContentSecurityPolicy>(cx, source, getter_AddRefs(holder)))) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'csp' member of LoadURIOptions", "ContentSecurityPolicy");
return false;
}
MOZ_ASSERT(holder);
mCsp = holder;
} else if (temp.ref().isNullOrUndefined()) {
mCsp = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'csp' member of LoadURIOptions");
return false;
}
} else {
mCsp = nullptr;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->hasValidUserGestureActivation_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), "'hasValidUserGestureActivation' member of LoadURIOptions", &mHasValidUserGestureActivation)) {
return false;
}
} else {
mHasValidUserGestureActivation = false;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->headers_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (temp.ref().isObject()) {
static_assert(IsRefcounted<nsIInputStream>::value, "We can only store refcounted classes.");
RefPtr<nsIInputStream> holder;
JS::Rooted<JSObject*> source(cx, &temp.ref().toObject());
if (NS_FAILED(UnwrapArg<nsIInputStream>(cx, source, getter_AddRefs(holder)))) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'headers' member of LoadURIOptions", "InputStream");
return false;
}
MOZ_ASSERT(holder);
mHeaders = holder;
} else if (temp.ref().isNullOrUndefined()) {
mHeaders = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'headers' member of LoadURIOptions");
return false;
}
} else {
mHeaders = nullptr;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->loadFlags_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), "'loadFlags' member of LoadURIOptions", &mLoadFlags)) {
return false;
}
} else {
mLoadFlags = 0;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->postData_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (temp.ref().isObject()) {
static_assert(IsRefcounted<nsIInputStream>::value, "We can only store refcounted classes.");
RefPtr<nsIInputStream> holder;
JS::Rooted<JSObject*> source(cx, &temp.ref().toObject());
if (NS_FAILED(UnwrapArg<nsIInputStream>(cx, source, getter_AddRefs(holder)))) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'postData' member of LoadURIOptions", "InputStream");
return false;
}
MOZ_ASSERT(holder);
mPostData = holder;
} else if (temp.ref().isNullOrUndefined()) {
mPostData = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'postData' member of LoadURIOptions");
return false;
}
} else {
mPostData = nullptr;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->referrerInfo_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (temp.ref().isObject()) {
static_assert(IsRefcounted<nsIReferrerInfo>::value, "We can only store refcounted classes.");
RefPtr<nsIReferrerInfo> holder;
JS::Rooted<JSObject*> source(cx, &temp.ref().toObject());
if (NS_FAILED(UnwrapArg<nsIReferrerInfo>(cx, source, getter_AddRefs(holder)))) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'referrerInfo' member of LoadURIOptions", "ReferrerInfo");
return false;
}
MOZ_ASSERT(holder);
mReferrerInfo = holder;
} else if (temp.ref().isNullOrUndefined()) {
mReferrerInfo = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'referrerInfo' member of LoadURIOptions");
return false;
}
} else {
mReferrerInfo = nullptr;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->remoteTypeOverride_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mRemoteTypeOverride.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, (mRemoteTypeOverride.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->triggeringPrincipal_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (temp.ref().isObject()) {
static_assert(IsRefcounted<nsIPrincipal>::value, "We can only store refcounted classes.");
RefPtr<nsIPrincipal> holder;
JS::Rooted<JSObject*> source(cx, &temp.ref().toObject());
if (NS_FAILED(UnwrapArg<nsIPrincipal>(cx, source, getter_AddRefs(holder)))) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'triggeringPrincipal' member of LoadURIOptions", "Principal");
return false;
}
MOZ_ASSERT(holder);
mTriggeringPrincipal = holder;
} else if (temp.ref().isNullOrUndefined()) {
mTriggeringPrincipal = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'triggeringPrincipal' member of LoadURIOptions");
return false;
}
} else {
mTriggeringPrincipal = nullptr;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->triggeringRemoteType_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mTriggeringRemoteType.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, (mTriggeringRemoteType.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->triggeringSandboxFlags_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), "'triggeringSandboxFlags' member of LoadURIOptions", &mTriggeringSandboxFlags)) {
return false;
}
} else {
mTriggeringSandboxFlags = 0U;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->triggeringStorageAccess_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), "'triggeringStorageAccess' member of LoadURIOptions", &mTriggeringStorageAccess)) {
return false;
}
} else {
mTriggeringStorageAccess = false;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->triggeringWindowId_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<uint64_t, eDefault>(cx, temp.ref(), "'triggeringWindowId' member of LoadURIOptions", &mTriggeringWindowId)) {
return false;
}
} else {
mTriggeringWindowId = 0ULL;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->wasSchemelessInput_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), "'wasSchemelessInput' member of LoadURIOptions", &mWasSchemelessInput)) {
return false;
}
} else {
mWasSchemelessInput = false;
}
mIsAnyMemberPresent = true;
return true;
}
bool
LoadURIOptions::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);
}
void
LoadURIOptions::TraceDictionary(JSTracer* trc)
{
}
LoadURIOptions&
LoadURIOptions::operator=(const LoadURIOptions& aOther)
{
DictionaryBase::operator=(aOther);
mBaseURI = aOther.mBaseURI;
mCancelContentJSEpoch = aOther.mCancelContentJSEpoch;
mCsp = aOther.mCsp;
mHasValidUserGestureActivation = aOther.mHasValidUserGestureActivation;
mHeaders = aOther.mHeaders;
mLoadFlags = aOther.mLoadFlags;
mPostData = aOther.mPostData;
mReferrerInfo = aOther.mReferrerInfo;
mRemoteTypeOverride.Reset();
if (aOther.mRemoteTypeOverride.WasPassed()) {
mRemoteTypeOverride.Construct(aOther.mRemoteTypeOverride.Value());
}
mTriggeringPrincipal = aOther.mTriggeringPrincipal;
mTriggeringRemoteType.Reset();
if (aOther.mTriggeringRemoteType.WasPassed()) {
mTriggeringRemoteType.Construct(aOther.mTriggeringRemoteType.Value());
}
mTriggeringSandboxFlags = aOther.mTriggeringSandboxFlags;
mTriggeringStorageAccess = aOther.mTriggeringStorageAccess;
mTriggeringWindowId = aOther.mTriggeringWindowId;
mWasSchemelessInput = aOther.mWasSchemelessInput;
return *this;
}
} // namespace mozilla::dom