Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM DebuggerUtils.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "DebuggerUtilsBinding.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/BindingUtils.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SimpleGlobalObject.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
HTMLContent::HTMLContent()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
HTMLContent::InitIds(JSContext* cx, HTMLContentAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->uri_id.init(cx, "uri") ||
!atomsCache->parserID_id.init(cx, "parserID") ||
!atomsCache->contents_id.init(cx, "contents") ||
!atomsCache->complete_id.init(cx, "complete")) {
return false;
}
return true;
}
bool
HTMLContent::Init(const char* sourceDescription, bool passedToJSImpl)
{
return true;
}
bool
HTMLContent::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
HTMLContentAtoms* atomsCache = GetAtomCache<HTMLContentAtoms>(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 (mComplete.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
bool const & currentValue = mComplete.InternalValue();
temp.setBoolean(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->complete_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mContents.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mContents.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->contents_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mParserID.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mParserID.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->parserID_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mUri.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mUri.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->uri_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
bool
HTMLContent::ToJSON(nsAString& aJSON) const
{
AutoJSAPI jsapi;
jsapi.Init();
JSContext *cx = jsapi.cx();
// It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
// because we'll only be creating objects, in ways that have no
// side-effects, followed by a call to JS::ToJSONMaybeSafely,
// which likewise guarantees no side-effects for the sorts of
// things we will pass it.
JSObject* scope = UnprivilegedJunkScopeOrWorkerGlobal(fallible);
if (!scope) {
JS_ReportOutOfMemory(cx);
return false;
}
JSAutoRealm ar(cx, scope);
JS::Rooted<JS::Value> val(cx);
if (!ToObjectInternal(cx, &val)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, &val.toObject());
return StringifyToJSON(cx, obj, aJSON);
}
void
HTMLContent::TraceDictionary(JSTracer* trc)
{
}
HTMLContent&
HTMLContent::operator=(const HTMLContent& aOther)
{
DictionaryBase::operator=(aOther);
mComplete.Reset();
if (aOther.mComplete.WasPassed()) {
mComplete.Construct(aOther.mComplete.Value());
}
mContents.Reset();
if (aOther.mContents.WasPassed()) {
mContents.Construct(aOther.mContents.Value());
}
mParserID.Reset();
if (aOther.mParserID.WasPassed()) {
mParserID.Construct(aOther.mParserID.Value());
}
mUri.Reset();
if (aOther.mUri.WasPassed()) {
mUri.Construct(aOther.mUri.Value());
}
return *this;
}
bool
HTMLContent::operator==(const HTMLContent& aOther) const
{
if (mComplete != aOther.mComplete) {
return false;
}
if (mContents != aOther.mContents) {
return false;
}
if (mParserID != aOther.mParserID) {
return false;
}
if (mUri != aOther.mUri) {
return false;
}
return true;
}
} // namespace mozilla::dom