Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM CSSGroupingRule.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "CSSGroupingRuleBinding.h"
4 : #include "CSSRuleBinding.h"
5 : #include "WrapperFactory.h"
6 : #include "mozilla/OwningNonNull.h"
7 : #include "mozilla/css/GroupRule.h"
8 : #include "mozilla/dom/BindingUtils.h"
9 : #include "mozilla/dom/CSSRuleList.h"
10 : #include "mozilla/dom/DOMJSClass.h"
11 : #include "mozilla/dom/NonRefcountedDOMObject.h"
12 : #include "mozilla/dom/PrimitiveConversions.h"
13 : #include "mozilla/dom/XrayExpandoClass.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : namespace CSSGroupingRuleBinding {
19 :
20 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<CSSRuleBinding::NativeType>::value,
21 : "Can't inherit from an interface with a different ownership model.");
22 :
23 : static bool
24 0 : get_cssRules(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::css::GroupRule* self, JSJitGetterCallArgs args)
25 : {
26 0 : auto result(StrongOrRawPtr<mozilla::dom::CSSRuleList>(self->CssRules()));
27 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
28 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
29 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
30 0 : return false;
31 : }
32 0 : return true;
33 : }
34 :
35 : static const JSJitInfo cssRules_getterinfo = {
36 : { (JSJitGetterOp)get_cssRules },
37 : { prototypes::id::CSSGroupingRule },
38 : { PrototypeTraits<prototypes::id::CSSGroupingRule>::Depth },
39 : JSJitInfo::Getter,
40 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
41 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
42 : false, /* isInfallible. False in setters. */
43 : true, /* isMovable. Not relevant for setters. */
44 : true, /* isEliminatable. Not relevant for setters. */
45 : false, /* isAlwaysInSlot. Only relevant for getters. */
46 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
47 : false, /* isTypedMethod. Only relevant for methods. */
48 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
49 : };
50 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
51 : static_assert(0 < 1, "There is no slot for us");
52 :
53 : static bool
54 0 : insertRule(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::css::GroupRule* self, const JSJitMethodCallArgs& args)
55 : {
56 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
57 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CSSGroupingRule.insertRule");
58 : }
59 0 : binding_detail::FakeString arg0;
60 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
61 0 : return false;
62 : }
63 : uint32_t arg1;
64 0 : if (args.hasDefined(1)) {
65 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
66 0 : return false;
67 : }
68 : } else {
69 0 : arg1 = 0U;
70 : }
71 0 : binding_detail::FastErrorResult rv;
72 0 : uint32_t result(self->InsertRule(NonNullHelper(Constify(arg0)), arg1, rv));
73 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
74 0 : return false;
75 : }
76 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
77 0 : args.rval().setNumber(result);
78 0 : return true;
79 : }
80 :
81 : static const JSJitInfo insertRule_methodinfo = {
82 : { (JSJitGetterOp)insertRule },
83 : { prototypes::id::CSSGroupingRule },
84 : { PrototypeTraits<prototypes::id::CSSGroupingRule>::Depth },
85 : JSJitInfo::Method,
86 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
87 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
88 : false, /* isInfallible. False in setters. */
89 : false, /* isMovable. Not relevant for setters. */
90 : false, /* isEliminatable. Not relevant for setters. */
91 : false, /* isAlwaysInSlot. Only relevant for getters. */
92 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
93 : false, /* isTypedMethod. Only relevant for methods. */
94 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
95 : };
96 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
97 : static_assert(0 < 1, "There is no slot for us");
98 :
99 : static bool
100 0 : deleteRule(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::css::GroupRule* self, const JSJitMethodCallArgs& args)
101 : {
102 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
103 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CSSGroupingRule.deleteRule");
104 : }
105 : uint32_t arg0;
106 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
107 0 : return false;
108 : }
109 0 : binding_detail::FastErrorResult rv;
110 0 : self->DeleteRule(arg0, rv);
111 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
112 0 : return false;
113 : }
114 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
115 0 : args.rval().setUndefined();
116 0 : return true;
117 : }
118 :
119 : static const JSJitInfo deleteRule_methodinfo = {
120 : { (JSJitGetterOp)deleteRule },
121 : { prototypes::id::CSSGroupingRule },
122 : { PrototypeTraits<prototypes::id::CSSGroupingRule>::Depth },
123 : JSJitInfo::Method,
124 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
125 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
126 : false, /* isInfallible. False in setters. */
127 : false, /* isMovable. Not relevant for setters. */
128 : false, /* isEliminatable. Not relevant for setters. */
129 : false, /* isAlwaysInSlot. Only relevant for getters. */
130 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
131 : false, /* isTypedMethod. Only relevant for methods. */
132 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
133 : };
134 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
135 : static_assert(0 < 1, "There is no slot for us");
136 :
137 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
138 : #if defined(__clang__)
139 : #pragma clang diagnostic push
140 : #pragma clang diagnostic ignored "-Wmissing-braces"
141 : #endif
142 : static const JSFunctionSpec sMethods_specs[] = {
143 : JS_FNSPEC("insertRule", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&insertRule_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
144 : JS_FNSPEC("deleteRule", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&deleteRule_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
145 : JS_FS_END
146 : };
147 : #if defined(__clang__)
148 : #pragma clang diagnostic pop
149 : #endif
150 :
151 :
152 : // Can't be const because the pref-enabled boolean needs to be writable
153 : static Prefable<const JSFunctionSpec> sMethods[] = {
154 : { nullptr, &sMethods_specs[0] },
155 : { nullptr, nullptr }
156 : };
157 :
158 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
159 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
160 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
161 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
162 :
163 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
164 : #if defined(__clang__)
165 : #pragma clang diagnostic push
166 : #pragma clang diagnostic ignored "-Wmissing-braces"
167 : #endif
168 : static const JSPropertySpec sAttributes_specs[] = {
169 : { "cssRules", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &cssRules_getterinfo, nullptr, nullptr },
170 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
171 : };
172 : #if defined(__clang__)
173 : #pragma clang diagnostic pop
174 : #endif
175 :
176 :
177 : // Can't be const because the pref-enabled boolean needs to be writable
178 : static Prefable<const JSPropertySpec> sAttributes[] = {
179 : { nullptr, &sAttributes_specs[0] },
180 : { nullptr, nullptr }
181 : };
182 :
183 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
184 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
185 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
186 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
187 :
188 :
189 : static uint16_t sNativeProperties_sortedPropertyIndices[3];
190 : static PropertyInfo sNativeProperties_propertyInfos[3];
191 :
192 : static const NativePropertiesN<2> sNativeProperties = {
193 : false, 0,
194 : false, 0,
195 : true, 0 /* sMethods */,
196 : true, 1 /* sAttributes */,
197 : false, 0,
198 : false, 0,
199 : false, 0,
200 : -1,
201 : 3,
202 : sNativeProperties_sortedPropertyIndices,
203 : {
204 : { sMethods, &sNativeProperties_propertyInfos[0] },
205 : { sAttributes, &sNativeProperties_propertyInfos[2] }
206 : }
207 : };
208 : static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
209 : "We have a property info count that is oversized");
210 :
211 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
212 : {
213 : "Function",
214 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
215 : &sBoringInterfaceObjectClassClassOps,
216 : JS_NULL_CLASS_SPEC,
217 : JS_NULL_CLASS_EXT,
218 : &sInterfaceObjectClassObjectOps
219 : },
220 : eInterface,
221 : true,
222 : prototypes::id::CSSGroupingRule,
223 : PrototypeTraits<prototypes::id::CSSGroupingRule>::Depth,
224 : sNativePropertyHooks,
225 : "function CSSGroupingRule() {\n [native code]\n}",
226 : CSSRuleBinding::GetConstructorObject
227 : };
228 :
229 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
230 : {
231 : "CSSGroupingRulePrototype",
232 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
233 : JS_NULL_CLASS_OPS,
234 : JS_NULL_CLASS_SPEC,
235 : JS_NULL_CLASS_EXT,
236 : JS_NULL_OBJECT_OPS
237 : },
238 : eInterfacePrototype,
239 : false,
240 : prototypes::id::CSSGroupingRule,
241 : PrototypeTraits<prototypes::id::CSSGroupingRule>::Depth,
242 : sNativePropertyHooks,
243 : "[object CSSGroupingRulePrototype]",
244 : CSSRuleBinding::GetProtoObject
245 : };
246 :
247 : JSObject*
248 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
249 : {
250 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
251 : }
252 :
253 : const NativePropertyHooks sNativePropertyHooks[] = { {
254 : nullptr,
255 : nullptr,
256 : nullptr,
257 : { sNativeProperties.Upcast(), nullptr },
258 : prototypes::id::CSSGroupingRule,
259 : constructors::id::CSSGroupingRule,
260 : CSSRuleBinding::sNativePropertyHooks,
261 : &DefaultXrayExpandoObjectClass
262 : } };
263 :
264 : void
265 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
266 : {
267 0 : JS::Handle<JSObject*> parentProto(CSSRuleBinding::GetProtoObjectHandle(aCx));
268 0 : if (!parentProto) {
269 0 : return;
270 : }
271 :
272 0 : JS::Handle<JSObject*> constructorProto(CSSRuleBinding::GetConstructorObjectHandle(aCx));
273 0 : if (!constructorProto) {
274 0 : return;
275 : }
276 :
277 : static bool sIdsInited = false;
278 0 : if (!sIdsInited && NS_IsMainThread()) {
279 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
280 0 : return;
281 : }
282 0 : sIdsInited = true;
283 : }
284 :
285 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CSSGroupingRule);
286 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CSSGroupingRule);
287 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
288 : &sPrototypeClass.mBase, protoCache,
289 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
290 : interfaceCache,
291 : sNativeProperties.Upcast(),
292 : nullptr,
293 : "CSSGroupingRule", aDefineOnGlobal,
294 : nullptr,
295 0 : false);
296 : }
297 :
298 : JS::Handle<JSObject*>
299 0 : GetProtoObjectHandle(JSContext* aCx)
300 : {
301 : /* Get the interface prototype object for this class. This will create the
302 : object as needed. */
303 0 : bool aDefineOnGlobal = true;
304 :
305 : /* Make sure our global is sane. Hopefully we can remove this sometime */
306 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
307 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
308 0 : return nullptr;
309 : }
310 :
311 : /* Check to see whether the interface objects are already installed */
312 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
313 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::CSSGroupingRule)) {
314 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
315 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
316 : }
317 :
318 : /*
319 : * The object might _still_ be null, but that's OK.
320 : *
321 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
322 : * traced by TraceProtoAndIfaceCache() and its contents are never
323 : * changed after they have been set.
324 : *
325 : * Calling address() avoids the read read barrier that does gray
326 : * unmarking, but it's not possible for the object to be gray here.
327 : */
328 :
329 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::CSSGroupingRule);
330 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
331 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
332 : }
333 :
334 : JSObject*
335 0 : GetProtoObject(JSContext* aCx)
336 : {
337 0 : return GetProtoObjectHandle(aCx);
338 : }
339 :
340 : JS::Handle<JSObject*>
341 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
342 : {
343 : /* Get the interface object for this class. This will create the object as
344 : needed. */
345 :
346 : /* Make sure our global is sane. Hopefully we can remove this sometime */
347 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
348 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
349 0 : return nullptr;
350 : }
351 :
352 : /* Check to see whether the interface objects are already installed */
353 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
354 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::CSSGroupingRule)) {
355 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
356 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
357 : }
358 :
359 : /*
360 : * The object might _still_ be null, but that's OK.
361 : *
362 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
363 : * traced by TraceProtoAndIfaceCache() and its contents are never
364 : * changed after they have been set.
365 : *
366 : * Calling address() avoids the read read barrier that does gray
367 : * unmarking, but it's not possible for the object to be gray here.
368 : */
369 :
370 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::CSSGroupingRule);
371 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
372 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
373 : }
374 :
375 : JSObject*
376 0 : GetConstructorObject(JSContext* aCx)
377 : {
378 0 : return GetConstructorObjectHandle(aCx);
379 : }
380 :
381 : } // namespace CSSGroupingRuleBinding
382 :
383 :
384 :
385 : } // namespace dom
386 : } // namespace mozilla
|