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