Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM HTMLImageElement.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "HTMLElementBinding.h"
4 : #include "HTMLImageElementBinding.h"
5 : #include "WrapperFactory.h"
6 : #include "imgINotificationObserver.h"
7 : #include "imgIRequest.h"
8 : #include "mozilla/OwningNonNull.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 : #include "mozilla/dom/CustomElementRegistry.h"
11 : #include "mozilla/dom/DOMJSClass.h"
12 : #include "mozilla/dom/HTMLImageElement.h"
13 : #include "mozilla/dom/NonRefcountedDOMObject.h"
14 : #include "mozilla/dom/Nullable.h"
15 : #include "mozilla/dom/PrimitiveConversions.h"
16 : #include "mozilla/dom/XrayExpandoClass.h"
17 : #include "nsContentUtils.h"
18 : #include "nsIURI.h"
19 :
20 : namespace mozilla {
21 : namespace dom {
22 :
23 : namespace HTMLImageElementBinding {
24 :
25 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElementBinding::NativeType>::value,
26 : "Can't inherit from an interface with a different ownership model.");
27 :
28 : static bool
29 0 : _Image(JSContext* cx, unsigned argc, JS::Value* vp)
30 : {
31 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
32 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
33 0 : if (!args.isConstructing()) {
34 : // XXXbz wish I could get the name from the callee instead of
35 : // Adding more relocations
36 0 : return ThrowConstructorWithoutNew(cx, "Image");
37 : }
38 :
39 0 : GlobalObject global(cx, obj);
40 0 : if (global.Failed()) {
41 0 : return false;
42 : }
43 :
44 0 : JS::Rooted<JSObject*> desiredProto(cx);
45 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
46 0 : return false;
47 : }
48 :
49 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
50 0 : Optional<uint32_t> arg0;
51 0 : if (args.hasDefined(0)) {
52 0 : arg0.Construct();
53 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0.Value())) {
54 0 : return false;
55 : }
56 : }
57 0 : Optional<uint32_t> arg1;
58 0 : if (args.hasDefined(1)) {
59 0 : arg1.Construct();
60 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1.Value())) {
61 0 : return false;
62 : }
63 : }
64 0 : Maybe<JSAutoCompartment> ac;
65 0 : if (objIsXray) {
66 0 : obj = js::CheckedUnwrap(obj);
67 0 : if (!obj) {
68 0 : return false;
69 : }
70 0 : ac.emplace(cx, obj);
71 0 : if (!JS_WrapObject(cx, &desiredProto)) {
72 0 : return false;
73 : }
74 : }
75 0 : binding_detail::FastErrorResult rv;
76 0 : auto result(StrongOrRawPtr<mozilla::dom::HTMLImageElement>(mozilla::dom::HTMLImageElement::Image(global, Constify(arg0), Constify(arg1), rv)));
77 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
78 0 : return false;
79 : }
80 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
81 : static_assert(!IsPointer<decltype(result)>::value,
82 : "NewObject implies that we need to keep the object alive with a strong reference.");
83 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
84 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
85 0 : return false;
86 : }
87 0 : return true;
88 : }
89 :
90 : static bool
91 0 : get_alt(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
92 : {
93 0 : DOMString result;
94 0 : self->GetAlt(result);
95 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
96 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
97 0 : return false;
98 : }
99 0 : return true;
100 : }
101 :
102 : static bool
103 0 : set_alt(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
104 : {
105 0 : binding_detail::FakeString arg0;
106 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
107 0 : return false;
108 : }
109 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
110 0 : Maybe<AutoCEReaction> ceReaction;
111 0 : if (reactionsStack) {
112 0 : ceReaction.emplace(reactionsStack);
113 : }
114 0 : binding_detail::FastErrorResult rv;
115 0 : self->SetAlt(NonNullHelper(Constify(arg0)), rv);
116 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
117 0 : return false;
118 : }
119 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
120 :
121 0 : return true;
122 : }
123 :
124 : static const JSJitInfo alt_getterinfo = {
125 : { (JSJitGetterOp)get_alt },
126 : { prototypes::id::HTMLImageElement },
127 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
128 : JSJitInfo::Getter,
129 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
130 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
131 : false, /* isInfallible. False in setters. */
132 : false, /* isMovable. Not relevant for setters. */
133 : false, /* isEliminatable. Not relevant for setters. */
134 : false, /* isAlwaysInSlot. Only relevant for getters. */
135 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
136 : false, /* isTypedMethod. Only relevant for methods. */
137 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
138 : };
139 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
140 : static_assert(0 < 1, "There is no slot for us");
141 : static const JSJitInfo alt_setterinfo = {
142 : { (JSJitGetterOp)set_alt },
143 : { prototypes::id::HTMLImageElement },
144 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
145 : JSJitInfo::Setter,
146 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
147 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
148 : false, /* isInfallible. False in setters. */
149 : false, /* isMovable. Not relevant for setters. */
150 : false, /* isEliminatable. Not relevant for setters. */
151 : false, /* isAlwaysInSlot. Only relevant for getters. */
152 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
153 : false, /* isTypedMethod. Only relevant for methods. */
154 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
155 : };
156 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
157 : static_assert(0 < 1, "There is no slot for us");
158 :
159 : static bool
160 0 : get_src(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
161 : {
162 0 : DOMString result;
163 0 : self->GetSrc(result);
164 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
165 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
166 0 : return false;
167 : }
168 0 : return true;
169 : }
170 :
171 : static bool
172 0 : set_src(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
173 : {
174 0 : binding_detail::FakeString arg0;
175 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
176 0 : return false;
177 : }
178 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
179 0 : Maybe<AutoCEReaction> ceReaction;
180 0 : if (reactionsStack) {
181 0 : ceReaction.emplace(reactionsStack);
182 : }
183 0 : binding_detail::FastErrorResult rv;
184 0 : self->SetSrc(NonNullHelper(Constify(arg0)), rv);
185 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
186 0 : return false;
187 : }
188 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
189 :
190 0 : return true;
191 : }
192 :
193 : static const JSJitInfo src_getterinfo = {
194 : { (JSJitGetterOp)get_src },
195 : { prototypes::id::HTMLImageElement },
196 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
197 : JSJitInfo::Getter,
198 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
199 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
200 : false, /* isInfallible. False in setters. */
201 : false, /* isMovable. Not relevant for setters. */
202 : false, /* isEliminatable. Not relevant for setters. */
203 : false, /* isAlwaysInSlot. Only relevant for getters. */
204 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
205 : false, /* isTypedMethod. Only relevant for methods. */
206 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
207 : };
208 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
209 : static_assert(0 < 1, "There is no slot for us");
210 : static const JSJitInfo src_setterinfo = {
211 : { (JSJitGetterOp)set_src },
212 : { prototypes::id::HTMLImageElement },
213 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
214 : JSJitInfo::Setter,
215 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
216 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
217 : false, /* isInfallible. False in setters. */
218 : false, /* isMovable. Not relevant for setters. */
219 : false, /* isEliminatable. Not relevant for setters. */
220 : false, /* isAlwaysInSlot. Only relevant for getters. */
221 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
222 : false, /* isTypedMethod. Only relevant for methods. */
223 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
224 : };
225 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
226 : static_assert(0 < 1, "There is no slot for us");
227 :
228 : static bool
229 0 : get_srcset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
230 : {
231 0 : DOMString result;
232 0 : self->GetSrcset(result);
233 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
234 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
235 0 : return false;
236 : }
237 0 : return true;
238 : }
239 :
240 : static bool
241 0 : set_srcset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
242 : {
243 0 : binding_detail::FakeString arg0;
244 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
245 0 : return false;
246 : }
247 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
248 0 : Maybe<AutoCEReaction> ceReaction;
249 0 : if (reactionsStack) {
250 0 : ceReaction.emplace(reactionsStack);
251 : }
252 0 : binding_detail::FastErrorResult rv;
253 0 : self->SetSrcset(NonNullHelper(Constify(arg0)), rv);
254 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
255 0 : return false;
256 : }
257 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
258 :
259 0 : return true;
260 : }
261 :
262 : static const JSJitInfo srcset_getterinfo = {
263 : { (JSJitGetterOp)get_srcset },
264 : { prototypes::id::HTMLImageElement },
265 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
266 : JSJitInfo::Getter,
267 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
268 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
269 : false, /* isInfallible. False in setters. */
270 : false, /* isMovable. Not relevant for setters. */
271 : false, /* isEliminatable. Not relevant for setters. */
272 : false, /* isAlwaysInSlot. Only relevant for getters. */
273 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
274 : false, /* isTypedMethod. Only relevant for methods. */
275 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
276 : };
277 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
278 : static_assert(0 < 1, "There is no slot for us");
279 : static const JSJitInfo srcset_setterinfo = {
280 : { (JSJitGetterOp)set_srcset },
281 : { prototypes::id::HTMLImageElement },
282 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
283 : JSJitInfo::Setter,
284 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
285 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
286 : false, /* isInfallible. False in setters. */
287 : false, /* isMovable. Not relevant for setters. */
288 : false, /* isEliminatable. Not relevant for setters. */
289 : false, /* isAlwaysInSlot. Only relevant for getters. */
290 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
291 : false, /* isTypedMethod. Only relevant for methods. */
292 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
293 : };
294 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
295 : static_assert(0 < 1, "There is no slot for us");
296 :
297 : static bool
298 0 : get_crossOrigin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
299 : {
300 0 : DOMString result;
301 0 : self->GetCrossOrigin(result);
302 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
303 0 : if (!xpc::StringToJsval(cx, result, args.rval())) {
304 0 : return false;
305 : }
306 0 : return true;
307 : }
308 :
309 : static bool
310 0 : set_crossOrigin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
311 : {
312 0 : binding_detail::FakeString arg0;
313 0 : if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) {
314 0 : return false;
315 : }
316 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
317 0 : Maybe<AutoCEReaction> ceReaction;
318 0 : if (reactionsStack) {
319 0 : ceReaction.emplace(reactionsStack);
320 : }
321 0 : binding_detail::FastErrorResult rv;
322 0 : self->SetCrossOrigin(NonNullHelper(Constify(arg0)), rv);
323 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
324 0 : return false;
325 : }
326 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
327 :
328 0 : return true;
329 : }
330 :
331 : static const JSJitInfo crossOrigin_getterinfo = {
332 : { (JSJitGetterOp)get_crossOrigin },
333 : { prototypes::id::HTMLImageElement },
334 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
335 : JSJitInfo::Getter,
336 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
337 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
338 : false, /* isInfallible. False in setters. */
339 : false, /* isMovable. Not relevant for setters. */
340 : false, /* isEliminatable. Not relevant for setters. */
341 : false, /* isAlwaysInSlot. Only relevant for getters. */
342 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
343 : false, /* isTypedMethod. Only relevant for methods. */
344 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
345 : };
346 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
347 : static_assert(0 < 1, "There is no slot for us");
348 : static const JSJitInfo crossOrigin_setterinfo = {
349 : { (JSJitGetterOp)set_crossOrigin },
350 : { prototypes::id::HTMLImageElement },
351 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
352 : JSJitInfo::Setter,
353 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
354 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
355 : false, /* isInfallible. False in setters. */
356 : false, /* isMovable. Not relevant for setters. */
357 : false, /* isEliminatable. Not relevant for setters. */
358 : false, /* isAlwaysInSlot. Only relevant for getters. */
359 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
360 : false, /* isTypedMethod. Only relevant for methods. */
361 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
362 : };
363 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
364 : static_assert(0 < 1, "There is no slot for us");
365 :
366 : static bool
367 0 : get_useMap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
368 : {
369 0 : DOMString result;
370 0 : self->GetUseMap(result);
371 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
372 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
373 0 : return false;
374 : }
375 0 : return true;
376 : }
377 :
378 : static bool
379 0 : set_useMap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
380 : {
381 0 : binding_detail::FakeString arg0;
382 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
383 0 : return false;
384 : }
385 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
386 0 : Maybe<AutoCEReaction> ceReaction;
387 0 : if (reactionsStack) {
388 0 : ceReaction.emplace(reactionsStack);
389 : }
390 0 : binding_detail::FastErrorResult rv;
391 0 : self->SetUseMap(NonNullHelper(Constify(arg0)), rv);
392 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
393 0 : return false;
394 : }
395 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
396 :
397 0 : return true;
398 : }
399 :
400 : static const JSJitInfo useMap_getterinfo = {
401 : { (JSJitGetterOp)get_useMap },
402 : { prototypes::id::HTMLImageElement },
403 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
404 : JSJitInfo::Getter,
405 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
406 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
407 : false, /* isInfallible. False in setters. */
408 : false, /* isMovable. Not relevant for setters. */
409 : false, /* isEliminatable. Not relevant for setters. */
410 : false, /* isAlwaysInSlot. Only relevant for getters. */
411 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
412 : false, /* isTypedMethod. Only relevant for methods. */
413 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
414 : };
415 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
416 : static_assert(0 < 1, "There is no slot for us");
417 : static const JSJitInfo useMap_setterinfo = {
418 : { (JSJitGetterOp)set_useMap },
419 : { prototypes::id::HTMLImageElement },
420 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
421 : JSJitInfo::Setter,
422 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
423 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
424 : false, /* isInfallible. False in setters. */
425 : false, /* isMovable. Not relevant for setters. */
426 : false, /* isEliminatable. Not relevant for setters. */
427 : false, /* isAlwaysInSlot. Only relevant for getters. */
428 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
429 : false, /* isTypedMethod. Only relevant for methods. */
430 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
431 : };
432 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
433 : static_assert(0 < 1, "There is no slot for us");
434 :
435 : static bool
436 0 : get_referrerPolicy(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
437 : {
438 0 : DOMString result;
439 0 : self->GetReferrerPolicy(result);
440 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
441 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
442 0 : return false;
443 : }
444 0 : return true;
445 : }
446 :
447 : static bool
448 0 : set_referrerPolicy(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
449 : {
450 0 : binding_detail::FakeString arg0;
451 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
452 0 : return false;
453 : }
454 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
455 0 : Maybe<AutoCEReaction> ceReaction;
456 0 : if (reactionsStack) {
457 0 : ceReaction.emplace(reactionsStack);
458 : }
459 0 : binding_detail::FastErrorResult rv;
460 0 : self->SetReferrerPolicy(NonNullHelper(Constify(arg0)), rv);
461 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
462 0 : return false;
463 : }
464 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
465 :
466 0 : return true;
467 : }
468 :
469 : static const JSJitInfo referrerPolicy_getterinfo = {
470 : { (JSJitGetterOp)get_referrerPolicy },
471 : { prototypes::id::HTMLImageElement },
472 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
473 : JSJitInfo::Getter,
474 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
475 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
476 : false, /* isInfallible. False in setters. */
477 : false, /* isMovable. Not relevant for setters. */
478 : false, /* isEliminatable. Not relevant for setters. */
479 : false, /* isAlwaysInSlot. Only relevant for getters. */
480 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
481 : false, /* isTypedMethod. Only relevant for methods. */
482 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
483 : };
484 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
485 : static_assert(0 < 1, "There is no slot for us");
486 : static const JSJitInfo referrerPolicy_setterinfo = {
487 : { (JSJitGetterOp)set_referrerPolicy },
488 : { prototypes::id::HTMLImageElement },
489 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
490 : JSJitInfo::Setter,
491 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
492 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
493 : false, /* isInfallible. False in setters. */
494 : false, /* isMovable. Not relevant for setters. */
495 : false, /* isEliminatable. Not relevant for setters. */
496 : false, /* isAlwaysInSlot. Only relevant for getters. */
497 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
498 : false, /* isTypedMethod. Only relevant for methods. */
499 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
500 : };
501 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
502 : static_assert(0 < 1, "There is no slot for us");
503 :
504 : static bool
505 0 : get_isMap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
506 : {
507 0 : bool result(self->IsMap());
508 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
509 0 : args.rval().setBoolean(result);
510 0 : return true;
511 : }
512 :
513 : static bool
514 0 : set_isMap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
515 : {
516 : bool arg0;
517 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
518 0 : return false;
519 : }
520 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
521 0 : Maybe<AutoCEReaction> ceReaction;
522 0 : if (reactionsStack) {
523 0 : ceReaction.emplace(reactionsStack);
524 : }
525 0 : binding_detail::FastErrorResult rv;
526 0 : self->SetIsMap(arg0, rv);
527 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
528 0 : return false;
529 : }
530 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
531 :
532 0 : return true;
533 : }
534 :
535 : static const JSJitInfo isMap_getterinfo = {
536 : { (JSJitGetterOp)get_isMap },
537 : { prototypes::id::HTMLImageElement },
538 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
539 : JSJitInfo::Getter,
540 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
541 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
542 : true, /* isInfallible. False in setters. */
543 : false, /* isMovable. Not relevant for setters. */
544 : false, /* isEliminatable. Not relevant for setters. */
545 : false, /* isAlwaysInSlot. Only relevant for getters. */
546 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
547 : false, /* isTypedMethod. Only relevant for methods. */
548 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
549 : };
550 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
551 : static_assert(0 < 1, "There is no slot for us");
552 : static const JSJitInfo isMap_setterinfo = {
553 : { (JSJitGetterOp)set_isMap },
554 : { prototypes::id::HTMLImageElement },
555 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
556 : JSJitInfo::Setter,
557 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
558 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
559 : false, /* isInfallible. False in setters. */
560 : false, /* isMovable. Not relevant for setters. */
561 : false, /* isEliminatable. Not relevant for setters. */
562 : false, /* isAlwaysInSlot. Only relevant for getters. */
563 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
564 : false, /* isTypedMethod. Only relevant for methods. */
565 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
566 : };
567 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
568 : static_assert(0 < 1, "There is no slot for us");
569 :
570 : static bool
571 0 : get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
572 : {
573 0 : uint32_t result(self->Width());
574 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
575 0 : args.rval().setNumber(result);
576 0 : return true;
577 : }
578 :
579 : static bool
580 0 : set_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
581 : {
582 : uint32_t arg0;
583 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
584 0 : return false;
585 : }
586 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
587 0 : Maybe<AutoCEReaction> ceReaction;
588 0 : if (reactionsStack) {
589 0 : ceReaction.emplace(reactionsStack);
590 : }
591 0 : binding_detail::FastErrorResult rv;
592 0 : self->SetWidth(arg0, rv);
593 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
594 0 : return false;
595 : }
596 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
597 :
598 0 : return true;
599 : }
600 :
601 : static const JSJitInfo width_getterinfo = {
602 : { (JSJitGetterOp)get_width },
603 : { prototypes::id::HTMLImageElement },
604 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
605 : JSJitInfo::Getter,
606 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
607 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
608 : true, /* isInfallible. False in setters. */
609 : false, /* isMovable. Not relevant for setters. */
610 : false, /* isEliminatable. Not relevant for setters. */
611 : false, /* isAlwaysInSlot. Only relevant for getters. */
612 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
613 : false, /* isTypedMethod. Only relevant for methods. */
614 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
615 : };
616 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
617 : static_assert(0 < 1, "There is no slot for us");
618 : static const JSJitInfo width_setterinfo = {
619 : { (JSJitGetterOp)set_width },
620 : { prototypes::id::HTMLImageElement },
621 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
622 : JSJitInfo::Setter,
623 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
624 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
625 : false, /* isInfallible. False in setters. */
626 : false, /* isMovable. Not relevant for setters. */
627 : false, /* isEliminatable. Not relevant for setters. */
628 : false, /* isAlwaysInSlot. Only relevant for getters. */
629 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
630 : false, /* isTypedMethod. Only relevant for methods. */
631 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
632 : };
633 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
634 : static_assert(0 < 1, "There is no slot for us");
635 :
636 : static bool
637 0 : get_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
638 : {
639 0 : uint32_t result(self->Height());
640 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
641 0 : args.rval().setNumber(result);
642 0 : return true;
643 : }
644 :
645 : static bool
646 0 : set_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
647 : {
648 : uint32_t arg0;
649 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
650 0 : return false;
651 : }
652 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
653 0 : Maybe<AutoCEReaction> ceReaction;
654 0 : if (reactionsStack) {
655 0 : ceReaction.emplace(reactionsStack);
656 : }
657 0 : binding_detail::FastErrorResult rv;
658 0 : self->SetHeight(arg0, rv);
659 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
660 0 : return false;
661 : }
662 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
663 :
664 0 : return true;
665 : }
666 :
667 : static const JSJitInfo height_getterinfo = {
668 : { (JSJitGetterOp)get_height },
669 : { prototypes::id::HTMLImageElement },
670 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
671 : JSJitInfo::Getter,
672 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
673 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
674 : true, /* isInfallible. False in setters. */
675 : false, /* isMovable. Not relevant for setters. */
676 : false, /* isEliminatable. Not relevant for setters. */
677 : false, /* isAlwaysInSlot. Only relevant for getters. */
678 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
679 : false, /* isTypedMethod. Only relevant for methods. */
680 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
681 : };
682 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
683 : static_assert(0 < 1, "There is no slot for us");
684 : static const JSJitInfo height_setterinfo = {
685 : { (JSJitGetterOp)set_height },
686 : { prototypes::id::HTMLImageElement },
687 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
688 : JSJitInfo::Setter,
689 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
690 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
691 : false, /* isInfallible. False in setters. */
692 : false, /* isMovable. Not relevant for setters. */
693 : false, /* isEliminatable. Not relevant for setters. */
694 : false, /* isAlwaysInSlot. Only relevant for getters. */
695 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
696 : false, /* isTypedMethod. Only relevant for methods. */
697 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
698 : };
699 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
700 : static_assert(0 < 1, "There is no slot for us");
701 :
702 : static bool
703 0 : get_naturalWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
704 : {
705 0 : uint32_t result(self->NaturalWidth());
706 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
707 0 : args.rval().setNumber(result);
708 0 : return true;
709 : }
710 :
711 : static const JSJitInfo naturalWidth_getterinfo = {
712 : { (JSJitGetterOp)get_naturalWidth },
713 : { prototypes::id::HTMLImageElement },
714 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
715 : JSJitInfo::Getter,
716 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
717 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
718 : true, /* isInfallible. False in setters. */
719 : false, /* isMovable. Not relevant for setters. */
720 : false, /* isEliminatable. Not relevant for setters. */
721 : false, /* isAlwaysInSlot. Only relevant for getters. */
722 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
723 : false, /* isTypedMethod. Only relevant for methods. */
724 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
725 : };
726 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
727 : static_assert(0 < 1, "There is no slot for us");
728 :
729 : static bool
730 0 : get_naturalHeight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
731 : {
732 0 : uint32_t result(self->NaturalHeight());
733 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
734 0 : args.rval().setNumber(result);
735 0 : return true;
736 : }
737 :
738 : static const JSJitInfo naturalHeight_getterinfo = {
739 : { (JSJitGetterOp)get_naturalHeight },
740 : { prototypes::id::HTMLImageElement },
741 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
742 : JSJitInfo::Getter,
743 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
744 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
745 : true, /* isInfallible. False in setters. */
746 : false, /* isMovable. Not relevant for setters. */
747 : false, /* isEliminatable. Not relevant for setters. */
748 : false, /* isAlwaysInSlot. Only relevant for getters. */
749 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
750 : false, /* isTypedMethod. Only relevant for methods. */
751 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
752 : };
753 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
754 : static_assert(0 < 1, "There is no slot for us");
755 :
756 : static bool
757 0 : get_complete(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
758 : {
759 0 : bool result(self->Complete());
760 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
761 0 : args.rval().setBoolean(result);
762 0 : return true;
763 : }
764 :
765 : static const JSJitInfo complete_getterinfo = {
766 : { (JSJitGetterOp)get_complete },
767 : { prototypes::id::HTMLImageElement },
768 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
769 : JSJitInfo::Getter,
770 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
771 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
772 : true, /* isInfallible. False in setters. */
773 : false, /* isMovable. Not relevant for setters. */
774 : false, /* isEliminatable. Not relevant for setters. */
775 : false, /* isAlwaysInSlot. Only relevant for getters. */
776 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
777 : false, /* isTypedMethod. Only relevant for methods. */
778 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
779 : };
780 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
781 : static_assert(0 < 1, "There is no slot for us");
782 :
783 : static bool
784 0 : get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
785 : {
786 0 : DOMString result;
787 0 : self->GetName(result);
788 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
789 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
790 0 : return false;
791 : }
792 0 : return true;
793 : }
794 :
795 : static bool
796 0 : set_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
797 : {
798 0 : binding_detail::FakeString arg0;
799 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
800 0 : return false;
801 : }
802 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
803 0 : Maybe<AutoCEReaction> ceReaction;
804 0 : if (reactionsStack) {
805 0 : ceReaction.emplace(reactionsStack);
806 : }
807 0 : binding_detail::FastErrorResult rv;
808 0 : self->SetName(NonNullHelper(Constify(arg0)), rv);
809 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
810 0 : return false;
811 : }
812 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
813 :
814 0 : return true;
815 : }
816 :
817 : static const JSJitInfo name_getterinfo = {
818 : { (JSJitGetterOp)get_name },
819 : { prototypes::id::HTMLImageElement },
820 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
821 : JSJitInfo::Getter,
822 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
823 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
824 : false, /* isInfallible. False in setters. */
825 : false, /* isMovable. Not relevant for setters. */
826 : false, /* isEliminatable. Not relevant for setters. */
827 : false, /* isAlwaysInSlot. Only relevant for getters. */
828 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
829 : false, /* isTypedMethod. Only relevant for methods. */
830 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
831 : };
832 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
833 : static_assert(0 < 1, "There is no slot for us");
834 : static const JSJitInfo name_setterinfo = {
835 : { (JSJitGetterOp)set_name },
836 : { prototypes::id::HTMLImageElement },
837 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
838 : JSJitInfo::Setter,
839 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
840 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
841 : false, /* isInfallible. False in setters. */
842 : false, /* isMovable. Not relevant for setters. */
843 : false, /* isEliminatable. Not relevant for setters. */
844 : false, /* isAlwaysInSlot. Only relevant for getters. */
845 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
846 : false, /* isTypedMethod. Only relevant for methods. */
847 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
848 : };
849 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
850 : static_assert(0 < 1, "There is no slot for us");
851 :
852 : static bool
853 0 : get_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
854 : {
855 0 : DOMString result;
856 0 : self->GetAlign(result);
857 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
858 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
859 0 : return false;
860 : }
861 0 : return true;
862 : }
863 :
864 : static bool
865 0 : set_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
866 : {
867 0 : binding_detail::FakeString arg0;
868 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
869 0 : return false;
870 : }
871 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
872 0 : Maybe<AutoCEReaction> ceReaction;
873 0 : if (reactionsStack) {
874 0 : ceReaction.emplace(reactionsStack);
875 : }
876 0 : binding_detail::FastErrorResult rv;
877 0 : self->SetAlign(NonNullHelper(Constify(arg0)), rv);
878 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
879 0 : return false;
880 : }
881 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
882 :
883 0 : return true;
884 : }
885 :
886 : static const JSJitInfo align_getterinfo = {
887 : { (JSJitGetterOp)get_align },
888 : { prototypes::id::HTMLImageElement },
889 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
890 : JSJitInfo::Getter,
891 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
892 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
893 : false, /* isInfallible. False in setters. */
894 : false, /* isMovable. Not relevant for setters. */
895 : false, /* isEliminatable. Not relevant for setters. */
896 : false, /* isAlwaysInSlot. Only relevant for getters. */
897 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
898 : false, /* isTypedMethod. Only relevant for methods. */
899 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
900 : };
901 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
902 : static_assert(0 < 1, "There is no slot for us");
903 : static const JSJitInfo align_setterinfo = {
904 : { (JSJitGetterOp)set_align },
905 : { prototypes::id::HTMLImageElement },
906 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
907 : JSJitInfo::Setter,
908 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
909 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
910 : false, /* isInfallible. False in setters. */
911 : false, /* isMovable. Not relevant for setters. */
912 : false, /* isEliminatable. Not relevant for setters. */
913 : false, /* isAlwaysInSlot. Only relevant for getters. */
914 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
915 : false, /* isTypedMethod. Only relevant for methods. */
916 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
917 : };
918 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
919 : static_assert(0 < 1, "There is no slot for us");
920 :
921 : static bool
922 0 : get_hspace(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
923 : {
924 0 : uint32_t result(self->Hspace());
925 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
926 0 : args.rval().setNumber(result);
927 0 : return true;
928 : }
929 :
930 : static bool
931 0 : set_hspace(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
932 : {
933 : uint32_t arg0;
934 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
935 0 : return false;
936 : }
937 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
938 0 : Maybe<AutoCEReaction> ceReaction;
939 0 : if (reactionsStack) {
940 0 : ceReaction.emplace(reactionsStack);
941 : }
942 0 : binding_detail::FastErrorResult rv;
943 0 : self->SetHspace(arg0, rv);
944 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
945 0 : return false;
946 : }
947 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
948 :
949 0 : return true;
950 : }
951 :
952 : static const JSJitInfo hspace_getterinfo = {
953 : { (JSJitGetterOp)get_hspace },
954 : { prototypes::id::HTMLImageElement },
955 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
956 : JSJitInfo::Getter,
957 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
958 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
959 : true, /* isInfallible. False in setters. */
960 : false, /* isMovable. Not relevant for setters. */
961 : false, /* isEliminatable. Not relevant for setters. */
962 : false, /* isAlwaysInSlot. Only relevant for getters. */
963 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
964 : false, /* isTypedMethod. Only relevant for methods. */
965 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
966 : };
967 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
968 : static_assert(0 < 1, "There is no slot for us");
969 : static const JSJitInfo hspace_setterinfo = {
970 : { (JSJitGetterOp)set_hspace },
971 : { prototypes::id::HTMLImageElement },
972 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
973 : JSJitInfo::Setter,
974 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
975 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
976 : false, /* isInfallible. False in setters. */
977 : false, /* isMovable. Not relevant for setters. */
978 : false, /* isEliminatable. Not relevant for setters. */
979 : false, /* isAlwaysInSlot. Only relevant for getters. */
980 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
981 : false, /* isTypedMethod. Only relevant for methods. */
982 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
983 : };
984 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
985 : static_assert(0 < 1, "There is no slot for us");
986 :
987 : static bool
988 0 : get_vspace(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
989 : {
990 0 : uint32_t result(self->Vspace());
991 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
992 0 : args.rval().setNumber(result);
993 0 : return true;
994 : }
995 :
996 : static bool
997 0 : set_vspace(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
998 : {
999 : uint32_t arg0;
1000 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
1001 0 : return false;
1002 : }
1003 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
1004 0 : Maybe<AutoCEReaction> ceReaction;
1005 0 : if (reactionsStack) {
1006 0 : ceReaction.emplace(reactionsStack);
1007 : }
1008 0 : binding_detail::FastErrorResult rv;
1009 0 : self->SetVspace(arg0, rv);
1010 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1011 0 : return false;
1012 : }
1013 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1014 :
1015 0 : return true;
1016 : }
1017 :
1018 : static const JSJitInfo vspace_getterinfo = {
1019 : { (JSJitGetterOp)get_vspace },
1020 : { prototypes::id::HTMLImageElement },
1021 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1022 : JSJitInfo::Getter,
1023 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1024 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
1025 : true, /* isInfallible. False in setters. */
1026 : false, /* isMovable. Not relevant for setters. */
1027 : false, /* isEliminatable. Not relevant for setters. */
1028 : false, /* isAlwaysInSlot. Only relevant for getters. */
1029 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1030 : false, /* isTypedMethod. Only relevant for methods. */
1031 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1032 : };
1033 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1034 : static_assert(0 < 1, "There is no slot for us");
1035 : static const JSJitInfo vspace_setterinfo = {
1036 : { (JSJitGetterOp)set_vspace },
1037 : { prototypes::id::HTMLImageElement },
1038 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1039 : JSJitInfo::Setter,
1040 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1041 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1042 : false, /* isInfallible. False in setters. */
1043 : false, /* isMovable. Not relevant for setters. */
1044 : false, /* isEliminatable. Not relevant for setters. */
1045 : false, /* isAlwaysInSlot. Only relevant for getters. */
1046 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1047 : false, /* isTypedMethod. Only relevant for methods. */
1048 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1049 : };
1050 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1051 : static_assert(0 < 1, "There is no slot for us");
1052 :
1053 : static bool
1054 0 : get_longDesc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
1055 : {
1056 0 : DOMString result;
1057 0 : self->GetLongDesc(result);
1058 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1059 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1060 0 : return false;
1061 : }
1062 0 : return true;
1063 : }
1064 :
1065 : static bool
1066 0 : set_longDesc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
1067 : {
1068 0 : binding_detail::FakeString arg0;
1069 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1070 0 : return false;
1071 : }
1072 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
1073 0 : Maybe<AutoCEReaction> ceReaction;
1074 0 : if (reactionsStack) {
1075 0 : ceReaction.emplace(reactionsStack);
1076 : }
1077 0 : binding_detail::FastErrorResult rv;
1078 0 : self->SetLongDesc(NonNullHelper(Constify(arg0)), rv);
1079 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1080 0 : return false;
1081 : }
1082 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1083 :
1084 0 : return true;
1085 : }
1086 :
1087 : static const JSJitInfo longDesc_getterinfo = {
1088 : { (JSJitGetterOp)get_longDesc },
1089 : { prototypes::id::HTMLImageElement },
1090 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1091 : JSJitInfo::Getter,
1092 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1093 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1094 : false, /* isInfallible. False in setters. */
1095 : false, /* isMovable. Not relevant for setters. */
1096 : false, /* isEliminatable. Not relevant for setters. */
1097 : false, /* isAlwaysInSlot. Only relevant for getters. */
1098 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1099 : false, /* isTypedMethod. Only relevant for methods. */
1100 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1101 : };
1102 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1103 : static_assert(0 < 1, "There is no slot for us");
1104 : static const JSJitInfo longDesc_setterinfo = {
1105 : { (JSJitGetterOp)set_longDesc },
1106 : { prototypes::id::HTMLImageElement },
1107 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1108 : JSJitInfo::Setter,
1109 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1110 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1111 : false, /* isInfallible. False in setters. */
1112 : false, /* isMovable. Not relevant for setters. */
1113 : false, /* isEliminatable. Not relevant for setters. */
1114 : false, /* isAlwaysInSlot. Only relevant for getters. */
1115 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1116 : false, /* isTypedMethod. Only relevant for methods. */
1117 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1118 : };
1119 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1120 : static_assert(0 < 1, "There is no slot for us");
1121 :
1122 : static bool
1123 0 : get_border(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
1124 : {
1125 0 : DOMString result;
1126 0 : self->GetBorder(result);
1127 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1128 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1129 0 : return false;
1130 : }
1131 0 : return true;
1132 : }
1133 :
1134 : static bool
1135 0 : set_border(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
1136 : {
1137 0 : binding_detail::FakeString arg0;
1138 0 : if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
1139 0 : return false;
1140 : }
1141 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
1142 0 : Maybe<AutoCEReaction> ceReaction;
1143 0 : if (reactionsStack) {
1144 0 : ceReaction.emplace(reactionsStack);
1145 : }
1146 0 : binding_detail::FastErrorResult rv;
1147 0 : self->SetBorder(NonNullHelper(Constify(arg0)), rv);
1148 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1149 0 : return false;
1150 : }
1151 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1152 :
1153 0 : return true;
1154 : }
1155 :
1156 : static const JSJitInfo border_getterinfo = {
1157 : { (JSJitGetterOp)get_border },
1158 : { prototypes::id::HTMLImageElement },
1159 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1160 : JSJitInfo::Getter,
1161 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1162 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1163 : false, /* isInfallible. False in setters. */
1164 : false, /* isMovable. Not relevant for setters. */
1165 : false, /* isEliminatable. Not relevant for setters. */
1166 : false, /* isAlwaysInSlot. Only relevant for getters. */
1167 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1168 : false, /* isTypedMethod. Only relevant for methods. */
1169 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1170 : };
1171 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1172 : static_assert(0 < 1, "There is no slot for us");
1173 : static const JSJitInfo border_setterinfo = {
1174 : { (JSJitGetterOp)set_border },
1175 : { prototypes::id::HTMLImageElement },
1176 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1177 : JSJitInfo::Setter,
1178 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1179 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1180 : false, /* isInfallible. False in setters. */
1181 : false, /* isMovable. Not relevant for setters. */
1182 : false, /* isEliminatable. Not relevant for setters. */
1183 : false, /* isAlwaysInSlot. Only relevant for getters. */
1184 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1185 : false, /* isTypedMethod. Only relevant for methods. */
1186 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1187 : };
1188 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1189 : static_assert(0 < 1, "There is no slot for us");
1190 :
1191 : static bool
1192 0 : get_sizes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
1193 : {
1194 0 : DOMString result;
1195 0 : self->GetSizes(result);
1196 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1197 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1198 0 : return false;
1199 : }
1200 0 : return true;
1201 : }
1202 :
1203 : static bool
1204 0 : set_sizes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
1205 : {
1206 0 : binding_detail::FakeString arg0;
1207 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1208 0 : return false;
1209 : }
1210 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
1211 0 : Maybe<AutoCEReaction> ceReaction;
1212 0 : if (reactionsStack) {
1213 0 : ceReaction.emplace(reactionsStack);
1214 : }
1215 0 : binding_detail::FastErrorResult rv;
1216 0 : self->SetSizes(NonNullHelper(Constify(arg0)), rv);
1217 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1218 0 : return false;
1219 : }
1220 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1221 :
1222 0 : return true;
1223 : }
1224 :
1225 : static const JSJitInfo sizes_getterinfo = {
1226 : { (JSJitGetterOp)get_sizes },
1227 : { prototypes::id::HTMLImageElement },
1228 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1229 : JSJitInfo::Getter,
1230 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1231 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1232 : false, /* isInfallible. False in setters. */
1233 : false, /* isMovable. Not relevant for setters. */
1234 : false, /* isEliminatable. Not relevant for setters. */
1235 : false, /* isAlwaysInSlot. Only relevant for getters. */
1236 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1237 : false, /* isTypedMethod. Only relevant for methods. */
1238 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1239 : };
1240 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1241 : static_assert(0 < 1, "There is no slot for us");
1242 : static const JSJitInfo sizes_setterinfo = {
1243 : { (JSJitGetterOp)set_sizes },
1244 : { prototypes::id::HTMLImageElement },
1245 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1246 : JSJitInfo::Setter,
1247 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1248 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1249 : false, /* isInfallible. False in setters. */
1250 : false, /* isMovable. Not relevant for setters. */
1251 : false, /* isEliminatable. Not relevant for setters. */
1252 : false, /* isAlwaysInSlot. Only relevant for getters. */
1253 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1254 : false, /* isTypedMethod. Only relevant for methods. */
1255 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1256 : };
1257 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1258 : static_assert(0 < 1, "There is no slot for us");
1259 :
1260 : static bool
1261 0 : get_currentSrc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
1262 : {
1263 0 : DOMString result;
1264 0 : self->GetCurrentSrc(result);
1265 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1266 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1267 0 : return false;
1268 : }
1269 0 : return true;
1270 : }
1271 :
1272 : static const JSJitInfo currentSrc_getterinfo = {
1273 : { (JSJitGetterOp)get_currentSrc },
1274 : { prototypes::id::HTMLImageElement },
1275 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1276 : JSJitInfo::Getter,
1277 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1278 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1279 : false, /* isInfallible. False in setters. */
1280 : false, /* isMovable. Not relevant for setters. */
1281 : false, /* isEliminatable. Not relevant for setters. */
1282 : false, /* isAlwaysInSlot. Only relevant for getters. */
1283 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1284 : false, /* isTypedMethod. Only relevant for methods. */
1285 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1286 : };
1287 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1288 : static_assert(0 < 1, "There is no slot for us");
1289 :
1290 : static bool
1291 0 : get_lowsrc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
1292 : {
1293 0 : DOMString result;
1294 0 : self->GetLowsrc(result);
1295 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1296 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1297 0 : return false;
1298 : }
1299 0 : return true;
1300 : }
1301 :
1302 : static bool
1303 0 : set_lowsrc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
1304 : {
1305 0 : binding_detail::FakeString arg0;
1306 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1307 0 : return false;
1308 : }
1309 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
1310 0 : Maybe<AutoCEReaction> ceReaction;
1311 0 : if (reactionsStack) {
1312 0 : ceReaction.emplace(reactionsStack);
1313 : }
1314 0 : self->SetLowsrc(NonNullHelper(Constify(arg0)));
1315 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1316 :
1317 0 : return true;
1318 : }
1319 :
1320 : static const JSJitInfo lowsrc_getterinfo = {
1321 : { (JSJitGetterOp)get_lowsrc },
1322 : { prototypes::id::HTMLImageElement },
1323 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1324 : JSJitInfo::Getter,
1325 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1326 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1327 : false, /* isInfallible. False in setters. */
1328 : false, /* isMovable. Not relevant for setters. */
1329 : false, /* isEliminatable. Not relevant for setters. */
1330 : false, /* isAlwaysInSlot. Only relevant for getters. */
1331 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1332 : false, /* isTypedMethod. Only relevant for methods. */
1333 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1334 : };
1335 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1336 : static_assert(0 < 1, "There is no slot for us");
1337 : static const JSJitInfo lowsrc_setterinfo = {
1338 : { (JSJitGetterOp)set_lowsrc },
1339 : { prototypes::id::HTMLImageElement },
1340 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1341 : JSJitInfo::Setter,
1342 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1343 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1344 : false, /* isInfallible. False in setters. */
1345 : false, /* isMovable. Not relevant for setters. */
1346 : false, /* isEliminatable. Not relevant for setters. */
1347 : false, /* isAlwaysInSlot. Only relevant for getters. */
1348 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1349 : false, /* isTypedMethod. Only relevant for methods. */
1350 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1351 : };
1352 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1353 : static_assert(0 < 1, "There is no slot for us");
1354 :
1355 : static bool
1356 0 : get_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
1357 : {
1358 0 : int32_t result(self->X());
1359 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1360 0 : args.rval().setInt32(int32_t(result));
1361 0 : return true;
1362 : }
1363 :
1364 : static const JSJitInfo x_getterinfo = {
1365 : { (JSJitGetterOp)get_x },
1366 : { prototypes::id::HTMLImageElement },
1367 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1368 : JSJitInfo::Getter,
1369 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1370 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
1371 : true, /* isInfallible. False in setters. */
1372 : false, /* isMovable. Not relevant for setters. */
1373 : false, /* isEliminatable. Not relevant for setters. */
1374 : false, /* isAlwaysInSlot. Only relevant for getters. */
1375 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1376 : false, /* isTypedMethod. Only relevant for methods. */
1377 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1378 : };
1379 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1380 : static_assert(0 < 1, "There is no slot for us");
1381 :
1382 : static bool
1383 0 : get_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
1384 : {
1385 0 : int32_t result(self->Y());
1386 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1387 0 : args.rval().setInt32(int32_t(result));
1388 0 : return true;
1389 : }
1390 :
1391 : static const JSJitInfo y_getterinfo = {
1392 : { (JSJitGetterOp)get_y },
1393 : { prototypes::id::HTMLImageElement },
1394 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1395 : JSJitInfo::Getter,
1396 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1397 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
1398 : true, /* isInfallible. False in setters. */
1399 : false, /* isMovable. Not relevant for setters. */
1400 : false, /* isEliminatable. Not relevant for setters. */
1401 : false, /* isAlwaysInSlot. Only relevant for getters. */
1402 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1403 : false, /* isTypedMethod. Only relevant for methods. */
1404 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1405 : };
1406 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1407 : static_assert(0 < 1, "There is no slot for us");
1408 :
1409 : static bool
1410 0 : get_loadingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
1411 : {
1412 0 : bool result(self->LoadingEnabled());
1413 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1414 0 : args.rval().setBoolean(result);
1415 0 : return true;
1416 : }
1417 :
1418 : static bool
1419 0 : set_loadingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitSetterCallArgs args)
1420 : {
1421 : bool arg0;
1422 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
1423 0 : return false;
1424 : }
1425 0 : self->SetLoadingEnabled(arg0);
1426 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1427 :
1428 0 : return true;
1429 : }
1430 :
1431 : static const JSJitInfo loadingEnabled_getterinfo = {
1432 : { (JSJitGetterOp)get_loadingEnabled },
1433 : { prototypes::id::HTMLImageElement },
1434 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1435 : JSJitInfo::Getter,
1436 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1437 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
1438 : true, /* isInfallible. False in setters. */
1439 : false, /* isMovable. Not relevant for setters. */
1440 : false, /* isEliminatable. Not relevant for setters. */
1441 : false, /* isAlwaysInSlot. Only relevant for getters. */
1442 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1443 : false, /* isTypedMethod. Only relevant for methods. */
1444 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1445 : };
1446 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1447 : static_assert(0 < 1, "There is no slot for us");
1448 : static const JSJitInfo loadingEnabled_setterinfo = {
1449 : { (JSJitGetterOp)set_loadingEnabled },
1450 : { prototypes::id::HTMLImageElement },
1451 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1452 : JSJitInfo::Setter,
1453 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1454 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1455 : false, /* isInfallible. False in setters. */
1456 : false, /* isMovable. Not relevant for setters. */
1457 : false, /* isEliminatable. Not relevant for setters. */
1458 : false, /* isAlwaysInSlot. Only relevant for getters. */
1459 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1460 : false, /* isTypedMethod. Only relevant for methods. */
1461 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1462 : };
1463 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1464 : static_assert(0 < 1, "There is no slot for us");
1465 :
1466 : static bool
1467 0 : get_imageBlockingStatus(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
1468 : {
1469 0 : int16_t result(self->ImageBlockingStatus());
1470 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1471 0 : args.rval().setInt32(int32_t(result));
1472 0 : return true;
1473 : }
1474 :
1475 : static const JSJitInfo imageBlockingStatus_getterinfo = {
1476 : { (JSJitGetterOp)get_imageBlockingStatus },
1477 : { prototypes::id::HTMLImageElement },
1478 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1479 : JSJitInfo::Getter,
1480 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1481 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
1482 : true, /* isInfallible. False in setters. */
1483 : false, /* isMovable. Not relevant for setters. */
1484 : false, /* isEliminatable. Not relevant for setters. */
1485 : false, /* isAlwaysInSlot. Only relevant for getters. */
1486 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1487 : false, /* isTypedMethod. Only relevant for methods. */
1488 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1489 : };
1490 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1491 : static_assert(0 < 1, "There is no slot for us");
1492 :
1493 : static bool
1494 0 : addObserver(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, const JSJitMethodCallArgs& args)
1495 : {
1496 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1497 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLImageElement.addObserver");
1498 : }
1499 : imgINotificationObserver* arg0;
1500 0 : RefPtr<imgINotificationObserver> arg0_holder;
1501 0 : if (args[0].isObject()) {
1502 0 : JS::Rooted<JSObject*> source(cx, &args[0].toObject());
1503 0 : if (NS_FAILED(UnwrapArg<imgINotificationObserver>(cx, source, getter_AddRefs(arg0_holder)))) {
1504 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of HTMLImageElement.addObserver", "imgINotificationObserver");
1505 0 : return false;
1506 : }
1507 0 : MOZ_ASSERT(arg0_holder);
1508 0 : arg0 = arg0_holder;
1509 : } else {
1510 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of HTMLImageElement.addObserver");
1511 0 : return false;
1512 : }
1513 0 : self->AddObserver(NonNullHelper(arg0));
1514 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1515 0 : args.rval().setUndefined();
1516 0 : return true;
1517 : }
1518 :
1519 : static const JSJitInfo addObserver_methodinfo = {
1520 : { (JSJitGetterOp)addObserver },
1521 : { prototypes::id::HTMLImageElement },
1522 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1523 : JSJitInfo::Method,
1524 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1525 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1526 : false, /* isInfallible. False in setters. */
1527 : false, /* isMovable. Not relevant for setters. */
1528 : false, /* isEliminatable. Not relevant for setters. */
1529 : false, /* isAlwaysInSlot. Only relevant for getters. */
1530 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1531 : false, /* isTypedMethod. Only relevant for methods. */
1532 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1533 : };
1534 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1535 : static_assert(0 < 1, "There is no slot for us");
1536 :
1537 : static bool
1538 0 : removeObserver(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, const JSJitMethodCallArgs& args)
1539 : {
1540 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1541 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLImageElement.removeObserver");
1542 : }
1543 : imgINotificationObserver* arg0;
1544 0 : RefPtr<imgINotificationObserver> arg0_holder;
1545 0 : if (args[0].isObject()) {
1546 0 : JS::Rooted<JSObject*> source(cx, &args[0].toObject());
1547 0 : if (NS_FAILED(UnwrapArg<imgINotificationObserver>(cx, source, getter_AddRefs(arg0_holder)))) {
1548 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of HTMLImageElement.removeObserver", "imgINotificationObserver");
1549 0 : return false;
1550 : }
1551 0 : MOZ_ASSERT(arg0_holder);
1552 0 : arg0 = arg0_holder;
1553 : } else {
1554 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of HTMLImageElement.removeObserver");
1555 0 : return false;
1556 : }
1557 0 : self->RemoveObserver(NonNullHelper(arg0));
1558 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1559 0 : args.rval().setUndefined();
1560 0 : return true;
1561 : }
1562 :
1563 : static const JSJitInfo removeObserver_methodinfo = {
1564 : { (JSJitGetterOp)removeObserver },
1565 : { prototypes::id::HTMLImageElement },
1566 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1567 : JSJitInfo::Method,
1568 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1569 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1570 : false, /* isInfallible. False in setters. */
1571 : false, /* isMovable. Not relevant for setters. */
1572 : false, /* isEliminatable. Not relevant for setters. */
1573 : false, /* isAlwaysInSlot. Only relevant for getters. */
1574 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1575 : false, /* isTypedMethod. Only relevant for methods. */
1576 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1577 : };
1578 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1579 : static_assert(0 < 1, "There is no slot for us");
1580 :
1581 : static bool
1582 0 : getRequest(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, const JSJitMethodCallArgs& args)
1583 : {
1584 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1585 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLImageElement.getRequest");
1586 : }
1587 : int32_t arg0;
1588 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) {
1589 0 : return false;
1590 : }
1591 0 : binding_detail::FastErrorResult rv;
1592 0 : auto result(StrongOrRawPtr<imgIRequest>(self->GetRequest(arg0, rv)));
1593 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1594 0 : return false;
1595 : }
1596 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1597 0 : if (!result) {
1598 0 : args.rval().setNull();
1599 0 : return true;
1600 : }
1601 0 : if (!WrapObject(cx, result, &NS_GET_IID(imgIRequest), args.rval())) {
1602 0 : return false;
1603 : }
1604 0 : return true;
1605 : }
1606 :
1607 : static const JSJitInfo getRequest_methodinfo = {
1608 : { (JSJitGetterOp)getRequest },
1609 : { prototypes::id::HTMLImageElement },
1610 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1611 : JSJitInfo::Method,
1612 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1613 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
1614 : false, /* isInfallible. False in setters. */
1615 : false, /* isMovable. Not relevant for setters. */
1616 : false, /* isEliminatable. Not relevant for setters. */
1617 : false, /* isAlwaysInSlot. Only relevant for getters. */
1618 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1619 : false, /* isTypedMethod. Only relevant for methods. */
1620 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1621 : };
1622 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1623 : static_assert(0 < 1, "There is no slot for us");
1624 :
1625 : static bool
1626 0 : getRequestType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, const JSJitMethodCallArgs& args)
1627 : {
1628 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1629 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLImageElement.getRequestType");
1630 : }
1631 : imgIRequest* arg0;
1632 0 : RefPtr<imgIRequest> arg0_holder;
1633 0 : if (args[0].isObject()) {
1634 0 : JS::Rooted<JSObject*> source(cx, &args[0].toObject());
1635 0 : if (NS_FAILED(UnwrapArg<imgIRequest>(cx, source, getter_AddRefs(arg0_holder)))) {
1636 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of HTMLImageElement.getRequestType", "imgIRequest");
1637 0 : return false;
1638 : }
1639 0 : MOZ_ASSERT(arg0_holder);
1640 0 : arg0 = arg0_holder;
1641 : } else {
1642 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of HTMLImageElement.getRequestType");
1643 0 : return false;
1644 : }
1645 0 : binding_detail::FastErrorResult rv;
1646 0 : int32_t result(self->GetRequestType(NonNullHelper(arg0), rv));
1647 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1648 0 : return false;
1649 : }
1650 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1651 0 : args.rval().setInt32(int32_t(result));
1652 0 : return true;
1653 : }
1654 :
1655 : static const JSJitInfo getRequestType_methodinfo = {
1656 : { (JSJitGetterOp)getRequestType },
1657 : { prototypes::id::HTMLImageElement },
1658 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1659 : JSJitInfo::Method,
1660 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1661 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
1662 : false, /* isInfallible. False in setters. */
1663 : false, /* isMovable. Not relevant for setters. */
1664 : false, /* isEliminatable. Not relevant for setters. */
1665 : false, /* isAlwaysInSlot. Only relevant for getters. */
1666 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1667 : false, /* isTypedMethod. Only relevant for methods. */
1668 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1669 : };
1670 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1671 : static_assert(0 < 1, "There is no slot for us");
1672 :
1673 : static bool
1674 0 : get_currentURI(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, JSJitGetterCallArgs args)
1675 : {
1676 0 : binding_detail::FastErrorResult rv;
1677 0 : auto result(StrongOrRawPtr<nsIURI>(self->GetCurrentURI(rv)));
1678 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1679 0 : return false;
1680 : }
1681 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1682 0 : if (!result) {
1683 0 : args.rval().setNull();
1684 0 : return true;
1685 : }
1686 0 : if (!WrapObject(cx, result, &NS_GET_IID(nsIURI), args.rval())) {
1687 0 : return false;
1688 : }
1689 0 : return true;
1690 : }
1691 :
1692 : static const JSJitInfo currentURI_getterinfo = {
1693 : { (JSJitGetterOp)get_currentURI },
1694 : { prototypes::id::HTMLImageElement },
1695 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1696 : JSJitInfo::Getter,
1697 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1698 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
1699 : false, /* isInfallible. False in setters. */
1700 : false, /* isMovable. Not relevant for setters. */
1701 : false, /* isEliminatable. Not relevant for setters. */
1702 : false, /* isAlwaysInSlot. Only relevant for getters. */
1703 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1704 : false, /* isTypedMethod. Only relevant for methods. */
1705 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1706 : };
1707 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1708 : static_assert(0 < 1, "There is no slot for us");
1709 :
1710 : static bool
1711 0 : forceReload(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, const JSJitMethodCallArgs& args)
1712 : {
1713 0 : Optional<bool> arg0;
1714 0 : if (args.hasDefined(0)) {
1715 0 : arg0.Construct();
1716 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0.Value())) {
1717 0 : return false;
1718 : }
1719 : }
1720 0 : binding_detail::FastErrorResult rv;
1721 0 : self->ForceReload(Constify(arg0), rv);
1722 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1723 0 : return false;
1724 : }
1725 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1726 0 : args.rval().setUndefined();
1727 0 : return true;
1728 : }
1729 :
1730 : static const JSJitInfo forceReload_methodinfo = {
1731 : { (JSJitGetterOp)forceReload },
1732 : { prototypes::id::HTMLImageElement },
1733 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1734 : JSJitInfo::Method,
1735 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1736 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1737 : false, /* isInfallible. False in setters. */
1738 : false, /* isMovable. Not relevant for setters. */
1739 : false, /* isEliminatable. Not relevant for setters. */
1740 : false, /* isAlwaysInSlot. Only relevant for getters. */
1741 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1742 : false, /* isTypedMethod. Only relevant for methods. */
1743 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1744 : };
1745 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1746 : static_assert(0 < 1, "There is no slot for us");
1747 :
1748 : static bool
1749 0 : forceImageState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLImageElement* self, const JSJitMethodCallArgs& args)
1750 : {
1751 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
1752 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLImageElement.forceImageState");
1753 : }
1754 : bool arg0;
1755 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
1756 0 : return false;
1757 : }
1758 : uint64_t arg1;
1759 0 : if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[1], &arg1)) {
1760 0 : return false;
1761 : }
1762 0 : self->ForceImageState(arg0, arg1);
1763 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1764 0 : args.rval().setUndefined();
1765 0 : return true;
1766 : }
1767 :
1768 : static const JSJitInfo forceImageState_methodinfo = {
1769 : { (JSJitGetterOp)forceImageState },
1770 : { prototypes::id::HTMLImageElement },
1771 : { PrototypeTraits<prototypes::id::HTMLImageElement>::Depth },
1772 : JSJitInfo::Method,
1773 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1774 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1775 : false, /* isInfallible. False in setters. */
1776 : false, /* isMovable. Not relevant for setters. */
1777 : false, /* isEliminatable. Not relevant for setters. */
1778 : false, /* isAlwaysInSlot. Only relevant for getters. */
1779 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1780 : false, /* isTypedMethod. Only relevant for methods. */
1781 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1782 : };
1783 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1784 : static_assert(0 < 1, "There is no slot for us");
1785 :
1786 : static bool
1787 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1788 : {
1789 0 : mozilla::dom::HTMLImageElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLImageElement>(obj);
1790 : // We don't want to preserve if we don't have a wrapper, and we
1791 : // obviously can't preserve if we're not initialized.
1792 0 : if (self && self->GetWrapperPreserveColor()) {
1793 0 : PreserveWrapper(self);
1794 : }
1795 0 : return true;
1796 : }
1797 :
1798 : static void
1799 0 : _finalize(js::FreeOp* fop, JSObject* obj)
1800 : {
1801 0 : mozilla::dom::HTMLImageElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLImageElement>(obj);
1802 0 : if (self) {
1803 0 : ClearWrapper(self, self, obj);
1804 0 : AddForDeferredFinalization<mozilla::dom::HTMLImageElement>(self);
1805 : }
1806 0 : }
1807 :
1808 : static void
1809 0 : _objectMoved(JSObject* obj, const JSObject* old)
1810 : {
1811 0 : mozilla::dom::HTMLImageElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLImageElement>(obj);
1812 0 : if (self) {
1813 0 : UpdateWrapper(self, self, obj, old);
1814 : }
1815 0 : }
1816 :
1817 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1818 : #if defined(__clang__)
1819 : #pragma clang diagnostic push
1820 : #pragma clang diagnostic ignored "-Wmissing-braces"
1821 : #endif
1822 : static const JSFunctionSpec sChromeMethods_specs[] = {
1823 : JS_FNSPEC("addObserver", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&addObserver_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1824 : JS_FNSPEC("removeObserver", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&removeObserver_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1825 : JS_FNSPEC("getRequest", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getRequest_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1826 : JS_FNSPEC("getRequestType", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getRequestType_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1827 : JS_FNSPEC("forceReload", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&forceReload_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1828 : JS_FNSPEC("forceImageState", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&forceImageState_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1829 : JS_FS_END
1830 : };
1831 : #if defined(__clang__)
1832 : #pragma clang diagnostic pop
1833 : #endif
1834 :
1835 :
1836 : // Can't be const because the pref-enabled boolean needs to be writable
1837 : static Prefable<const JSFunctionSpec> sChromeMethods[] = {
1838 : { nullptr, &sChromeMethods_specs[0] },
1839 : { nullptr, nullptr }
1840 : };
1841 :
1842 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1843 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1844 : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1845 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1846 :
1847 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1848 : #if defined(__clang__)
1849 : #pragma clang diagnostic push
1850 : #pragma clang diagnostic ignored "-Wmissing-braces"
1851 : #endif
1852 : static const JSPropertySpec sAttributes_specs[] = {
1853 : { "alt", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &alt_getterinfo, GenericBindingSetter, &alt_setterinfo },
1854 : { "src", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &src_getterinfo, GenericBindingSetter, &src_setterinfo },
1855 : { "srcset", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &srcset_getterinfo, GenericBindingSetter, &srcset_setterinfo },
1856 : { "crossOrigin", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &crossOrigin_getterinfo, GenericBindingSetter, &crossOrigin_setterinfo },
1857 : { "useMap", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &useMap_getterinfo, GenericBindingSetter, &useMap_setterinfo },
1858 : { "referrerPolicy", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &referrerPolicy_getterinfo, GenericBindingSetter, &referrerPolicy_setterinfo },
1859 : { "isMap", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &isMap_getterinfo, GenericBindingSetter, &isMap_setterinfo },
1860 : { "width", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &width_getterinfo, GenericBindingSetter, &width_setterinfo },
1861 : { "height", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &height_getterinfo, GenericBindingSetter, &height_setterinfo },
1862 : { "naturalWidth", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &naturalWidth_getterinfo, nullptr, nullptr },
1863 : { "naturalHeight", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &naturalHeight_getterinfo, nullptr, nullptr },
1864 : { "complete", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &complete_getterinfo, nullptr, nullptr },
1865 : { "name", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &name_getterinfo, GenericBindingSetter, &name_setterinfo },
1866 : { "align", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &align_getterinfo, GenericBindingSetter, &align_setterinfo },
1867 : { "hspace", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &hspace_getterinfo, GenericBindingSetter, &hspace_setterinfo },
1868 : { "vspace", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &vspace_getterinfo, GenericBindingSetter, &vspace_setterinfo },
1869 : { "longDesc", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &longDesc_getterinfo, GenericBindingSetter, &longDesc_setterinfo },
1870 : { "border", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &border_getterinfo, GenericBindingSetter, &border_setterinfo },
1871 : { "sizes", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &sizes_getterinfo, GenericBindingSetter, &sizes_setterinfo },
1872 : { "currentSrc", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, ¤tSrc_getterinfo, nullptr, nullptr },
1873 : { "lowsrc", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &lowsrc_getterinfo, GenericBindingSetter, &lowsrc_setterinfo },
1874 : { "x", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &x_getterinfo, nullptr, nullptr },
1875 : { "y", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &y_getterinfo, nullptr, nullptr },
1876 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1877 : };
1878 : #if defined(__clang__)
1879 : #pragma clang diagnostic pop
1880 : #endif
1881 :
1882 :
1883 : // Can't be const because the pref-enabled boolean needs to be writable
1884 : static Prefable<const JSPropertySpec> sAttributes[] = {
1885 : { nullptr, &sAttributes_specs[0] },
1886 : { nullptr, nullptr }
1887 : };
1888 :
1889 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1890 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1891 : static_assert(23 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1892 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1893 :
1894 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1895 : #if defined(__clang__)
1896 : #pragma clang diagnostic push
1897 : #pragma clang diagnostic ignored "-Wmissing-braces"
1898 : #endif
1899 : static const JSPropertySpec sChromeAttributes_specs[] = {
1900 : { "loadingEnabled", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &loadingEnabled_getterinfo, GenericBindingSetter, &loadingEnabled_setterinfo },
1901 : { "imageBlockingStatus", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &imageBlockingStatus_getterinfo, nullptr, nullptr },
1902 : { "currentURI", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, ¤tURI_getterinfo, nullptr, nullptr },
1903 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1904 : };
1905 : #if defined(__clang__)
1906 : #pragma clang diagnostic pop
1907 : #endif
1908 :
1909 :
1910 : // Can't be const because the pref-enabled boolean needs to be writable
1911 : static Prefable<const JSPropertySpec> sChromeAttributes[] = {
1912 : { nullptr, &sChromeAttributes_specs[0] },
1913 : { nullptr, nullptr }
1914 : };
1915 :
1916 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1917 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1918 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1919 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1920 :
1921 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1922 : #if defined(__clang__)
1923 : #pragma clang diagnostic push
1924 : #pragma clang diagnostic ignored "-Wmissing-braces"
1925 : #endif
1926 : static const ConstantSpec sChromeConstants_specs[] = {
1927 : { "UNKNOWN_REQUEST", JS::Int32Value(-1) },
1928 : { "CURRENT_REQUEST", JS::Int32Value(0) },
1929 : { "PENDING_REQUEST", JS::Int32Value(1) },
1930 : { 0, JS::UndefinedValue() }
1931 : };
1932 : #if defined(__clang__)
1933 : #pragma clang diagnostic pop
1934 : #endif
1935 :
1936 :
1937 : // Can't be const because the pref-enabled boolean needs to be writable
1938 : static Prefable<const ConstantSpec> sChromeConstants[] = {
1939 : { nullptr, &sChromeConstants_specs[0] },
1940 : { nullptr, nullptr }
1941 : };
1942 :
1943 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1944 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1945 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1946 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1947 :
1948 :
1949 : static uint16_t sNativeProperties_sortedPropertyIndices[23];
1950 : static PropertyInfo sNativeProperties_propertyInfos[23];
1951 :
1952 : static const NativePropertiesN<1> sNativeProperties = {
1953 : false, 0,
1954 : false, 0,
1955 : false, 0,
1956 : true, 0 /* sAttributes */,
1957 : false, 0,
1958 : false, 0,
1959 : false, 0,
1960 : -1,
1961 : 23,
1962 : sNativeProperties_sortedPropertyIndices,
1963 : {
1964 : { sAttributes, &sNativeProperties_propertyInfos[0] }
1965 : }
1966 : };
1967 : static_assert(23 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1968 : "We have a property info count that is oversized");
1969 :
1970 : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[12];
1971 : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[12];
1972 :
1973 : static const NativePropertiesN<3> sChromeOnlyNativeProperties = {
1974 : false, 0,
1975 : false, 0,
1976 : true, 0 /* sChromeMethods */,
1977 : true, 1 /* sChromeAttributes */,
1978 : false, 0,
1979 : false, 0,
1980 : true, 2 /* sChromeConstants */,
1981 : -1,
1982 : 12,
1983 : sChromeOnlyNativeProperties_sortedPropertyIndices,
1984 : {
1985 : { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] },
1986 : { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[6] },
1987 : { sChromeConstants, &sChromeOnlyNativeProperties_propertyInfos[9] }
1988 : }
1989 : };
1990 : static_assert(12 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1991 : "We have a property info count that is oversized");
1992 :
1993 : static bool
1994 0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1995 : {
1996 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1997 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
1998 0 : if (!args.isConstructing()) {
1999 : // XXXbz wish I could get the name from the callee instead of
2000 : // Adding more relocations
2001 0 : return ThrowConstructorWithoutNew(cx, "HTMLImageElement");
2002 : }
2003 :
2004 0 : GlobalObject global(cx, obj);
2005 0 : if (global.Failed()) {
2006 0 : return false;
2007 : }
2008 :
2009 : // The newTarget might be a cross-compartment wrapper. Get the underlying object
2010 : // so we can do the spec's object-identity checks.
2011 0 : JS::Rooted<JSObject*> newTarget(cx, js::CheckedUnwrap(&args.newTarget().toObject()));
2012 0 : if (!newTarget) {
2013 0 : return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
2014 : }
2015 :
2016 : // Step 2 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
2017 : // Enter the compartment of our underlying newTarget object, so we end
2018 : // up comparing to the constructor object for our interface from that global.
2019 : {
2020 0 : JSAutoCompartment ac(cx, newTarget);
2021 0 : JS::Handle<JSObject*> constructor(GetConstructorObjectHandle(cx));
2022 0 : if (!constructor) {
2023 0 : return false;
2024 : }
2025 0 : if (newTarget == constructor) {
2026 0 : return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
2027 : }
2028 : }
2029 :
2030 0 : JS::Rooted<JSObject*> desiredProto(cx);
2031 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
2032 0 : return false;
2033 : }
2034 0 : if (!desiredProto) {
2035 : // Step 7 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
2036 : // This fallback behavior is designed to match analogous behavior for the
2037 : // JavaScript built-ins. So we enter the compartment of our underlying
2038 : // newTarget object and fall back to the prototype object from that global.
2039 : // XXX The spec says to use GetFunctionRealm(), which is not actually
2040 : // the same thing as what we have here (e.g. in the case of scripted callable proxies
2041 : // whose target is not same-compartment with the proxy, or bound functions, etc).
2042 : // https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
2043 : {
2044 0 : JSAutoCompartment ac(cx, newTarget);
2045 0 : desiredProto = GetProtoObjectHandle(cx);
2046 0 : if (!desiredProto) {
2047 0 : return false;
2048 : }
2049 : }
2050 :
2051 : // desiredProto is in the compartment of the underlying newTarget object.
2052 : // Wrap it into the context compartment.
2053 0 : if (!JS_WrapObject(cx, &desiredProto)) {
2054 0 : return false;
2055 : }
2056 : }
2057 :
2058 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
2059 0 : Maybe<JSAutoCompartment> ac;
2060 0 : if (objIsXray) {
2061 0 : obj = js::CheckedUnwrap(obj);
2062 0 : if (!obj) {
2063 0 : return false;
2064 : }
2065 0 : ac.emplace(cx, obj);
2066 0 : if (!JS_WrapObject(cx, &desiredProto)) {
2067 0 : return false;
2068 : }
2069 : }
2070 0 : binding_detail::FastErrorResult rv;
2071 0 : auto result(StrongOrRawPtr<mozilla::dom::HTMLImageElement>(CreateHTMLElement(global, args, rv)));
2072 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2073 0 : return false;
2074 : }
2075 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
2076 : static_assert(!IsPointer<decltype(result)>::value,
2077 : "NewObject implies that we need to keep the object alive with a strong reference.");
2078 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
2079 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
2080 0 : return false;
2081 : }
2082 0 : return true;
2083 : }
2084 :
2085 : static const js::ClassOps sInterfaceObjectClassOps = {
2086 : nullptr, /* addProperty */
2087 : nullptr, /* delProperty */
2088 : nullptr, /* getProperty */
2089 : nullptr, /* setProperty */
2090 : nullptr, /* enumerate */
2091 : nullptr, /* newEnumerate */
2092 : nullptr, /* resolve */
2093 : nullptr, /* mayResolve */
2094 : nullptr, /* finalize */
2095 : _constructor, /* call */
2096 : nullptr, /* hasInstance */
2097 : _constructor, /* construct */
2098 : nullptr, /* trace */
2099 : };
2100 :
2101 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
2102 : {
2103 : "Function",
2104 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE + 1 /* slots for the named constructors */),
2105 : &sInterfaceObjectClassOps,
2106 : JS_NULL_CLASS_SPEC,
2107 : JS_NULL_CLASS_EXT,
2108 : &sInterfaceObjectClassObjectOps
2109 : },
2110 : eInterface,
2111 : true,
2112 : prototypes::id::HTMLImageElement,
2113 : PrototypeTraits<prototypes::id::HTMLImageElement>::Depth,
2114 : sNativePropertyHooks,
2115 : "function HTMLImageElement() {\n [native code]\n}",
2116 : HTMLElementBinding::GetConstructorObject
2117 : };
2118 :
2119 : const NativePropertyHooks sNamedConstructorNativePropertyHooks = {
2120 : nullptr,
2121 : nullptr,
2122 : nullptr,
2123 : { nullptr, nullptr },
2124 : prototypes::id::HTMLImageElement,
2125 : constructors::id::HTMLImageElement,
2126 : nullptr
2127 : };
2128 :
2129 : static const NamedConstructor namedConstructors[] = {
2130 : { "Image", { _Image, &sNamedConstructorNativePropertyHooks }, 0 },
2131 : { nullptr, { nullptr, nullptr }, 0 }
2132 : };
2133 :
2134 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
2135 : {
2136 : "HTMLImageElementPrototype",
2137 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
2138 : JS_NULL_CLASS_OPS,
2139 : JS_NULL_CLASS_SPEC,
2140 : JS_NULL_CLASS_EXT,
2141 : JS_NULL_OBJECT_OPS
2142 : },
2143 : eInterfacePrototype,
2144 : false,
2145 : prototypes::id::HTMLImageElement,
2146 : PrototypeTraits<prototypes::id::HTMLImageElement>::Depth,
2147 : sNativePropertyHooks,
2148 : "[object HTMLImageElementPrototype]",
2149 : HTMLElementBinding::GetProtoObject
2150 : };
2151 :
2152 : JSObject*
2153 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
2154 : {
2155 0 : JSObject* interfaceObject = GetConstructorObjectHandle(aCx, aDefineOnGlobal);
2156 0 : if (!interfaceObject) {
2157 0 : return nullptr;
2158 : }
2159 0 : for (unsigned slot = DOM_INTERFACE_SLOTS_BASE; slot < JSCLASS_RESERVED_SLOTS(&sInterfaceObjectClass.mBase); ++slot) {
2160 0 : JSObject* constructor = &js::GetReservedSlot(interfaceObject, slot).toObject();
2161 0 : if (JS_GetFunctionId(JS_GetObjectFunction(constructor)) == JSID_TO_STRING(id)) {
2162 0 : return constructor;
2163 : }
2164 : }
2165 0 : return interfaceObject;
2166 : }
2167 :
2168 : static const js::ClassOps sClassOps = {
2169 : _addProperty, /* addProperty */
2170 : nullptr, /* delProperty */
2171 : nullptr, /* getProperty */
2172 : nullptr, /* setProperty */
2173 : nullptr, /* enumerate */
2174 : nullptr, /* newEnumerate */
2175 : nullptr, /* resolve */
2176 : nullptr, /* mayResolve */
2177 : _finalize, /* finalize */
2178 : nullptr, /* call */
2179 : nullptr, /* hasInstance */
2180 : nullptr, /* construct */
2181 : nullptr, /* trace */
2182 : };
2183 :
2184 : static const js::ClassExtension sClassExtension = {
2185 : nullptr, /* weakmapKeyDelegateOp */
2186 : _objectMoved /* objectMovedOp */
2187 : };
2188 :
2189 : static const DOMJSClass sClass = {
2190 : { "HTMLImageElement",
2191 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
2192 : &sClassOps,
2193 : JS_NULL_CLASS_SPEC,
2194 : &sClassExtension,
2195 : JS_NULL_OBJECT_OPS
2196 : },
2197 : { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLImageElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
2198 : IsBaseOf<nsISupports, mozilla::dom::HTMLImageElement >::value,
2199 : sNativePropertyHooks,
2200 : FindAssociatedGlobalForNative<mozilla::dom::HTMLImageElement>::Get,
2201 : GetProtoObjectHandle,
2202 : GetCCParticipant<mozilla::dom::HTMLImageElement>::Get()
2203 : };
2204 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
2205 : "Must have the right minimal number of reserved slots.");
2206 : static_assert(1 >= 1,
2207 : "Must have enough reserved slots.");
2208 :
2209 : const JSClass*
2210 0 : GetJSClass()
2211 : {
2212 0 : return sClass.ToJSClass();
2213 : }
2214 :
2215 : bool
2216 0 : Wrap(JSContext* aCx, mozilla::dom::HTMLImageElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
2217 : {
2218 : MOZ_ASSERT(static_cast<mozilla::dom::HTMLImageElement*>(aObject) ==
2219 : reinterpret_cast<mozilla::dom::HTMLImageElement*>(aObject),
2220 : "Multiple inheritance for mozilla::dom::HTMLImageElement is broken.");
2221 : MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
2222 : reinterpret_cast<nsGenericHTMLElement*>(aObject),
2223 : "Multiple inheritance for nsGenericHTMLElement is broken.");
2224 : MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
2225 : reinterpret_cast<mozilla::dom::Element*>(aObject),
2226 : "Multiple inheritance for mozilla::dom::Element is broken.");
2227 : MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
2228 : reinterpret_cast<nsINode*>(aObject),
2229 : "Multiple inheritance for nsINode is broken.");
2230 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
2231 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
2232 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
2233 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
2234 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
2235 0 : MOZ_ASSERT(!aCache->GetWrapper(),
2236 : "You should probably not be using Wrap() directly; use "
2237 : "GetOrCreateDOMReflector instead");
2238 :
2239 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
2240 : "nsISupports must be on our primary inheritance chain");
2241 :
2242 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
2243 0 : if (!global) {
2244 0 : return false;
2245 : }
2246 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
2247 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
2248 :
2249 : // That might have ended up wrapping us already, due to the wonders
2250 : // of XBL. Check for that, and bail out as needed.
2251 0 : aReflector.set(aCache->GetWrapper());
2252 0 : if (aReflector) {
2253 : #ifdef DEBUG
2254 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
2255 : #endif // DEBUG
2256 0 : return true;
2257 : }
2258 :
2259 0 : JSAutoCompartment ac(aCx, global);
2260 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
2261 0 : if (!canonicalProto) {
2262 0 : return false;
2263 : }
2264 0 : JS::Rooted<JSObject*> proto(aCx);
2265 0 : if (aGivenProto) {
2266 0 : proto = aGivenProto;
2267 : // Unfortunately, while aGivenProto was in the compartment of aCx
2268 : // coming in, we changed compartments to that of "parent" so may need
2269 : // to wrap the proto here.
2270 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
2271 0 : if (!JS_WrapObject(aCx, &proto)) {
2272 0 : return false;
2273 : }
2274 : }
2275 : } else {
2276 0 : proto = canonicalProto;
2277 : }
2278 :
2279 0 : BindingJSObjectCreator<mozilla::dom::HTMLImageElement> creator(aCx);
2280 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
2281 0 : if (!aReflector) {
2282 0 : return false;
2283 : }
2284 :
2285 0 : aCache->SetWrapper(aReflector);
2286 0 : creator.InitializationSucceeded();
2287 :
2288 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
2289 : aCache->GetWrapperPreserveColor() == aReflector);
2290 : // If proto != canonicalProto, we have to preserve our wrapper;
2291 : // otherwise we won't be able to properly recreate it later, since
2292 : // we won't know what proto to use. Note that we don't check
2293 : // aGivenProto here, since it's entirely possible (and even
2294 : // somewhat common) to have a non-null aGivenProto which is the
2295 : // same as canonicalProto.
2296 0 : if (proto != canonicalProto) {
2297 0 : PreserveWrapper(aObject);
2298 : }
2299 :
2300 0 : return true;
2301 : }
2302 :
2303 : const NativePropertyHooks sNativePropertyHooks[] = { {
2304 : nullptr,
2305 : nullptr,
2306 : nullptr,
2307 : { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
2308 : prototypes::id::HTMLImageElement,
2309 : constructors::id::HTMLImageElement,
2310 : HTMLElementBinding::sNativePropertyHooks,
2311 : &DefaultXrayExpandoObjectClass
2312 : } };
2313 :
2314 : void
2315 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
2316 : {
2317 0 : JS::Handle<JSObject*> parentProto(HTMLElementBinding::GetProtoObjectHandle(aCx));
2318 0 : if (!parentProto) {
2319 0 : return;
2320 : }
2321 :
2322 0 : JS::Handle<JSObject*> constructorProto(HTMLElementBinding::GetConstructorObjectHandle(aCx));
2323 0 : if (!constructorProto) {
2324 0 : return;
2325 : }
2326 :
2327 : static bool sIdsInited = false;
2328 0 : if (!sIdsInited && NS_IsMainThread()) {
2329 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
2330 0 : return;
2331 : }
2332 0 : if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
2333 0 : return;
2334 : }
2335 0 : sIdsInited = true;
2336 : }
2337 :
2338 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLImageElement);
2339 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLImageElement);
2340 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
2341 : &sPrototypeClass.mBase, protoCache,
2342 : constructorProto, &sInterfaceObjectClass.mBase, 0, namedConstructors,
2343 : interfaceCache,
2344 : sNativeProperties.Upcast(),
2345 0 : nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
2346 : "HTMLImageElement", aDefineOnGlobal,
2347 : nullptr,
2348 0 : false);
2349 : }
2350 :
2351 : JS::Handle<JSObject*>
2352 0 : GetProtoObjectHandle(JSContext* aCx)
2353 : {
2354 : /* Get the interface prototype object for this class. This will create the
2355 : object as needed. */
2356 0 : bool aDefineOnGlobal = true;
2357 :
2358 : /* Make sure our global is sane. Hopefully we can remove this sometime */
2359 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
2360 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
2361 0 : return nullptr;
2362 : }
2363 :
2364 : /* Check to see whether the interface objects are already installed */
2365 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
2366 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::HTMLImageElement)) {
2367 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
2368 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
2369 : }
2370 :
2371 : /*
2372 : * The object might _still_ be null, but that's OK.
2373 : *
2374 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
2375 : * traced by TraceProtoAndIfaceCache() and its contents are never
2376 : * changed after they have been set.
2377 : *
2378 : * Calling address() avoids the read read barrier that does gray
2379 : * unmarking, but it's not possible for the object to be gray here.
2380 : */
2381 :
2382 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::HTMLImageElement);
2383 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
2384 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
2385 : }
2386 :
2387 : JS::Handle<JSObject*>
2388 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
2389 : {
2390 : /* Get the interface object for this class. This will create the object as
2391 : needed. */
2392 :
2393 : /* Make sure our global is sane. Hopefully we can remove this sometime */
2394 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
2395 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
2396 0 : return nullptr;
2397 : }
2398 :
2399 : /* Check to see whether the interface objects are already installed */
2400 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
2401 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::HTMLImageElement)) {
2402 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
2403 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
2404 : }
2405 :
2406 : /*
2407 : * The object might _still_ be null, but that's OK.
2408 : *
2409 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
2410 : * traced by TraceProtoAndIfaceCache() and its contents are never
2411 : * changed after they have been set.
2412 : *
2413 : * Calling address() avoids the read read barrier that does gray
2414 : * unmarking, but it's not possible for the object to be gray here.
2415 : */
2416 :
2417 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::HTMLImageElement);
2418 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
2419 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
2420 : }
2421 :
2422 : JSObject*
2423 0 : GetConstructorObject(JSContext* aCx)
2424 : {
2425 0 : return GetConstructorObjectHandle(aCx);
2426 : }
2427 :
2428 : } // namespace HTMLImageElementBinding
2429 :
2430 :
2431 :
2432 : } // namespace dom
2433 : } // namespace mozilla
|