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