Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM HTMLTableSectionElement.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "HTMLElementBinding.h"
4 : #include "HTMLTableSectionElementBinding.h"
5 : #include "WrapperFactory.h"
6 : #include "mozilla/OwningNonNull.h"
7 : #include "mozilla/dom/BindingUtils.h"
8 : #include "mozilla/dom/CustomElementRegistry.h"
9 : #include "mozilla/dom/DOMJSClass.h"
10 : #include "mozilla/dom/HTMLTableSectionElement.h"
11 : #include "mozilla/dom/NonRefcountedDOMObject.h"
12 : #include "mozilla/dom/PrimitiveConversions.h"
13 : #include "mozilla/dom/XrayExpandoClass.h"
14 : #include "nsContentList.h"
15 : #include "nsGenericHTMLElement.h"
16 :
17 : namespace mozilla {
18 : namespace dom {
19 :
20 : namespace HTMLTableSectionElementBinding {
21 :
22 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElementBinding::NativeType>::value,
23 : "Can't inherit from an interface with a different ownership model.");
24 :
25 : static bool
26 0 : get_rows(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTableSectionElement* self, JSJitGetterCallArgs args)
27 : {
28 0 : auto result(StrongOrRawPtr<nsIHTMLCollection>(self->Rows()));
29 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
30 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
31 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
32 0 : return false;
33 : }
34 0 : return true;
35 : }
36 :
37 : static const JSJitInfo rows_getterinfo = {
38 : { (JSJitGetterOp)get_rows },
39 : { prototypes::id::HTMLTableSectionElement },
40 : { PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth },
41 : JSJitInfo::Getter,
42 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
43 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
44 : false, /* isInfallible. False in setters. */
45 : false, /* isMovable. Not relevant for setters. */
46 : false, /* isEliminatable. Not relevant for setters. */
47 : false, /* isAlwaysInSlot. Only relevant for getters. */
48 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
49 : false, /* isTypedMethod. Only relevant for methods. */
50 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
51 : };
52 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
53 : static_assert(0 < 1, "There is no slot for us");
54 :
55 : static bool
56 0 : insertRow(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTableSectionElement* self, const JSJitMethodCallArgs& args)
57 : {
58 : int32_t arg0;
59 0 : if (args.hasDefined(0)) {
60 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) {
61 0 : return false;
62 : }
63 : } else {
64 0 : arg0 = -1;
65 : }
66 0 : binding_detail::FastErrorResult rv;
67 0 : auto result(StrongOrRawPtr<nsGenericHTMLElement>(self->InsertRow(arg0, rv)));
68 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
69 0 : return false;
70 : }
71 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
72 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
73 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
74 0 : return false;
75 : }
76 0 : return true;
77 : }
78 :
79 : static const JSJitInfo insertRow_methodinfo = {
80 : { (JSJitGetterOp)insertRow },
81 : { prototypes::id::HTMLTableSectionElement },
82 : { PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth },
83 : JSJitInfo::Method,
84 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
85 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
86 : false, /* isInfallible. False in setters. */
87 : false, /* isMovable. Not relevant for setters. */
88 : false, /* isEliminatable. Not relevant for setters. */
89 : false, /* isAlwaysInSlot. Only relevant for getters. */
90 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
91 : false, /* isTypedMethod. Only relevant for methods. */
92 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
93 : };
94 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
95 : static_assert(0 < 1, "There is no slot for us");
96 :
97 : static bool
98 0 : deleteRow(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTableSectionElement* self, const JSJitMethodCallArgs& args)
99 : {
100 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
101 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLTableSectionElement.deleteRow");
102 : }
103 : int32_t arg0;
104 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) {
105 0 : return false;
106 : }
107 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
108 0 : Maybe<AutoCEReaction> ceReaction;
109 0 : if (reactionsStack) {
110 0 : ceReaction.emplace(reactionsStack);
111 : }
112 0 : binding_detail::FastErrorResult rv;
113 0 : self->DeleteRow(arg0, rv);
114 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
115 0 : return false;
116 : }
117 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
118 0 : args.rval().setUndefined();
119 0 : return true;
120 : }
121 :
122 : static const JSJitInfo deleteRow_methodinfo = {
123 : { (JSJitGetterOp)deleteRow },
124 : { prototypes::id::HTMLTableSectionElement },
125 : { PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth },
126 : JSJitInfo::Method,
127 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
128 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
129 : false, /* isInfallible. False in setters. */
130 : false, /* isMovable. Not relevant for setters. */
131 : false, /* isEliminatable. Not relevant for setters. */
132 : false, /* isAlwaysInSlot. Only relevant for getters. */
133 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
134 : false, /* isTypedMethod. Only relevant for methods. */
135 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
136 : };
137 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
138 : static_assert(0 < 1, "There is no slot for us");
139 :
140 : static bool
141 0 : get_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTableSectionElement* self, JSJitGetterCallArgs args)
142 : {
143 0 : DOMString result;
144 0 : self->GetAlign(result);
145 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
146 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
147 0 : return false;
148 : }
149 0 : return true;
150 : }
151 :
152 : static bool
153 0 : set_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTableSectionElement* self, JSJitSetterCallArgs args)
154 : {
155 0 : binding_detail::FakeString arg0;
156 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
157 0 : return false;
158 : }
159 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
160 0 : Maybe<AutoCEReaction> ceReaction;
161 0 : if (reactionsStack) {
162 0 : ceReaction.emplace(reactionsStack);
163 : }
164 0 : binding_detail::FastErrorResult rv;
165 0 : self->SetAlign(NonNullHelper(Constify(arg0)), rv);
166 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
167 0 : return false;
168 : }
169 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
170 :
171 0 : return true;
172 : }
173 :
174 : static const JSJitInfo align_getterinfo = {
175 : { (JSJitGetterOp)get_align },
176 : { prototypes::id::HTMLTableSectionElement },
177 : { PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth },
178 : JSJitInfo::Getter,
179 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
180 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
181 : false, /* isInfallible. False in setters. */
182 : false, /* isMovable. Not relevant for setters. */
183 : false, /* isEliminatable. Not relevant for setters. */
184 : false, /* isAlwaysInSlot. Only relevant for getters. */
185 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
186 : false, /* isTypedMethod. Only relevant for methods. */
187 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
188 : };
189 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
190 : static_assert(0 < 1, "There is no slot for us");
191 : static const JSJitInfo align_setterinfo = {
192 : { (JSJitGetterOp)set_align },
193 : { prototypes::id::HTMLTableSectionElement },
194 : { PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth },
195 : JSJitInfo::Setter,
196 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
197 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
198 : false, /* isInfallible. False in setters. */
199 : false, /* isMovable. Not relevant for setters. */
200 : false, /* isEliminatable. Not relevant for setters. */
201 : false, /* isAlwaysInSlot. Only relevant for getters. */
202 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
203 : false, /* isTypedMethod. Only relevant for methods. */
204 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
205 : };
206 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
207 : static_assert(0 < 1, "There is no slot for us");
208 :
209 : static bool
210 0 : get_ch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTableSectionElement* self, JSJitGetterCallArgs args)
211 : {
212 0 : DOMString result;
213 0 : self->GetCh(result);
214 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
215 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
216 0 : return false;
217 : }
218 0 : return true;
219 : }
220 :
221 : static bool
222 0 : set_ch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTableSectionElement* self, JSJitSetterCallArgs args)
223 : {
224 0 : binding_detail::FakeString arg0;
225 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
226 0 : return false;
227 : }
228 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
229 0 : Maybe<AutoCEReaction> ceReaction;
230 0 : if (reactionsStack) {
231 0 : ceReaction.emplace(reactionsStack);
232 : }
233 0 : binding_detail::FastErrorResult rv;
234 0 : self->SetCh(NonNullHelper(Constify(arg0)), rv);
235 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
236 0 : return false;
237 : }
238 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
239 :
240 0 : return true;
241 : }
242 :
243 : static const JSJitInfo ch_getterinfo = {
244 : { (JSJitGetterOp)get_ch },
245 : { prototypes::id::HTMLTableSectionElement },
246 : { PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth },
247 : JSJitInfo::Getter,
248 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
249 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
250 : false, /* isInfallible. False in setters. */
251 : false, /* isMovable. Not relevant for setters. */
252 : false, /* isEliminatable. Not relevant for setters. */
253 : false, /* isAlwaysInSlot. Only relevant for getters. */
254 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
255 : false, /* isTypedMethod. Only relevant for methods. */
256 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
257 : };
258 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
259 : static_assert(0 < 1, "There is no slot for us");
260 : static const JSJitInfo ch_setterinfo = {
261 : { (JSJitGetterOp)set_ch },
262 : { prototypes::id::HTMLTableSectionElement },
263 : { PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth },
264 : JSJitInfo::Setter,
265 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
266 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
267 : false, /* isInfallible. False in setters. */
268 : false, /* isMovable. Not relevant for setters. */
269 : false, /* isEliminatable. Not relevant for setters. */
270 : false, /* isAlwaysInSlot. Only relevant for getters. */
271 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
272 : false, /* isTypedMethod. Only relevant for methods. */
273 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
274 : };
275 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
276 : static_assert(0 < 1, "There is no slot for us");
277 :
278 : static bool
279 0 : get_chOff(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTableSectionElement* self, JSJitGetterCallArgs args)
280 : {
281 0 : DOMString result;
282 0 : self->GetChOff(result);
283 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
284 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
285 0 : return false;
286 : }
287 0 : return true;
288 : }
289 :
290 : static bool
291 0 : set_chOff(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTableSectionElement* self, JSJitSetterCallArgs args)
292 : {
293 0 : binding_detail::FakeString arg0;
294 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
295 0 : return false;
296 : }
297 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
298 0 : Maybe<AutoCEReaction> ceReaction;
299 0 : if (reactionsStack) {
300 0 : ceReaction.emplace(reactionsStack);
301 : }
302 0 : binding_detail::FastErrorResult rv;
303 0 : self->SetChOff(NonNullHelper(Constify(arg0)), rv);
304 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
305 0 : return false;
306 : }
307 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
308 :
309 0 : return true;
310 : }
311 :
312 : static const JSJitInfo chOff_getterinfo = {
313 : { (JSJitGetterOp)get_chOff },
314 : { prototypes::id::HTMLTableSectionElement },
315 : { PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth },
316 : JSJitInfo::Getter,
317 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
318 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
319 : false, /* isInfallible. False in setters. */
320 : false, /* isMovable. Not relevant for setters. */
321 : false, /* isEliminatable. Not relevant for setters. */
322 : false, /* isAlwaysInSlot. Only relevant for getters. */
323 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
324 : false, /* isTypedMethod. Only relevant for methods. */
325 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
326 : };
327 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
328 : static_assert(0 < 1, "There is no slot for us");
329 : static const JSJitInfo chOff_setterinfo = {
330 : { (JSJitGetterOp)set_chOff },
331 : { prototypes::id::HTMLTableSectionElement },
332 : { PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth },
333 : JSJitInfo::Setter,
334 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
335 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
336 : false, /* isInfallible. False in setters. */
337 : false, /* isMovable. Not relevant for setters. */
338 : false, /* isEliminatable. Not relevant for setters. */
339 : false, /* isAlwaysInSlot. Only relevant for getters. */
340 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
341 : false, /* isTypedMethod. Only relevant for methods. */
342 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
343 : };
344 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
345 : static_assert(0 < 1, "There is no slot for us");
346 :
347 : static bool
348 0 : get_vAlign(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTableSectionElement* self, JSJitGetterCallArgs args)
349 : {
350 0 : DOMString result;
351 0 : self->GetVAlign(result);
352 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
353 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
354 0 : return false;
355 : }
356 0 : return true;
357 : }
358 :
359 : static bool
360 0 : set_vAlign(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTableSectionElement* self, JSJitSetterCallArgs args)
361 : {
362 0 : binding_detail::FakeString arg0;
363 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
364 0 : return false;
365 : }
366 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
367 0 : Maybe<AutoCEReaction> ceReaction;
368 0 : if (reactionsStack) {
369 0 : ceReaction.emplace(reactionsStack);
370 : }
371 0 : binding_detail::FastErrorResult rv;
372 0 : self->SetVAlign(NonNullHelper(Constify(arg0)), rv);
373 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
374 0 : return false;
375 : }
376 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
377 :
378 0 : return true;
379 : }
380 :
381 : static const JSJitInfo vAlign_getterinfo = {
382 : { (JSJitGetterOp)get_vAlign },
383 : { prototypes::id::HTMLTableSectionElement },
384 : { PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth },
385 : JSJitInfo::Getter,
386 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
387 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
388 : false, /* isInfallible. False in setters. */
389 : false, /* isMovable. Not relevant for setters. */
390 : false, /* isEliminatable. Not relevant for setters. */
391 : false, /* isAlwaysInSlot. Only relevant for getters. */
392 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
393 : false, /* isTypedMethod. Only relevant for methods. */
394 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
395 : };
396 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
397 : static_assert(0 < 1, "There is no slot for us");
398 : static const JSJitInfo vAlign_setterinfo = {
399 : { (JSJitGetterOp)set_vAlign },
400 : { prototypes::id::HTMLTableSectionElement },
401 : { PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth },
402 : JSJitInfo::Setter,
403 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
404 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
405 : false, /* isInfallible. False in setters. */
406 : false, /* isMovable. Not relevant for setters. */
407 : false, /* isEliminatable. Not relevant for setters. */
408 : false, /* isAlwaysInSlot. Only relevant for getters. */
409 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
410 : false, /* isTypedMethod. Only relevant for methods. */
411 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
412 : };
413 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
414 : static_assert(0 < 1, "There is no slot for us");
415 :
416 : static bool
417 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
418 : {
419 0 : mozilla::dom::HTMLTableSectionElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLTableSectionElement>(obj);
420 : // We don't want to preserve if we don't have a wrapper, and we
421 : // obviously can't preserve if we're not initialized.
422 0 : if (self && self->GetWrapperPreserveColor()) {
423 0 : PreserveWrapper(self);
424 : }
425 0 : return true;
426 : }
427 :
428 : static void
429 0 : _finalize(js::FreeOp* fop, JSObject* obj)
430 : {
431 0 : mozilla::dom::HTMLTableSectionElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLTableSectionElement>(obj);
432 0 : if (self) {
433 0 : ClearWrapper(self, self, obj);
434 0 : AddForDeferredFinalization<mozilla::dom::HTMLTableSectionElement>(self);
435 : }
436 0 : }
437 :
438 : static void
439 0 : _objectMoved(JSObject* obj, const JSObject* old)
440 : {
441 0 : mozilla::dom::HTMLTableSectionElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLTableSectionElement>(obj);
442 0 : if (self) {
443 0 : UpdateWrapper(self, self, obj, old);
444 : }
445 0 : }
446 :
447 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
448 : #if defined(__clang__)
449 : #pragma clang diagnostic push
450 : #pragma clang diagnostic ignored "-Wmissing-braces"
451 : #endif
452 : static const JSFunctionSpec sMethods_specs[] = {
453 : JS_FNSPEC("insertRow", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&insertRow_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
454 : JS_FNSPEC("deleteRow", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&deleteRow_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
455 : JS_FS_END
456 : };
457 : #if defined(__clang__)
458 : #pragma clang diagnostic pop
459 : #endif
460 :
461 :
462 : // Can't be const because the pref-enabled boolean needs to be writable
463 : static Prefable<const JSFunctionSpec> sMethods[] = {
464 : { nullptr, &sMethods_specs[0] },
465 : { nullptr, nullptr }
466 : };
467 :
468 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
469 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
470 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
471 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
472 :
473 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
474 : #if defined(__clang__)
475 : #pragma clang diagnostic push
476 : #pragma clang diagnostic ignored "-Wmissing-braces"
477 : #endif
478 : static const JSPropertySpec sAttributes_specs[] = {
479 : { "rows", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &rows_getterinfo, nullptr, nullptr },
480 : { "align", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &align_getterinfo, GenericBindingSetter, &align_setterinfo },
481 : { "ch", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &ch_getterinfo, GenericBindingSetter, &ch_setterinfo },
482 : { "chOff", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &chOff_getterinfo, GenericBindingSetter, &chOff_setterinfo },
483 : { "vAlign", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &vAlign_getterinfo, GenericBindingSetter, &vAlign_setterinfo },
484 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
485 : };
486 : #if defined(__clang__)
487 : #pragma clang diagnostic pop
488 : #endif
489 :
490 :
491 : // Can't be const because the pref-enabled boolean needs to be writable
492 : static Prefable<const JSPropertySpec> sAttributes[] = {
493 : { nullptr, &sAttributes_specs[0] },
494 : { nullptr, nullptr }
495 : };
496 :
497 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
498 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
499 : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
500 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
501 :
502 :
503 : static uint16_t sNativeProperties_sortedPropertyIndices[7];
504 : static PropertyInfo sNativeProperties_propertyInfos[7];
505 :
506 : static const NativePropertiesN<2> sNativeProperties = {
507 : false, 0,
508 : false, 0,
509 : true, 0 /* sMethods */,
510 : true, 1 /* sAttributes */,
511 : false, 0,
512 : false, 0,
513 : false, 0,
514 : -1,
515 : 7,
516 : sNativeProperties_sortedPropertyIndices,
517 : {
518 : { sMethods, &sNativeProperties_propertyInfos[0] },
519 : { sAttributes, &sNativeProperties_propertyInfos[2] }
520 : }
521 : };
522 : static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
523 : "We have a property info count that is oversized");
524 :
525 : static bool
526 0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
527 : {
528 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
529 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
530 0 : if (!args.isConstructing()) {
531 : // XXXbz wish I could get the name from the callee instead of
532 : // Adding more relocations
533 0 : return ThrowConstructorWithoutNew(cx, "HTMLTableSectionElement");
534 : }
535 :
536 0 : GlobalObject global(cx, obj);
537 0 : if (global.Failed()) {
538 0 : return false;
539 : }
540 :
541 : // The newTarget might be a cross-compartment wrapper. Get the underlying object
542 : // so we can do the spec's object-identity checks.
543 0 : JS::Rooted<JSObject*> newTarget(cx, js::CheckedUnwrap(&args.newTarget().toObject()));
544 0 : if (!newTarget) {
545 0 : return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
546 : }
547 :
548 : // Step 2 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
549 : // Enter the compartment of our underlying newTarget object, so we end
550 : // up comparing to the constructor object for our interface from that global.
551 : {
552 0 : JSAutoCompartment ac(cx, newTarget);
553 0 : JS::Handle<JSObject*> constructor(GetConstructorObjectHandle(cx));
554 0 : if (!constructor) {
555 0 : return false;
556 : }
557 0 : if (newTarget == constructor) {
558 0 : return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
559 : }
560 : }
561 :
562 0 : JS::Rooted<JSObject*> desiredProto(cx);
563 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
564 0 : return false;
565 : }
566 0 : if (!desiredProto) {
567 : // Step 7 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
568 : // This fallback behavior is designed to match analogous behavior for the
569 : // JavaScript built-ins. So we enter the compartment of our underlying
570 : // newTarget object and fall back to the prototype object from that global.
571 : // XXX The spec says to use GetFunctionRealm(), which is not actually
572 : // the same thing as what we have here (e.g. in the case of scripted callable proxies
573 : // whose target is not same-compartment with the proxy, or bound functions, etc).
574 : // https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
575 : {
576 0 : JSAutoCompartment ac(cx, newTarget);
577 0 : desiredProto = GetProtoObjectHandle(cx);
578 0 : if (!desiredProto) {
579 0 : return false;
580 : }
581 : }
582 :
583 : // desiredProto is in the compartment of the underlying newTarget object.
584 : // Wrap it into the context compartment.
585 0 : if (!JS_WrapObject(cx, &desiredProto)) {
586 0 : return false;
587 : }
588 : }
589 :
590 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
591 0 : Maybe<JSAutoCompartment> ac;
592 0 : if (objIsXray) {
593 0 : obj = js::CheckedUnwrap(obj);
594 0 : if (!obj) {
595 0 : return false;
596 : }
597 0 : ac.emplace(cx, obj);
598 0 : if (!JS_WrapObject(cx, &desiredProto)) {
599 0 : return false;
600 : }
601 : }
602 0 : binding_detail::FastErrorResult rv;
603 0 : auto result(StrongOrRawPtr<mozilla::dom::HTMLTableSectionElement>(CreateHTMLElement(global, args, rv)));
604 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
605 0 : return false;
606 : }
607 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
608 : static_assert(!IsPointer<decltype(result)>::value,
609 : "NewObject implies that we need to keep the object alive with a strong reference.");
610 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
611 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
612 0 : return false;
613 : }
614 0 : return true;
615 : }
616 :
617 : static const js::ClassOps sInterfaceObjectClassOps = {
618 : nullptr, /* addProperty */
619 : nullptr, /* delProperty */
620 : nullptr, /* getProperty */
621 : nullptr, /* setProperty */
622 : nullptr, /* enumerate */
623 : nullptr, /* newEnumerate */
624 : nullptr, /* resolve */
625 : nullptr, /* mayResolve */
626 : nullptr, /* finalize */
627 : _constructor, /* call */
628 : nullptr, /* hasInstance */
629 : _constructor, /* construct */
630 : nullptr, /* trace */
631 : };
632 :
633 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
634 : {
635 : "Function",
636 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
637 : &sInterfaceObjectClassOps,
638 : JS_NULL_CLASS_SPEC,
639 : JS_NULL_CLASS_EXT,
640 : &sInterfaceObjectClassObjectOps
641 : },
642 : eInterface,
643 : true,
644 : prototypes::id::HTMLTableSectionElement,
645 : PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth,
646 : sNativePropertyHooks,
647 : "function HTMLTableSectionElement() {\n [native code]\n}",
648 : HTMLElementBinding::GetConstructorObject
649 : };
650 :
651 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
652 : {
653 : "HTMLTableSectionElementPrototype",
654 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
655 : JS_NULL_CLASS_OPS,
656 : JS_NULL_CLASS_SPEC,
657 : JS_NULL_CLASS_EXT,
658 : JS_NULL_OBJECT_OPS
659 : },
660 : eInterfacePrototype,
661 : false,
662 : prototypes::id::HTMLTableSectionElement,
663 : PrototypeTraits<prototypes::id::HTMLTableSectionElement>::Depth,
664 : sNativePropertyHooks,
665 : "[object HTMLTableSectionElementPrototype]",
666 : HTMLElementBinding::GetProtoObject
667 : };
668 :
669 : JSObject*
670 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
671 : {
672 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
673 : }
674 :
675 : static const js::ClassOps sClassOps = {
676 : _addProperty, /* addProperty */
677 : nullptr, /* delProperty */
678 : nullptr, /* getProperty */
679 : nullptr, /* setProperty */
680 : nullptr, /* enumerate */
681 : nullptr, /* newEnumerate */
682 : nullptr, /* resolve */
683 : nullptr, /* mayResolve */
684 : _finalize, /* finalize */
685 : nullptr, /* call */
686 : nullptr, /* hasInstance */
687 : nullptr, /* construct */
688 : nullptr, /* trace */
689 : };
690 :
691 : static const js::ClassExtension sClassExtension = {
692 : nullptr, /* weakmapKeyDelegateOp */
693 : _objectMoved /* objectMovedOp */
694 : };
695 :
696 : static const DOMJSClass sClass = {
697 : { "HTMLTableSectionElement",
698 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
699 : &sClassOps,
700 : JS_NULL_CLASS_SPEC,
701 : &sClassExtension,
702 : JS_NULL_OBJECT_OPS
703 : },
704 : { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLTableSectionElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
705 : IsBaseOf<nsISupports, mozilla::dom::HTMLTableSectionElement >::value,
706 : sNativePropertyHooks,
707 : FindAssociatedGlobalForNative<mozilla::dom::HTMLTableSectionElement>::Get,
708 : GetProtoObjectHandle,
709 : GetCCParticipant<mozilla::dom::HTMLTableSectionElement>::Get()
710 : };
711 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
712 : "Must have the right minimal number of reserved slots.");
713 : static_assert(1 >= 1,
714 : "Must have enough reserved slots.");
715 :
716 : const JSClass*
717 0 : GetJSClass()
718 : {
719 0 : return sClass.ToJSClass();
720 : }
721 :
722 : bool
723 0 : Wrap(JSContext* aCx, mozilla::dom::HTMLTableSectionElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
724 : {
725 : MOZ_ASSERT(static_cast<mozilla::dom::HTMLTableSectionElement*>(aObject) ==
726 : reinterpret_cast<mozilla::dom::HTMLTableSectionElement*>(aObject),
727 : "Multiple inheritance for mozilla::dom::HTMLTableSectionElement is broken.");
728 : MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
729 : reinterpret_cast<nsGenericHTMLElement*>(aObject),
730 : "Multiple inheritance for nsGenericHTMLElement is broken.");
731 : MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
732 : reinterpret_cast<mozilla::dom::Element*>(aObject),
733 : "Multiple inheritance for mozilla::dom::Element is broken.");
734 : MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
735 : reinterpret_cast<nsINode*>(aObject),
736 : "Multiple inheritance for nsINode is broken.");
737 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
738 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
739 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
740 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
741 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
742 0 : MOZ_ASSERT(!aCache->GetWrapper(),
743 : "You should probably not be using Wrap() directly; use "
744 : "GetOrCreateDOMReflector instead");
745 :
746 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
747 : "nsISupports must be on our primary inheritance chain");
748 :
749 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
750 0 : if (!global) {
751 0 : return false;
752 : }
753 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
754 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
755 :
756 : // That might have ended up wrapping us already, due to the wonders
757 : // of XBL. Check for that, and bail out as needed.
758 0 : aReflector.set(aCache->GetWrapper());
759 0 : if (aReflector) {
760 : #ifdef DEBUG
761 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
762 : #endif // DEBUG
763 0 : return true;
764 : }
765 :
766 0 : JSAutoCompartment ac(aCx, global);
767 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
768 0 : if (!canonicalProto) {
769 0 : return false;
770 : }
771 0 : JS::Rooted<JSObject*> proto(aCx);
772 0 : if (aGivenProto) {
773 0 : proto = aGivenProto;
774 : // Unfortunately, while aGivenProto was in the compartment of aCx
775 : // coming in, we changed compartments to that of "parent" so may need
776 : // to wrap the proto here.
777 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
778 0 : if (!JS_WrapObject(aCx, &proto)) {
779 0 : return false;
780 : }
781 : }
782 : } else {
783 0 : proto = canonicalProto;
784 : }
785 :
786 0 : BindingJSObjectCreator<mozilla::dom::HTMLTableSectionElement> creator(aCx);
787 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
788 0 : if (!aReflector) {
789 0 : return false;
790 : }
791 :
792 0 : aCache->SetWrapper(aReflector);
793 0 : creator.InitializationSucceeded();
794 :
795 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
796 : aCache->GetWrapperPreserveColor() == aReflector);
797 : // If proto != canonicalProto, we have to preserve our wrapper;
798 : // otherwise we won't be able to properly recreate it later, since
799 : // we won't know what proto to use. Note that we don't check
800 : // aGivenProto here, since it's entirely possible (and even
801 : // somewhat common) to have a non-null aGivenProto which is the
802 : // same as canonicalProto.
803 0 : if (proto != canonicalProto) {
804 0 : PreserveWrapper(aObject);
805 : }
806 :
807 0 : return true;
808 : }
809 :
810 : const NativePropertyHooks sNativePropertyHooks[] = { {
811 : nullptr,
812 : nullptr,
813 : nullptr,
814 : { sNativeProperties.Upcast(), nullptr },
815 : prototypes::id::HTMLTableSectionElement,
816 : constructors::id::HTMLTableSectionElement,
817 : HTMLElementBinding::sNativePropertyHooks,
818 : &DefaultXrayExpandoObjectClass
819 : } };
820 :
821 : void
822 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
823 : {
824 0 : JS::Handle<JSObject*> parentProto(HTMLElementBinding::GetProtoObjectHandle(aCx));
825 0 : if (!parentProto) {
826 0 : return;
827 : }
828 :
829 0 : JS::Handle<JSObject*> constructorProto(HTMLElementBinding::GetConstructorObjectHandle(aCx));
830 0 : if (!constructorProto) {
831 0 : return;
832 : }
833 :
834 : static bool sIdsInited = false;
835 0 : if (!sIdsInited && NS_IsMainThread()) {
836 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
837 0 : return;
838 : }
839 0 : sIdsInited = true;
840 : }
841 :
842 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLTableSectionElement);
843 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLTableSectionElement);
844 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
845 : &sPrototypeClass.mBase, protoCache,
846 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
847 : interfaceCache,
848 : sNativeProperties.Upcast(),
849 : nullptr,
850 : "HTMLTableSectionElement", aDefineOnGlobal,
851 : nullptr,
852 0 : false);
853 : }
854 :
855 : JS::Handle<JSObject*>
856 0 : GetProtoObjectHandle(JSContext* aCx)
857 : {
858 : /* Get the interface prototype object for this class. This will create the
859 : object as needed. */
860 0 : bool aDefineOnGlobal = true;
861 :
862 : /* Make sure our global is sane. Hopefully we can remove this sometime */
863 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
864 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
865 0 : return nullptr;
866 : }
867 :
868 : /* Check to see whether the interface objects are already installed */
869 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
870 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::HTMLTableSectionElement)) {
871 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
872 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
873 : }
874 :
875 : /*
876 : * The object might _still_ be null, but that's OK.
877 : *
878 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
879 : * traced by TraceProtoAndIfaceCache() and its contents are never
880 : * changed after they have been set.
881 : *
882 : * Calling address() avoids the read read barrier that does gray
883 : * unmarking, but it's not possible for the object to be gray here.
884 : */
885 :
886 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::HTMLTableSectionElement);
887 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
888 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
889 : }
890 :
891 : JS::Handle<JSObject*>
892 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
893 : {
894 : /* Get the interface object for this class. This will create the object as
895 : needed. */
896 :
897 : /* Make sure our global is sane. Hopefully we can remove this sometime */
898 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
899 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
900 0 : return nullptr;
901 : }
902 :
903 : /* Check to see whether the interface objects are already installed */
904 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
905 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::HTMLTableSectionElement)) {
906 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
907 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
908 : }
909 :
910 : /*
911 : * The object might _still_ be null, but that's OK.
912 : *
913 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
914 : * traced by TraceProtoAndIfaceCache() and its contents are never
915 : * changed after they have been set.
916 : *
917 : * Calling address() avoids the read read barrier that does gray
918 : * unmarking, but it's not possible for the object to be gray here.
919 : */
920 :
921 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::HTMLTableSectionElement);
922 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
923 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
924 : }
925 :
926 : JSObject*
927 0 : GetConstructorObject(JSContext* aCx)
928 : {
929 0 : return GetConstructorObjectHandle(aCx);
930 : }
931 :
932 : } // namespace HTMLTableSectionElementBinding
933 :
934 :
935 :
936 : } // namespace dom
937 : } // namespace mozilla
|