Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM CSSPageDescriptors.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "CSSPageDescriptorsBinding.h"
#include "CSSStyleDeclarationBinding.h"
#include "MainThreadUtils.h"
#include "WrapperFactory.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/Atomics.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/CSSPageRule.h"
#include "mozilla/dom/CustomElementRegistry.h"
#include "mozilla/dom/DOMJSClass.h"
#include "mozilla/dom/DOMJSProxyHandler.h"
#include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/ProxyHandlerUtils.h"
#include "mozilla/dom/WebIDLPrefs.h"
#include "mozilla/dom/XrayExpandoClass.h"
#include "nsContentUtils.h"
#include "nsJSPrincipals.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
namespace CSSPageDescriptors_Binding {
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<CSSStyleDeclaration_Binding::NativeType>::value,
"Can't inherit from an interface with a different ownership model.");
MOZ_CAN_RUN_SCRIPT static bool
GetPropertyValue(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args, nsCSSPropertyID id)
{
const char* attrName = nsCSSProps::PropertyIDLName(id);
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"CSSPageDescriptors", attrName, DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::CSSPageRuleDeclaration*>(void_self);
nsAutoCString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->GetPropertyValue(id, result))>, "Should be returning void here");
MOZ_KnownLive(self)->GetPropertyValue(id, result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!NonVoidUTF8StringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
SetPropertyValue(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitSetterCallArgs args, nsCSSPropertyID id)
{
const char* attrName = nsCSSProps::PropertyIDLName(id);
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"CSSPageDescriptors", attrName, DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::CSSPageRuleDeclaration*>(void_self);
binding_detail::FakeString<char> arg0;
if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
return false;
}
Maybe<AutoCEReaction> ceReaction;
DocGroup* docGroup = self->GetDocGroup();
if (docGroup) {
ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
}
FastErrorResult rv;
nsIPrincipal* subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
if (principal->IsSystemPrincipal()) {
principal = nullptr;
}
subjectPrincipal = principal;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->SetPropertyValue(id, Constify(arg0), MOZ_KnownLive(subjectPrincipal), rv))>, "Should be returning void here");
MOZ_KnownLive(self)->SetPropertyValue(id, Constify(arg0), MOZ_KnownLive(subjectPrincipal), rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, ErrorDescriptionFor<ErrorFor::setter>{ "CSSPageDescriptors", attrName }))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
get_pageOrientation(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
return CSSPageDescriptors_Binding::GetPropertyValue(cx, obj, void_self, args, eCSSProperty_page_orientation);
}
MOZ_CAN_RUN_SCRIPT static bool
set_pageOrientation(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitSetterCallArgs args)
{
return CSSPageDescriptors_Binding::SetPropertyValue(cx, obj, void_self, args, eCSSProperty_page_orientation);
}
static const JSJitInfo pageOrientation_getterinfo = {
{ get_pageOrientation },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
static const JSJitInfo pageOrientation_setterinfo = {
{ (JSJitGetterOp)set_pageOrientation },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Setter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
get_size(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
return CSSPageDescriptors_Binding::GetPropertyValue(cx, obj, void_self, args, eCSSProperty_size);
}
MOZ_CAN_RUN_SCRIPT static bool
set_size(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitSetterCallArgs args)
{
return CSSPageDescriptors_Binding::SetPropertyValue(cx, obj, void_self, args, eCSSProperty_size);
}
static const JSJitInfo size_getterinfo = {
{ get_size },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
static const JSJitInfo size_setterinfo = {
{ (JSJitGetterOp)set_size },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Setter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
get_marginBottom(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
return CSSPageDescriptors_Binding::GetPropertyValue(cx, obj, void_self, args, eCSSProperty_margin_bottom);
}
MOZ_CAN_RUN_SCRIPT static bool
set_marginBottom(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitSetterCallArgs args)
{
return CSSPageDescriptors_Binding::SetPropertyValue(cx, obj, void_self, args, eCSSProperty_margin_bottom);
}
static const JSJitInfo marginBottom_getterinfo = {
{ get_marginBottom },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
static const JSJitInfo marginBottom_setterinfo = {
{ (JSJitGetterOp)set_marginBottom },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Setter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
get_marginLeft(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
return CSSPageDescriptors_Binding::GetPropertyValue(cx, obj, void_self, args, eCSSProperty_margin_left);
}
MOZ_CAN_RUN_SCRIPT static bool
set_marginLeft(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitSetterCallArgs args)
{
return CSSPageDescriptors_Binding::SetPropertyValue(cx, obj, void_self, args, eCSSProperty_margin_left);
}
static const JSJitInfo marginLeft_getterinfo = {
{ get_marginLeft },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
static const JSJitInfo marginLeft_setterinfo = {
{ (JSJitGetterOp)set_marginLeft },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Setter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
get_marginRight(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
return CSSPageDescriptors_Binding::GetPropertyValue(cx, obj, void_self, args, eCSSProperty_margin_right);
}
MOZ_CAN_RUN_SCRIPT static bool
set_marginRight(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitSetterCallArgs args)
{
return CSSPageDescriptors_Binding::SetPropertyValue(cx, obj, void_self, args, eCSSProperty_margin_right);
}
static const JSJitInfo marginRight_getterinfo = {
{ get_marginRight },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
static const JSJitInfo marginRight_setterinfo = {
{ (JSJitGetterOp)set_marginRight },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Setter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
get_marginTop(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
return CSSPageDescriptors_Binding::GetPropertyValue(cx, obj, void_self, args, eCSSProperty_margin_top);
}
MOZ_CAN_RUN_SCRIPT static bool
set_marginTop(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitSetterCallArgs args)
{
return CSSPageDescriptors_Binding::SetPropertyValue(cx, obj, void_self, args, eCSSProperty_margin_top);
}
static const JSJitInfo marginTop_getterinfo = {
{ get_marginTop },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
static const JSJitInfo marginTop_setterinfo = {
{ (JSJitGetterOp)set_marginTop },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Setter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
get_margin(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
return CSSPageDescriptors_Binding::GetPropertyValue(cx, obj, void_self, args, eCSSProperty_margin);
}
MOZ_CAN_RUN_SCRIPT static bool
set_margin(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitSetterCallArgs args)
{
return CSSPageDescriptors_Binding::SetPropertyValue(cx, obj, void_self, args, eCSSProperty_margin);
}
static const JSJitInfo margin_getterinfo = {
{ get_margin },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
static const JSJitInfo margin_setterinfo = {
{ (JSJitGetterOp)set_margin },
{ prototypes::id::CSSPageDescriptors },
{ PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth },
JSJitInfo::Setter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_GLOBINIT static const JSFunctionSpec sMethods_specs[] = {
JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "$ArrayValues"),
JS_FS_END
};
static const Prefable<const JSFunctionSpec> sMethods[] = {
{ nullptr, &sMethods_specs[0] },
{ nullptr, nullptr }
};
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
"We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
"We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
MOZ_GLOBINIT static const JSPropertySpec sAttributes_specs[] = {
JSPropertySpec::nativeAccessors("pageOrientation", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pageOrientation_getterinfo, GenericSetter<NormalThisPolicy>, &pageOrientation_setterinfo),
JSPropertySpec::nativeAccessors("page-orientation", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pageOrientation_getterinfo, GenericSetter<NormalThisPolicy>, &pageOrientation_setterinfo),
JS_PS_END,
JSPropertySpec::nativeAccessors("size", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &size_getterinfo, GenericSetter<NormalThisPolicy>, &size_setterinfo),
JSPropertySpec::nativeAccessors("marginBottom", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &marginBottom_getterinfo, GenericSetter<NormalThisPolicy>, &marginBottom_setterinfo),
JSPropertySpec::nativeAccessors("margin-bottom", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &marginBottom_getterinfo, GenericSetter<NormalThisPolicy>, &marginBottom_setterinfo),
JSPropertySpec::nativeAccessors("marginLeft", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &marginLeft_getterinfo, GenericSetter<NormalThisPolicy>, &marginLeft_setterinfo),
JSPropertySpec::nativeAccessors("margin-left", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &marginLeft_getterinfo, GenericSetter<NormalThisPolicy>, &marginLeft_setterinfo),
JSPropertySpec::nativeAccessors("marginRight", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &marginRight_getterinfo, GenericSetter<NormalThisPolicy>, &marginRight_setterinfo),
JSPropertySpec::nativeAccessors("margin-right", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &marginRight_getterinfo, GenericSetter<NormalThisPolicy>, &marginRight_setterinfo),
JSPropertySpec::nativeAccessors("marginTop", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &marginTop_getterinfo, GenericSetter<NormalThisPolicy>, &marginTop_setterinfo),
JSPropertySpec::nativeAccessors("margin-top", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &marginTop_getterinfo, GenericSetter<NormalThisPolicy>, &marginTop_setterinfo),
JSPropertySpec::nativeAccessors("margin", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &margin_getterinfo, GenericSetter<NormalThisPolicy>, &margin_setterinfo),
JS_PS_END
};
static const PrefableDisablers sAttributes_disablers0 = {
WebIDLPrefIndex::layout_css_page_orientation_enabled, 0, false, OriginTrial(0), nullptr
};
static const Prefable<const JSPropertySpec> sAttributes[] = {
{ &sAttributes_disablers0, &sAttributes_specs[0] },
{ nullptr, &sAttributes_specs[3] },
{ nullptr, nullptr }
};
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
"We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
"We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
static uint16_t sNativeProperties_sortedPropertyIndices[13];
static PropertyInfo sNativeProperties_propertyInfos[13];
static const NativePropertiesN<2> sNativeProperties = {
false, 0,
false, 0,
true, 0 /* sMethods */,
true, 1 /* sAttributes */,
false, 0,
false, 0,
false, 0,
-1,
13,
sNativeProperties_sortedPropertyIndices,
{
{ sMethods, &sNativeProperties_propertyInfos[0] },
{ sAttributes, &sNativeProperties_propertyInfos[1] }
}
};
static_assert(13 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount)),
"We have a property info count that is oversized");
static_assert(std::is_base_of_v<nsISupports, mozilla::dom::CSSPageRuleDeclaration>,
"We don't support non-nsISupports native classes for "
"proxy-based bindings yet");
class DOMProxyHandler : public mozilla::dom::DOMProxyHandler
{
public:
using Base = mozilla::dom::DOMProxyHandler;
explicit constexpr DOMProxyHandler()
{
}
bool
getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<Maybe<JS::PropertyDescriptor>> desc) const override;
bool
defineProperty(JSContext* cx_, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* done) const override;
using mozilla::dom::DOMProxyHandler::defineProperty;
bool
ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::MutableHandleVector<jsid> props) const override;
bool
hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
bool
get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
const char*
className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
bool
finalizeInBackground(const JS::Value& priv) const override;
void
finalize(JS::GCContext* gcx, JSObject* proxy) const override;
static const DOMProxyHandler*
getInstance();
bool
delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
bool
getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
bool
canNurseryAllocate() const override;
size_t
objectMoved(JSObject* obj, JSObject* old) const override;
};
MOZ_ALWAYS_INLINE bool
IsProxy(JSObject* obj)
{
return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
}
MOZ_ALWAYS_INLINE mozilla::dom::CSSPageRuleDeclaration*
UnwrapProxy(JSObject* obj)
{
MOZ_ASSERT(js::IsProxy(obj));
if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
obj = js::UncheckedUnwrap(obj);
}
MOZ_ASSERT(IsProxy(obj));
return static_cast<mozilla::dom::CSSPageRuleDeclaration*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
}
const NativeNamedOrIndexedPropertyHooks sNativeNamedOrIndexedPropertyHooks = {
binding_detail::ResolveOwnProperty,
binding_detail::EnumerateOwnProperties,
nullptr
};
bool sNativePropertiesInited = false;
const NativePropertyHooks sNativePropertyHooks = {
&sNativeNamedOrIndexedPropertyHooks,
{ sNativeProperties.Upcast(), nullptr, &sNativePropertiesInited },
prototypes::id::CSSPageDescriptors,
constructors::id::CSSPageDescriptors,
&DefaultXrayExpandoObjectClass
};
static const DOMInterfaceInfo sInterfaceObjectInfo = {
{ ThrowingConstructor, &sNativePropertyHooks },
CSSStyleDeclaration_Binding::GetConstructorObjectHandle,
PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth,
prototypes::id::CSSPageDescriptors,
true,
0,
"CSSPageDescriptors",
};
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
{
"CSSPageDescriptorsPrototype",
JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
JS_NULL_CLASS_OPS,
JS_NULL_CLASS_SPEC,
JS_NULL_CLASS_EXT,
JS_NULL_OBJECT_OPS
},
eInterfacePrototype,
prototypes::id::CSSPageDescriptors,
PrototypeTraits<prototypes::id::CSSPageDescriptors>::Depth,
&sNativePropertyHooks,
CSSStyleDeclaration_Binding::GetProtoObject
};
static JS::Handle<JSObject*>
GetProtoObjectHandle(JSContext* aCx);
bool
DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<Maybe<JS::PropertyDescriptor>> desc) const
{
bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
uint32_t index = GetArrayIndexFromId(id);
if (IsArrayIndex(index)) {
JS::Rooted<JS::Value> value(cx);
mozilla::dom::CSSPageRuleDeclaration* self = UnwrapProxy(proxy);
bool found = false;
nsAutoCString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->IndexedGetter(index, found, result))>, "Should be returning void here");
MOZ_KnownLive(self)->IndexedGetter(index, found, result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (found) {
if (!NonVoidUTF8StringToJsval(cx, result, &value)) {
return false;
}
desc.set(mozilla::Some(JS::PropertyDescriptor::Data(value, { JS::PropertyAttribute::Configurable, JS::PropertyAttribute::Enumerable })));
return true;
}
}
JS::Rooted<JSObject*> expando(cx);
if (!isXray &&(expando = GetExpandoObject(proxy))) {
if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
return false;
}
if (desc.isSome()) {
return true;
}
}
desc.reset();
return true;
}
bool
DOMProxyHandler::defineProperty(JSContext* cx_, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* done) const
{
if (IsArrayIndex(GetArrayIndexFromId(id))) {
*done = true;
return opresult.failNoIndexedSetter();
}
return mozilla::dom::DOMProxyHandler::defineProperty(cx_, proxy, id, desc, opresult, done);
}
bool
DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::MutableHandleVector<jsid> props) const
{
bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
uint32_t length = UnwrapProxy(proxy)->Length();
MOZ_ASSERT(int32_t(length) >= 0);
for (int32_t i = 0; i < int32_t(length); ++i) {
if (!props.append(JS::PropertyKey::Int(i))) {
return false;
}
}
JS::Rooted<JSObject*> expando(cx);
if (!isXray &&(expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
!js::GetPropertyKeys(cx, expando, flags, props)) {
return false;
}
return true;
}
bool
DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
{
MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
"Should not have a XrayWrapper here");
uint32_t index = GetArrayIndexFromId(id);
if (IsArrayIndex(index)) {
bool found = false;
mozilla::dom::CSSPageRuleDeclaration* self = UnwrapProxy(proxy);
nsAutoCString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->IndexedGetter(index, found, result))>, "Should be returning void here");
MOZ_KnownLive(self)->IndexedGetter(index, found, result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
(void)result;
*bp = found;
return true;
}
JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
if (expando) {
bool b = true;
bool ok = JS_HasPropertyById(cx, expando, id, &b);
*bp = !!b;
if (!ok || *bp) {
return ok;
}
}
*bp = false;
return true;
}
bool
DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
{
MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
"Should not have a XrayWrapper here");
uint32_t index = GetArrayIndexFromId(id);
if (IsArrayIndex(index)) {
mozilla::dom::CSSPageRuleDeclaration* self = UnwrapProxy(proxy);
bool found = false;
nsAutoCString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->IndexedGetter(index, found, result))>, "Should be returning void here");
MOZ_KnownLive(self)->IndexedGetter(index, found, result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (found) {
if (!NonVoidUTF8StringToJsval(cx, result, vp)) {
return false;
}
return true;
}
// Even if we don't have this index, we don't forward the
// get on to our expando object.
} else {
bool expandoHasProp = false;
{ // Scope for expando
JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
if (expando) {
if (!JS_HasPropertyById(cx, expando, id, &expandoHasProp)) {
return false;
}
if (expandoHasProp) {
// Forward the get to the expando object, but our receiver is whatever our
// receiver is.
if (!JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp)) {
return false;
}
}
}
}
if (expandoHasProp) {
return true;
}
}
bool foundOnPrototype;
if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
return false;
}
if (foundOnPrototype) {
return true;
}
MOZ_ASSERT(vp.isUndefined());
return true;
}
const char*
DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
{
return "CSSPageDescriptors";
}
bool
DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
{
return false;
}
void
DOMProxyHandler::finalize(JS::GCContext* gcx, JSObject* proxy) const
{
mozilla::dom::CSSPageRuleDeclaration* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CSSPageRuleDeclaration>(proxy);
if (self) {
JS::SetReservedSlot(proxy, DOM_OBJECT_SLOT, JS::UndefinedValue());
ClearWrapper(self, self, proxy);
if (size_t mallocBytes = BindingJSObjectMallocBytes(self)) {
JS::RemoveAssociatedMemory(proxy, mallocBytes,
JS::MemoryUse::DOMBinding);
}
AddForDeferredFinalization<mozilla::dom::CSSPageRuleDeclaration>(self);
}
}
const DOMProxyHandler*
DOMProxyHandler::getInstance()
{
static const DOMProxyHandler instance;
return &instance;
}
bool
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
{
MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
"Should not have a XrayWrapper here");
uint32_t index = GetArrayIndexFromId(id);
if (IsArrayIndex(index)) {
bool deleteSucceeded;
bool found = false;
mozilla::dom::CSSPageRuleDeclaration* self = UnwrapProxy(proxy);
nsAutoCString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->IndexedGetter(index, found, result))>, "Should be returning void here");
MOZ_KnownLive(self)->IndexedGetter(index, found, result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
(void)result;
deleteSucceeded = !found;
return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
}
return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
}
bool
DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
{
JS::Rooted<JS::Value> temp(cx);
MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
"Should not have a XrayWrapper here");
mozilla::dom::CSSPageRuleDeclaration* self = UnwrapProxy(proxy);
uint32_t length = self->Length();
// Compute the end of the indices we'll get ourselves
uint32_t ourEnd = std::clamp(length, begin, end);
for (uint32_t index = begin; index < ourEnd; ++index) {
bool found = false;
nsAutoCString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->IndexedGetter(index, found, result))>, "Should be returning void here");
MOZ_KnownLive(self)->IndexedGetter(index, found, result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
MOZ_ASSERT(found);
if (!NonVoidUTF8StringToJsval(cx, result, &temp)) {
return false;
}
if (!adder->append(cx, temp)) return false;
continue;
}
if (end > ourEnd) {
JS::Rooted<JSObject*> proto(cx);
if (!js::GetObjectProto(cx, proxy, &proto)) {
return false;
}
return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
}
return true;
}
bool
DOMProxyHandler::canNurseryAllocate() const
{
return true;
}
size_t
DOMProxyHandler::objectMoved(JSObject* obj, JSObject* old) const
{
mozilla::dom::CSSPageRuleDeclaration* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CSSPageRuleDeclaration>(obj);
if (self) {
UpdateWrapper(self, self, obj, old);
}
return 0;
}
static const DOMJSClass sClass = {
PROXY_CLASS_DEF("CSSPageDescriptors",
JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1)),
{ prototypes::id::CSSStyleDeclaration, prototypes::id::CSSPageDescriptors, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
std::is_base_of_v<nsISupports, mozilla::dom::CSSPageRuleDeclaration>,
&sNativePropertyHooks,
FindAssociatedGlobalForNative<mozilla::dom::CSSPageRuleDeclaration>::Get,
GetProtoObjectHandle,
GetCCParticipant<mozilla::dom::CSSPageRuleDeclaration>::Get(),
nullptr,
nullptr
};
bool
Wrap(JSContext* aCx, mozilla::dom::CSSPageRuleDeclaration* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
{
static_assert(!std::is_base_of_v<NonRefcountedDOMObject, mozilla::dom::CSSPageRuleDeclaration>,
"Shouldn't have wrappercached things that are not refcounted.");
static_assert(std::is_same_v<decltype(aObject), mozilla::dom::CSSPageRuleDeclaration*>);
MOZ_ASSERT(static_cast<nsICSSDeclaration*>(aObject) ==
reinterpret_cast<nsICSSDeclaration*>(aObject),
"Multiple inheritance for nsICSSDeclaration is broken.");
MOZ_ASSERT(ToSupportsIsCorrect(aObject));
MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
MOZ_ASSERT(!aCache->GetWrapper(),
"You should probably not be using Wrap() directly; use "
"GetOrCreateDOMReflector instead");
MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
"nsISupports must be on our primary inheritance chain");
// If the wrapper cache contains a dead reflector then finalize that
// now, ensuring that the finalizer for the old reflector always
// runs before the new reflector is created and attached. This
// avoids the awkward situation where there are multiple reflector
// objects that contain pointers to the same native.
if (JSObject* oldReflector = aCache->GetWrapperMaybeDead()) {
DOMProxyHandler::getInstance()->finalize(nullptr /* unused */, oldReflector);
MOZ_ASSERT(!aCache->GetWrapperMaybeDead());
}
JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
if (!global) {
return false;
}
MOZ_ASSERT(JS_IsGlobalObject(global));
JS::AssertObjectIsNotGray(global);
// That might have ended up wrapping us already, due to the wonders
// of XBL. Check for that, and bail out as needed.
aReflector.set(aCache->GetWrapper());
if (aReflector) {
#ifdef DEBUG
AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
#endif // DEBUG
return true;
}
JSAutoRealm ar(aCx, global);
JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
if (!canonicalProto) {
return false;
}
JS::Rooted<JSObject*> proto(aCx);
if (aGivenProto) {
proto = aGivenProto;
// Unfortunately, while aGivenProto was in the compartment of aCx
// coming in, we changed compartments to that of "parent" so may need
// to wrap the proto here.
if (js::GetContextCompartment(aCx) != JS::GetCompartment(proto)) {
if (!JS_WrapObject(aCx, &proto)) {
return false;
}
}
} else {
proto = canonicalProto;
}
BindingJSObjectCreator<mozilla::dom::CSSPageRuleDeclaration> creator(aCx);
creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
proto, /* aLazyProto = */ false,
aObject, JS::UndefinedHandleValue, aReflector);
if (!aReflector) {
return false;
}
aCache->SetWrapper(aReflector);
creator.InitializationSucceeded();
MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
aCache->GetWrapperPreserveColor() == aReflector);
// If proto != canonicalProto, we have to preserve our wrapper;
// otherwise we won't be able to properly recreate it later, since
// we won't know what proto to use. Note that we don't check
// aGivenProto here, since it's entirely possible (and even
// somewhat common) to have a non-null aGivenProto which is the
// same as canonicalProto.
if (proto != canonicalProto) {
PreserveWrapper(aObject);
}
return true;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal)
{
JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CSSPageDescriptors);
JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CSSPageDescriptors);
JS::Handle<JSObject*> parentProto(CSSStyleDeclaration_Binding::GetProtoObjectHandle(aCx));
if (!parentProto) {
return;
}
JS::Handle<JSObject*> constructorProto(CSSStyleDeclaration_Binding::GetConstructorObjectHandle(aCx));
if (!constructorProto) {
return;
}
dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
&sPrototypeClass, protoCache,
constructorProto, &sInterfaceObjectInfo, 0, false, Span<const LegacyFactoryFunction, 0>{},
interfaceCache,
sNativeProperties.Upcast(),
nullptr,
"CSSPageDescriptors",
aDefineOnGlobal != DefineInterfaceProperty::No,
nullptr,
false,
nullptr);
}
static JS::Handle<JSObject*>
GetProtoObjectHandle(JSContext* aCx)
{
/* Get the interface prototype object for this class. This will create the
object as needed. */
return GetPerInterfaceObjectHandle(aCx, prototypes::id::CSSPageDescriptors,
&CreateInterfaceObjects,
DefineInterfaceProperty::CheckExposure);
}
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx)
{
/* Get the interface object for this class. This will create the object as
needed. */
return GetPerInterfaceObjectHandle(aCx, constructors::id::CSSPageDescriptors,
&CreateInterfaceObjects,
DefineInterfaceProperty::CheckExposure);
}
} // namespace CSSPageDescriptors_Binding
} // namespace mozilla::dom