Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM CSSPageRule.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "CSSPageRuleBinding.h"
4 : #include "CSSRuleBinding.h"
5 : #include "WrapperFactory.h"
6 : #include "mozilla/OwningNonNull.h"
7 : #include "mozilla/dom/BindingUtils.h"
8 : #include "mozilla/dom/CSSPageRule.h"
9 : #include "mozilla/dom/DOMJSClass.h"
10 : #include "mozilla/dom/NonRefcountedDOMObject.h"
11 : #include "mozilla/dom/XrayExpandoClass.h"
12 : #include "nsICSSDeclaration.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : namespace CSSPageRuleBinding {
18 :
19 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<CSSRuleBinding::NativeType>::value,
20 : "Can't inherit from an interface with a different ownership model.");
21 :
22 : static bool
23 0 : get_style(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CSSPageRule* self, JSJitGetterCallArgs args)
24 : {
25 0 : auto result(StrongOrRawPtr<nsICSSDeclaration>(self->Style()));
26 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
27 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
28 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
29 0 : return false;
30 : }
31 0 : return true;
32 : }
33 :
34 : static bool
35 0 : set_style(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CSSPageRule* self, JSJitSetterCallArgs args)
36 : {
37 0 : JS::Rooted<JS::Value> v(cx);
38 0 : if (!JS_GetProperty(cx, obj, "style", &v)) {
39 0 : return false;
40 : }
41 :
42 0 : if (!v.isObject()) {
43 0 : return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "CSSPageRule.style");
44 : }
45 :
46 0 : JS::Rooted<JSObject*> targetObj(cx, &v.toObject());
47 0 : return JS_SetProperty(cx, targetObj, "cssText", args[0]);
48 : }
49 :
50 : static const JSJitInfo style_getterinfo = {
51 : { (JSJitGetterOp)get_style },
52 : { prototypes::id::CSSPageRule },
53 : { PrototypeTraits<prototypes::id::CSSPageRule>::Depth },
54 : JSJitInfo::Getter,
55 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
56 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
57 : false, /* isInfallible. False in setters. */
58 : true, /* isMovable. Not relevant for setters. */
59 : true, /* isEliminatable. Not relevant for setters. */
60 : false, /* isAlwaysInSlot. Only relevant for getters. */
61 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
62 : false, /* isTypedMethod. Only relevant for methods. */
63 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
64 : };
65 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
66 : static_assert(0 < 1, "There is no slot for us");
67 : static const JSJitInfo style_setterinfo = {
68 : { (JSJitGetterOp)set_style },
69 : { prototypes::id::CSSPageRule },
70 : { PrototypeTraits<prototypes::id::CSSPageRule>::Depth },
71 : JSJitInfo::Setter,
72 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
73 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
74 : false, /* isInfallible. False in setters. */
75 : false, /* isMovable. Not relevant for setters. */
76 : false, /* isEliminatable. Not relevant for setters. */
77 : false, /* isAlwaysInSlot. Only relevant for getters. */
78 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
79 : false, /* isTypedMethod. Only relevant for methods. */
80 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
81 : };
82 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
83 : static_assert(0 < 1, "There is no slot for us");
84 :
85 : static bool
86 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
87 : {
88 0 : mozilla::dom::CSSPageRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CSSPageRule>(obj);
89 : // We don't want to preserve if we don't have a wrapper, and we
90 : // obviously can't preserve if we're not initialized.
91 0 : if (self && self->GetWrapperPreserveColor()) {
92 0 : PreserveWrapper(self);
93 : }
94 0 : return true;
95 : }
96 :
97 : static void
98 0 : _finalize(js::FreeOp* fop, JSObject* obj)
99 : {
100 0 : mozilla::dom::CSSPageRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CSSPageRule>(obj);
101 0 : if (self) {
102 0 : ClearWrapper(self, self, obj);
103 0 : AddForDeferredFinalization<mozilla::dom::CSSPageRule>(self);
104 : }
105 0 : }
106 :
107 : static void
108 0 : _objectMoved(JSObject* obj, const JSObject* old)
109 : {
110 0 : mozilla::dom::CSSPageRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CSSPageRule>(obj);
111 0 : if (self) {
112 0 : UpdateWrapper(self, self, obj, old);
113 : }
114 0 : }
115 :
116 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
117 : #if defined(__clang__)
118 : #pragma clang diagnostic push
119 : #pragma clang diagnostic ignored "-Wmissing-braces"
120 : #endif
121 : static const JSPropertySpec sAttributes_specs[] = {
122 : { "style", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &style_getterinfo, GenericBindingSetter, &style_setterinfo },
123 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
124 : };
125 : #if defined(__clang__)
126 : #pragma clang diagnostic pop
127 : #endif
128 :
129 :
130 : // Can't be const because the pref-enabled boolean needs to be writable
131 : static Prefable<const JSPropertySpec> sAttributes[] = {
132 : { nullptr, &sAttributes_specs[0] },
133 : { nullptr, nullptr }
134 : };
135 :
136 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
137 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
138 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
139 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
140 :
141 :
142 : static uint16_t sNativeProperties_sortedPropertyIndices[1];
143 : static PropertyInfo sNativeProperties_propertyInfos[1];
144 :
145 : static const NativePropertiesN<1> sNativeProperties = {
146 : false, 0,
147 : false, 0,
148 : false, 0,
149 : true, 0 /* sAttributes */,
150 : false, 0,
151 : false, 0,
152 : false, 0,
153 : -1,
154 : 1,
155 : sNativeProperties_sortedPropertyIndices,
156 : {
157 : { sAttributes, &sNativeProperties_propertyInfos[0] }
158 : }
159 : };
160 : static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
161 : "We have a property info count that is oversized");
162 :
163 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
164 : {
165 : "Function",
166 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
167 : &sBoringInterfaceObjectClassClassOps,
168 : JS_NULL_CLASS_SPEC,
169 : JS_NULL_CLASS_EXT,
170 : &sInterfaceObjectClassObjectOps
171 : },
172 : eInterface,
173 : true,
174 : prototypes::id::CSSPageRule,
175 : PrototypeTraits<prototypes::id::CSSPageRule>::Depth,
176 : sNativePropertyHooks,
177 : "function CSSPageRule() {\n [native code]\n}",
178 : CSSRuleBinding::GetConstructorObject
179 : };
180 :
181 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
182 : {
183 : "CSSPageRulePrototype",
184 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
185 : JS_NULL_CLASS_OPS,
186 : JS_NULL_CLASS_SPEC,
187 : JS_NULL_CLASS_EXT,
188 : JS_NULL_OBJECT_OPS
189 : },
190 : eInterfacePrototype,
191 : false,
192 : prototypes::id::CSSPageRule,
193 : PrototypeTraits<prototypes::id::CSSPageRule>::Depth,
194 : sNativePropertyHooks,
195 : "[object CSSPageRulePrototype]",
196 : CSSRuleBinding::GetProtoObject
197 : };
198 :
199 : JSObject*
200 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
201 : {
202 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
203 : }
204 :
205 : static const js::ClassOps sClassOps = {
206 : _addProperty, /* addProperty */
207 : nullptr, /* delProperty */
208 : nullptr, /* getProperty */
209 : nullptr, /* setProperty */
210 : nullptr, /* enumerate */
211 : nullptr, /* newEnumerate */
212 : nullptr, /* resolve */
213 : nullptr, /* mayResolve */
214 : _finalize, /* finalize */
215 : nullptr, /* call */
216 : nullptr, /* hasInstance */
217 : nullptr, /* construct */
218 : nullptr, /* trace */
219 : };
220 :
221 : static const js::ClassExtension sClassExtension = {
222 : nullptr, /* weakmapKeyDelegateOp */
223 : _objectMoved /* objectMovedOp */
224 : };
225 :
226 : static const DOMJSClass sClass = {
227 : { "CSSPageRule",
228 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
229 : &sClassOps,
230 : JS_NULL_CLASS_SPEC,
231 : &sClassExtension,
232 : JS_NULL_OBJECT_OPS
233 : },
234 : { prototypes::id::CSSRule, prototypes::id::CSSPageRule, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
235 : IsBaseOf<nsISupports, mozilla::dom::CSSPageRule >::value,
236 : sNativePropertyHooks,
237 : FindAssociatedGlobalForNative<mozilla::dom::CSSPageRule>::Get,
238 : GetProtoObjectHandle,
239 : GetCCParticipant<mozilla::dom::CSSPageRule>::Get()
240 : };
241 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
242 : "Must have the right minimal number of reserved slots.");
243 : static_assert(1 >= 1,
244 : "Must have enough reserved slots.");
245 :
246 : const JSClass*
247 0 : GetJSClass()
248 : {
249 0 : return sClass.ToJSClass();
250 : }
251 :
252 : bool
253 0 : Wrap(JSContext* aCx, mozilla::dom::CSSPageRule* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
254 : {
255 : MOZ_ASSERT(static_cast<mozilla::dom::CSSPageRule*>(aObject) ==
256 : reinterpret_cast<mozilla::dom::CSSPageRule*>(aObject),
257 : "Multiple inheritance for mozilla::dom::CSSPageRule is broken.");
258 : MOZ_ASSERT(static_cast<mozilla::css::Rule*>(aObject) ==
259 : reinterpret_cast<mozilla::css::Rule*>(aObject),
260 : "Multiple inheritance for mozilla::css::Rule is broken.");
261 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
262 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
263 0 : MOZ_ASSERT(!aCache->GetWrapper(),
264 : "You should probably not be using Wrap() directly; use "
265 : "GetOrCreateDOMReflector instead");
266 :
267 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
268 : "nsISupports must be on our primary inheritance chain");
269 :
270 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
271 0 : if (!global) {
272 0 : return false;
273 : }
274 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
275 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
276 :
277 : // That might have ended up wrapping us already, due to the wonders
278 : // of XBL. Check for that, and bail out as needed.
279 0 : aReflector.set(aCache->GetWrapper());
280 0 : if (aReflector) {
281 : #ifdef DEBUG
282 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
283 : #endif // DEBUG
284 0 : return true;
285 : }
286 :
287 0 : JSAutoCompartment ac(aCx, global);
288 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
289 0 : if (!canonicalProto) {
290 0 : return false;
291 : }
292 0 : JS::Rooted<JSObject*> proto(aCx);
293 0 : if (aGivenProto) {
294 0 : proto = aGivenProto;
295 : // Unfortunately, while aGivenProto was in the compartment of aCx
296 : // coming in, we changed compartments to that of "parent" so may need
297 : // to wrap the proto here.
298 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
299 0 : if (!JS_WrapObject(aCx, &proto)) {
300 0 : return false;
301 : }
302 : }
303 : } else {
304 0 : proto = canonicalProto;
305 : }
306 :
307 0 : BindingJSObjectCreator<mozilla::dom::CSSPageRule> creator(aCx);
308 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
309 0 : if (!aReflector) {
310 0 : return false;
311 : }
312 :
313 0 : aCache->SetWrapper(aReflector);
314 0 : creator.InitializationSucceeded();
315 :
316 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
317 : aCache->GetWrapperPreserveColor() == aReflector);
318 : // If proto != canonicalProto, we have to preserve our wrapper;
319 : // otherwise we won't be able to properly recreate it later, since
320 : // we won't know what proto to use. Note that we don't check
321 : // aGivenProto here, since it's entirely possible (and even
322 : // somewhat common) to have a non-null aGivenProto which is the
323 : // same as canonicalProto.
324 0 : if (proto != canonicalProto) {
325 0 : PreserveWrapper(aObject);
326 : }
327 :
328 0 : return true;
329 : }
330 :
331 : const NativePropertyHooks sNativePropertyHooks[] = { {
332 : nullptr,
333 : nullptr,
334 : nullptr,
335 : { sNativeProperties.Upcast(), nullptr },
336 : prototypes::id::CSSPageRule,
337 : constructors::id::CSSPageRule,
338 : CSSRuleBinding::sNativePropertyHooks,
339 : &DefaultXrayExpandoObjectClass
340 : } };
341 :
342 : void
343 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
344 : {
345 0 : JS::Handle<JSObject*> parentProto(CSSRuleBinding::GetProtoObjectHandle(aCx));
346 0 : if (!parentProto) {
347 0 : return;
348 : }
349 :
350 0 : JS::Handle<JSObject*> constructorProto(CSSRuleBinding::GetConstructorObjectHandle(aCx));
351 0 : if (!constructorProto) {
352 0 : return;
353 : }
354 :
355 : static bool sIdsInited = false;
356 0 : if (!sIdsInited && NS_IsMainThread()) {
357 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
358 0 : return;
359 : }
360 0 : sIdsInited = true;
361 : }
362 :
363 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CSSPageRule);
364 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CSSPageRule);
365 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
366 : &sPrototypeClass.mBase, protoCache,
367 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
368 : interfaceCache,
369 : sNativeProperties.Upcast(),
370 : nullptr,
371 : "CSSPageRule", aDefineOnGlobal,
372 : nullptr,
373 0 : false);
374 : }
375 :
376 : JS::Handle<JSObject*>
377 0 : GetProtoObjectHandle(JSContext* aCx)
378 : {
379 : /* Get the interface prototype object for this class. This will create the
380 : object as needed. */
381 0 : bool aDefineOnGlobal = true;
382 :
383 : /* Make sure our global is sane. Hopefully we can remove this sometime */
384 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
385 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
386 0 : return nullptr;
387 : }
388 :
389 : /* Check to see whether the interface objects are already installed */
390 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
391 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::CSSPageRule)) {
392 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
393 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
394 : }
395 :
396 : /*
397 : * The object might _still_ be null, but that's OK.
398 : *
399 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
400 : * traced by TraceProtoAndIfaceCache() and its contents are never
401 : * changed after they have been set.
402 : *
403 : * Calling address() avoids the read read barrier that does gray
404 : * unmarking, but it's not possible for the object to be gray here.
405 : */
406 :
407 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::CSSPageRule);
408 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
409 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
410 : }
411 :
412 : JS::Handle<JSObject*>
413 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
414 : {
415 : /* Get the interface object for this class. This will create the object as
416 : needed. */
417 :
418 : /* Make sure our global is sane. Hopefully we can remove this sometime */
419 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
420 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
421 0 : return nullptr;
422 : }
423 :
424 : /* Check to see whether the interface objects are already installed */
425 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
426 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::CSSPageRule)) {
427 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
428 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
429 : }
430 :
431 : /*
432 : * The object might _still_ be null, but that's OK.
433 : *
434 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
435 : * traced by TraceProtoAndIfaceCache() and its contents are never
436 : * changed after they have been set.
437 : *
438 : * Calling address() avoids the read read barrier that does gray
439 : * unmarking, but it's not possible for the object to be gray here.
440 : */
441 :
442 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::CSSPageRule);
443 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
444 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
445 : }
446 :
447 : JSObject*
448 0 : GetConstructorObject(JSContext* aCx)
449 : {
450 0 : return GetConstructorObjectHandle(aCx);
451 : }
452 :
453 : } // namespace CSSPageRuleBinding
454 :
455 :
456 :
457 : } // namespace dom
458 : } // namespace mozilla
|