script_bindings/home/runner/work/servo/servo/target/debug/build/script_bindings-d55f55d5af1efaee/out/Bindings/
ResizeObserverBinding.rs

1/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */
2
3#![allow(non_camel_case_types,non_upper_case_globals,unsafe_op_in_unsafe_fn,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::enum_variant_names,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]
4
5use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
6use crate::codegen::GenericBindings::NodeBinding::Node_Binding;
7use crate::import::base::*;
8
9
10#[repr(usize)]
11#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
12pub enum ResizeObserverBoxOptions {
13    Border_box,
14    Content_box,
15    Device_pixel_content_box
16}
17pub mod ResizeObserverBoxOptionsValues {
18
19    use crate::utils::find_enum_value;
20    use js::conversions::ConversionResult;
21    use js::conversions::FromJSValConvertible;
22    use js::conversions::ToJSValConvertible;
23    use js::context::RawJSContext;
24    use js::rust::HandleValue;
25    use js::rust::MutableHandleValue;
26    use js::jsval::JSVal;
27
28    pub(crate) const pairs: &[(&str, super::ResizeObserverBoxOptions)] = &[
29        ("border-box", super::ResizeObserverBoxOptions::Border_box),
30        ("content-box", super::ResizeObserverBoxOptions::Content_box),
31        ("device-pixel-content-box", super::ResizeObserverBoxOptions::Device_pixel_content_box),
32    ];
33
34    impl super::ResizeObserverBoxOptions {
35        pub fn as_str(&self) -> &'static str {
36            pairs[*self as usize].0
37        }
38    }
39
40    impl Default for super::ResizeObserverBoxOptions {
41        fn default() -> super::ResizeObserverBoxOptions {
42            pairs[0].1
43        }
44    }
45
46    impl std::str::FromStr for super::ResizeObserverBoxOptions {
47        type Err = ();
48
49        fn from_str(s: &str) -> Result<Self, Self::Err> {
50            pairs
51                .iter()
52                .find(|&&(key, _)| s == key)
53                .map(|&(_, ev)| ev)
54                .ok_or(())
55        }
56    }
57
58    impl ToJSValConvertible for super::ResizeObserverBoxOptions {
59        unsafe fn to_jsval(&self, cx: *mut RawJSContext, rval: MutableHandleValue) {
60            pairs[*self as usize].0.to_jsval(cx, rval);
61        }
62    }
63
64    impl FromJSValConvertible for super::ResizeObserverBoxOptions {
65        type Config = ();
66        unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
67                             -> Result<ConversionResult<super::ResizeObserverBoxOptions>, ()> {
68            match find_enum_value(cx, value, pairs) {
69                Err(_) => Err(()),
70                Ok((None, search)) => {
71                    Ok(ConversionResult::Failure(
72                        format!("'{}' is not a valid enum value for enumeration 'ResizeObserverBoxOptions'.", search).into()
73                    ))
74                }
75                Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
76            }
77        }
78    }
79        } // mod ResizeObserverBoxOptionsValues
80
81#[derive(JSTraceable)]
82pub struct ResizeObserverOptions {
83    pub box_: ResizeObserverBoxOptions,
84}
85impl Default for ResizeObserverOptions {
86    fn default() -> Self {
87        Self::empty()
88    }
89}
90
91impl ResizeObserverOptions {
92    pub fn empty() -> Self {
93        Self {
94                box_: ResizeObserverBoxOptions::Content_box,
95        }
96    }
97    pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
98                      -> Result<ConversionResult<ResizeObserverOptions>, ()> {
99        unsafe {
100            let object = if val.get().is_null_or_undefined() {
101                ptr::null_mut()
102            } else if val.get().is_object() {
103                val.get().to_object()
104            } else {
105                return Ok(ConversionResult::Failure("Value is not an object.".into()));
106            };
107            rooted!(&in(cx) let object = object);
108        let dictionary = ResizeObserverOptions {
109                box_: {
110                    rooted!(&in(cx) let mut rval = UndefinedValue());
111                    if get_dictionary_property(cx.raw_cx(), object.handle(), "box", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
112                            match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
113                                Ok(ConversionResult::Success(value)) => value,
114                                Ok(ConversionResult::Failure(error)) => {
115                                    throw_type_error(cx.raw_cx(), &error); return Err(());
116
117                                }
118                                _ => {
119                                    return Err(());
120
121                                },
122                            }
123
124                    } else {
125                            ResizeObserverBoxOptions::Content_box
126                    }
127                },
128        };
129            Ok(ConversionResult::Success(dictionary))
130        }
131    }
132}
133
134impl FromJSValConvertible for ResizeObserverOptions {
135    type Config = ();
136    unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
137                         -> Result<ConversionResult<ResizeObserverOptions>, ()> {
138        ResizeObserverOptions::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
139    }
140}
141
142impl ResizeObserverOptions {
143    #[allow(clippy::wrong_self_convention)]
144    pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
145        let box_ = &self.box_;
146        rooted!(in(cx) let mut box__js = UndefinedValue());
147        box_.to_jsval(cx, box__js.handle_mut());
148        set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "box", box__js.handle()).unwrap();
149    }
150}
151
152impl ToJSValConvertible for ResizeObserverOptions {
153    unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
154        rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
155        self.to_jsobject(cx, obj.handle_mut());
156        rval.set(ObjectOrNullValue(obj.get()))
157    }
158}
159
160
161#[derive(JSTraceable, MallocSizeOf, PartialEq)]
162#[cfg_attr(crown, allow(crown::unrooted_must_root))]
163#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)]
164pub struct ResizeObserverCallback<D: DomTypes> {
165    pub parent: CallbackFunction<D>,
166}
167
168impl<D: DomTypes> ResizeObserverCallback<D> {
169
170    pub unsafe fn new(aCx: SafeJSContext, aCallback: *mut JSObject) -> Rc<ResizeObserverCallback<D>> {
171        let mut ret = Rc::new(ResizeObserverCallback {
172            parent: CallbackFunction::new()
173        });
174        // Note: callback cannot be moved after calling init.
175        match Rc::get_mut(&mut ret) {
176            Some(ref mut callback) => callback.parent.init(aCx, aCallback),
177            None => unreachable!(),
178        };
179        ret
180    }
181
182    pub fn Call_<T: ThisReflector>(&self, thisObj: &T, entries: Vec<DomRoot<D::ResizeObserverEntry>>, observer: &D::ResizeObserver, aExceptionHandling: ExceptionHandling, can_gc: CanGc) -> Fallible<()> {
183        let s = CallSetup::<D>::new(self, aExceptionHandling);
184        rooted!(in(*s.get_context()) let mut thisValue: JSVal);
185        let wrap_result = wrap_call_this_value(s.get_context(), thisObj, thisValue.handle_mut());
186        if !wrap_result {
187            return Err(JSFailed);
188        }
189        unsafe { self.Call(s.get_context(), thisValue.handle(), entries, observer, can_gc) }
190    }
191
192    pub fn Call__<>(&self, entries: Vec<DomRoot<D::ResizeObserverEntry>>, observer: &D::ResizeObserver, aExceptionHandling: ExceptionHandling, can_gc: CanGc) -> Fallible<()> {
193        let s = CallSetup::<D>::new(self, aExceptionHandling);
194
195        unsafe { self.Call(s.get_context(), HandleValue::undefined(), entries, observer, can_gc) }
196    }
197
198    unsafe fn Call<>(&self, cx: SafeJSContext, aThisObj: HandleValue, entries: Vec<DomRoot<D::ResizeObserverEntry>>, observer: &D::ResizeObserver, can_gc: CanGc) -> Fallible<()> {
199        rooted!(&in(cx) let mut rval = UndefinedValue());
200        rooted_vec!(let mut argv);
201        argv.extend((0..2).map(|_| Heap::default()));
202
203        let mut argc = 2;
204
205        rooted!(&in(cx) let mut argv_root = UndefinedValue());
206        (observer).to_jsval(cx.raw_cx(), argv_root.handle_mut());
207        {
208        let arg = &mut argv[1];
209        *arg = Heap::default();
210        arg.set(argv_root.get());
211        }
212
213        rooted!(&in(cx) let mut argv_root = UndefinedValue());
214        (entries).to_jsval(cx.raw_cx(), argv_root.handle_mut());
215        {
216        let arg = &mut argv[0];
217        *arg = Heap::default();
218        arg.set(argv_root.get());
219        }
220
221        rooted!(&in(cx) let callable = ObjectValue(self.callback()));
222        rooted!(&in(cx) let rootedThis = aThisObj.get());
223        let ok = Call(
224            cx.raw_cx(), rootedThis.handle(), callable.handle(),
225            &HandleValueArray {
226                length_: argc as ::libc::size_t,
227                elements_: argv.as_ptr() as *const JSVal
228            }, rval.handle_mut());
229        maybe_resume_unwind();
230        if !ok {
231            return Err(JSFailed);
232        }
233
234        Ok(())
235
236    }
237}
238
239impl<D: DomTypes> CallbackContainer<D> for ResizeObserverCallback<D> {
240    unsafe fn new(cx: SafeJSContext, callback: *mut JSObject) -> Rc<ResizeObserverCallback<D>> {
241        ResizeObserverCallback::new(cx, callback)
242    }
243
244    fn callback_holder(&self) -> &CallbackObject<D> {
245        self.parent.callback_holder()
246    }
247}
248
249impl<D: DomTypes> ToJSValConvertible for ResizeObserverCallback<D> {
250    unsafe fn to_jsval(&self, cx: *mut RawJSContext, rval: MutableHandleValue) {
251        self.callback().to_jsval(cx, rval);
252    }
253}
254
255
256pub use self::ResizeObserver_Binding::{Wrap, ResizeObserverMethods, GetProtoObject, DefineDOMInterface};
257pub mod ResizeObserver_Binding {
258use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
259use crate::codegen::GenericBindings::NodeBinding::Node_Binding;
260use crate::codegen::GenericBindings::ResizeObserverBinding::ResizeObserverBoxOptions;
261use crate::codegen::GenericBindings::ResizeObserverBinding::ResizeObserverBoxOptionsValues;
262use crate::codegen::GenericBindings::ResizeObserverBinding::ResizeObserverCallback;
263use crate::codegen::GenericBindings::ResizeObserverBinding::ResizeObserverOptions;
264use crate::import::module::*;
265
266unsafe extern "C" fn observe<D: DomTypes>
267(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
268    let mut result = false;
269    wrap_panic(&mut || result = (|| {
270        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
271        let this = &*(this as *const D::ResizeObserver);
272        let args = &*args;
273        let argc = args.argc_;
274
275        if argc < 1 {
276            throw_type_error(cx.raw_cx(), "Not enough arguments to \"ResizeObserver.observe\".");
277            return false;
278        }
279        let arg0: DomRoot<D::Element> = if HandleValue::from_raw(args.get(0)).get().is_object() {
280            match root_from_handlevalue(HandleValue::from_raw(args.get(0)), SafeJSContext::from_ptr(cx.raw_cx())) {
281                Ok(val) => val,
282                Err(()) => {
283                    throw_type_error(cx.raw_cx(), "value does not implement interface Element.");
284                    return false;
285
286                }
287            }
288
289        } else {
290            throw_type_error(cx.raw_cx(), "Value is not an object.");
291            return false;
292
293        };
294        let arg1: crate::codegen::GenericBindings::ResizeObserverBinding::ResizeObserverOptions = if args.get(1).is_undefined() {
295            crate::codegen::GenericBindings::ResizeObserverBinding::ResizeObserverOptions::empty()
296        } else {
297            match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
298                Ok(ConversionResult::Success(value)) => value,
299                Ok(ConversionResult::Failure(error)) => {
300                    throw_type_error(cx.raw_cx(), &error);
301            return false;
302
303                }
304                _ => {
305                    return false;
306
307                },
308            }
309
310        };
311        let result: () = this.Observe(&arg0, &arg1);
312
313        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
314        return true;
315    })());
316    result
317}
318
319
320static observe_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
321
322pub(crate) fn init_observe_methodinfo<D: DomTypes>() {
323    observe_methodinfo.set(JSJitInfo {
324    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
325        method: Some(observe::<D>)
326    },
327    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
328        protoID: PrototypeList::ID::ResizeObserver as u16,
329    },
330    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
331    _bitfield_align_1: [],
332    _bitfield_1: __BindgenBitfieldUnit::new(
333        new_jsjitinfo_bitfield_1!(
334            JSJitInfo_OpType::Method as u8,
335            JSJitInfo_AliasSet::AliasEverything as u8,
336            JSValueType::JSVAL_TYPE_UNDEFINED as u8,
337            false,
338            false,
339            false,
340            false,
341            false,
342            false,
343            0,
344        ).to_ne_bytes()
345    ),
346});
347}
348unsafe extern "C" fn unobserve<D: DomTypes>
349(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
350    let mut result = false;
351    wrap_panic(&mut || result = (|| {
352        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
353        let this = &*(this as *const D::ResizeObserver);
354        let args = &*args;
355        let argc = args.argc_;
356
357        if argc < 1 {
358            throw_type_error(cx.raw_cx(), "Not enough arguments to \"ResizeObserver.unobserve\".");
359            return false;
360        }
361        let arg0: DomRoot<D::Element> = if HandleValue::from_raw(args.get(0)).get().is_object() {
362            match root_from_handlevalue(HandleValue::from_raw(args.get(0)), SafeJSContext::from_ptr(cx.raw_cx())) {
363                Ok(val) => val,
364                Err(()) => {
365                    throw_type_error(cx.raw_cx(), "value does not implement interface Element.");
366                    return false;
367
368                }
369            }
370
371        } else {
372            throw_type_error(cx.raw_cx(), "Value is not an object.");
373            return false;
374
375        };
376        let result: () = this.Unobserve(&arg0);
377
378        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
379        return true;
380    })());
381    result
382}
383
384
385static unobserve_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
386
387pub(crate) fn init_unobserve_methodinfo<D: DomTypes>() {
388    unobserve_methodinfo.set(JSJitInfo {
389    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
390        method: Some(unobserve::<D>)
391    },
392    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
393        protoID: PrototypeList::ID::ResizeObserver as u16,
394    },
395    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
396    _bitfield_align_1: [],
397    _bitfield_1: __BindgenBitfieldUnit::new(
398        new_jsjitinfo_bitfield_1!(
399            JSJitInfo_OpType::Method as u8,
400            JSJitInfo_AliasSet::AliasEverything as u8,
401            JSValueType::JSVAL_TYPE_UNDEFINED as u8,
402            false,
403            false,
404            false,
405            false,
406            false,
407            false,
408            0,
409        ).to_ne_bytes()
410    ),
411});
412}
413unsafe extern "C" fn disconnect<D: DomTypes>
414(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
415    let mut result = false;
416    wrap_panic(&mut || result = (|| {
417        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
418        let this = &*(this as *const D::ResizeObserver);
419        let args = &*args;
420        let argc = args.argc_;
421        let result: () = this.Disconnect();
422
423        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
424        return true;
425    })());
426    result
427}
428
429
430static disconnect_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
431
432pub(crate) fn init_disconnect_methodinfo<D: DomTypes>() {
433    disconnect_methodinfo.set(JSJitInfo {
434    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
435        method: Some(disconnect::<D>)
436    },
437    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
438        protoID: PrototypeList::ID::ResizeObserver as u16,
439    },
440    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
441    _bitfield_align_1: [],
442    _bitfield_1: __BindgenBitfieldUnit::new(
443        new_jsjitinfo_bitfield_1!(
444            JSJitInfo_OpType::Method as u8,
445            JSJitInfo_AliasSet::AliasEverything as u8,
446            JSValueType::JSVAL_TYPE_UNDEFINED as u8,
447            true,
448            false,
449            false,
450            false,
451            false,
452            false,
453            0,
454        ).to_ne_bytes()
455    ),
456});
457}
458unsafe extern "C" fn _finalize<D: DomTypes>
459(_cx: *mut GCContext, obj: *mut JSObject){
460    wrap_panic(&mut || {
461
462        let this = native_from_object_static::<D::ResizeObserver>(obj).unwrap();
463        finalize_common(this);
464    })
465}
466
467unsafe extern "C" fn _trace<D: DomTypes>
468(trc: *mut JSTracer, obj: *mut JSObject){
469    wrap_panic(&mut || {
470
471        let this = native_from_object_static::<D::ResizeObserver>(obj).unwrap();
472        if this.is_null() { return; } // GC during obj creation
473        (*this).trace(trc);
474    })
475}
476
477
478static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
479
480pub(crate) fn init_class_ops<D: DomTypes>() {
481    CLASS_OPS.set(JSClassOps {
482        addProperty: None,
483        delProperty: None,
484        enumerate: None,
485        newEnumerate: None,
486        resolve: None,
487        mayResolve: None,
488        finalize: Some(_finalize::<D>),
489        call: None,
490        construct: None,
491        trace: Some(_trace::<D>),
492    });
493}
494
495pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
496
497pub(crate) fn init_domjs_class<D: DomTypes>() {
498    init_class_ops::<D>();
499    Class.set(DOMJSClass {
500        base: JSClass {
501            name: c"ResizeObserver".as_ptr(),
502            flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
503                   (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
504                   /* JSCLASS_HAS_RESERVED_SLOTS(1) */,
505            cOps: unsafe { CLASS_OPS.get() },
506            spec: ptr::null(),
507            ext: ptr::null(),
508            oOps: ptr::null(),
509        },
510        dom_class:
511DOMClass {
512    interface_chain: [ PrototypeList::ID::ResizeObserver, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
513    depth: 0,
514    type_id: crate::codegen::InheritTypes::TopTypeId { alone: () },
515    malloc_size_of: malloc_size_of_including_raw_self::<D::ResizeObserver> as unsafe fn(&mut _, _) -> _,
516    global: Globals::EMPTY,
517},
518    });
519}
520
521#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
522(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::ResizeObserver>, _can_gc: CanGc) -> DomRoot<D::ResizeObserver>{
523
524    let raw = Root::new(MaybeUnreflectedDom::from_box(object));
525
526    let scope = scope.reflector().get_jsobject();
527    assert!(!scope.get().is_null());
528    assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
529    let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
530
531    rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
532    GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
533    assert!(!canonical_proto.is_null());
534
535
536    rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
537    if let Some(given) = given_proto {
538        proto.set(*given);
539        if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
540            assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
541        }
542    } else {
543        proto.set(*canonical_proto);
544    }
545    rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
546        cx.raw_cx(),
547        &Class.get().base,
548        proto.handle(),
549    ));
550    assert!(!obj.is_null());
551    JS_SetReservedSlot(
552        obj.get(),
553        DOM_OBJECT_SLOT,
554        &PrivateValue(raw.as_ptr() as *const libc::c_void),
555    );
556
557    let root = raw.reflect_with(obj.get());
558
559
560
561    DomRoot::from_ref(&*root)
562}
563
564pub trait ResizeObserverMethods<D: DomTypes> {
565    fn Observe(&self, r#target: &D::Element, r#options: &crate::codegen::GenericBindings::ResizeObserverBinding::ResizeObserverOptions);
566    fn Unobserve(&self, r#target: &D::Element);
567    fn Disconnect(&self, );
568    fn Constructor(r#global: &D::Window, r#proto: Option<HandleObject>, r#can_gc: CanGc, r#callback: Rc<ResizeObserverCallback<D>>) -> DomRoot<D::ResizeObserver>;
569}
570static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
571
572pub(crate) fn init_sMethods_specs<D: DomTypes>() {
573    sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
574    JSFunctionSpec {
575        name: JSPropertySpec_Name { string_: c"observe".as_ptr() },
576        call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { observe_methodinfo.get() } as *const _ as *const JSJitInfo },
577        nargs: 1,
578        flags: (JSPROP_ENUMERATE) as u16,
579        selfHostedName: ptr::null()
580    },
581    JSFunctionSpec {
582        name: JSPropertySpec_Name { string_: c"unobserve".as_ptr() },
583        call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { unobserve_methodinfo.get() } as *const _ as *const JSJitInfo },
584        nargs: 1,
585        flags: (JSPROP_ENUMERATE) as u16,
586        selfHostedName: ptr::null()
587    },
588    JSFunctionSpec {
589        name: JSPropertySpec_Name { string_: c"disconnect".as_ptr() },
590        call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { disconnect_methodinfo.get() } as *const _ as *const JSJitInfo },
591        nargs: 0,
592        flags: (JSPROP_ENUMERATE) as u16,
593        selfHostedName: ptr::null()
594    },
595    JSFunctionSpec {
596        name: JSPropertySpec_Name { string_: ptr::null() },
597        call: JSNativeWrapper { op: None, info: ptr::null() },
598        nargs: 0,
599        flags: 0,
600        selfHostedName: ptr::null()
601    }]))[..]
602])));
603}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
604
605pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
606    sMethods.set(Box::leak(Box::new([    Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sMethods_specs.get() })[0])])));
607}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
608
609pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
610    sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
611    JSPropertySpec {
612                    name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
613                    attributes_: (JSPROP_READONLY),
614                    kind_: (JSPropertySpec_Kind::Value),
615                    u: JSPropertySpec_AccessorsOrValue {
616                        value: JSPropertySpec_ValueWrapper {
617                            type_: JSPropertySpec_ValueWrapper_Type::String,
618                            __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
619                                string: c"ResizeObserver".as_ptr(),
620                            }
621                        }
622                    }
623                }
624,
625    JSPropertySpec::ZERO]))[..]
626])));
627}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
628
629pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
630    sAttributes.set(Box::leak(Box::new([    Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[0])])));
631}
632pub fn GetProtoObject<D: DomTypes>
633(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
634    /* Get the interface prototype object for this class.  This will create the
635       object as needed. */get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::ResizeObserver), CreateInterfaceObjects::<D>, rval)
636}
637
638
639static PrototypeClass: JSClass = JSClass {
640    name: c"ResizeObserverPrototype".as_ptr(),
641    flags:
642        // JSCLASS_HAS_RESERVED_SLOTS()
643        (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
644    cOps: ptr::null(),
645    spec: ptr::null(),
646    ext: ptr::null(),
647    oOps: ptr::null(),
648};
649
650unsafe extern "C" fn _constructor<D: DomTypes>
651(cx: *mut RawJSContext, argc: u32, vp: *mut JSVal) -> bool{
652    let mut result = false;
653    wrap_panic(&mut || result = {
654        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
655        let args = CallArgs::from_vp(vp, argc);
656        let global = D::GlobalScope::from_object(JS_CALLEE(cx.raw_cx(), vp).to_object());
657
658                    call_default_constructor::<D>(
659                        SafeJSContext::from_ptr(cx.raw_cx()),
660                        &args,
661                        &global,
662                        PrototypeList::ID::ResizeObserver,
663                        "ResizeObserver",
664                        CreateInterfaceObjects::<D>,
665                        |cx: SafeJSContext, args: &CallArgs, global: &D::GlobalScope, desired_proto: HandleObject| {
666
667        if argc < 1 {
668            throw_type_error(cx.raw_cx(), "Not enough arguments to \"ResizeObserver.constructor\".");
669            return false;
670        }
671        let arg0: Rc<ResizeObserverCallback<D>> = if HandleValue::from_raw(args.get(0)).get().is_object() {
672            if IsCallable(HandleValue::from_raw(args.get(0)).get().to_object()) {
673                ResizeObserverCallback::<D>::new(SafeJSContext::from_ptr(cx.raw_cx()), HandleValue::from_raw(args.get(0)).get().to_object())
674            } else {
675                throw_type_error(cx.raw_cx(), "Value is not callable.");
676                return false;
677
678            }
679        } else {
680            throw_type_error(cx.raw_cx(), "Value is not an object.");
681            return false;
682
683        };
684        let result: DomRoot<D::ResizeObserver> = <D::ResizeObserver>::Constructor(global.downcast::<D::Window>().unwrap(), Some(desired_proto), CanGc::note(), arg0);
685
686        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
687        return true;
688                        }
689                    )
690
691    });
692    result
693}
694
695
696static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
697
698pub(crate) fn init_interface_object<D: DomTypes>() {
699    INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
700        Box::leak(Box::new(InterfaceConstructorBehavior::call(_constructor::<D>))),
701        b"function ResizeObserver() {\n    [native code]\n}",
702        PrototypeList::ID::ResizeObserver,
703        0,
704    ));
705}
706
707pub fn DefineDOMInterface<D: DomTypes>
708(cx: SafeJSContext, global: HandleObject){
709    define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::ResizeObserver),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
710}
711
712pub fn ConstructorEnabled<D: DomTypes>
713(aCx: SafeJSContext, aObj: HandleObject) -> bool{
714    is_exposed_in(aObj, Globals::WINDOW) &&
715    pref!(dom_resize_observer_enabled)
716}
717
718unsafe fn CreateInterfaceObjects<D: DomTypes>
719(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
720
721    rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
722    prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
723    assert!(!prototype_proto.is_null());
724
725    rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
726    create_interface_prototype_object::<D>(cx,
727                                      global,
728                                      prototype_proto.handle(),
729                                      &PrototypeClass,
730                                      sMethods.get(),
731                                      sAttributes.get(),
732                                      &[],
733                                      &[],
734                                      prototype.handle_mut());
735    assert!(!prototype.is_null());
736    assert!((*cache)[PrototypeList::ID::ResizeObserver as usize].is_null());
737    (*cache)[PrototypeList::ID::ResizeObserver as usize] = prototype.get();
738    <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::ResizeObserver as isize),
739                                  ptr::null_mut(),
740                                  prototype.get());
741
742    rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
743    interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
744
745    assert!(!interface_proto.is_null());
746
747    rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
748    create_noncallback_interface_object::<D>(cx,
749                                        global,
750                                        interface_proto.handle(),
751                                        INTERFACE_OBJECT_CLASS.get(),
752                                        &[],
753                                        &[],
754                                        &[],
755                                        prototype.handle(),
756                                        c"ResizeObserver",
757                                        1,
758                                        &[],
759                                        interface.handle_mut());
760    assert!(!interface.is_null());
761}
762
763
764        pub(crate) fn init_statics<D: DomTypes>() {
765            init_interface_object::<D>();
766            init_domjs_class::<D>();
767            crate::codegen::GenericBindings::ResizeObserverBinding::ResizeObserver_Binding::init_observe_methodinfo::<D>();
768crate::codegen::GenericBindings::ResizeObserverBinding::ResizeObserver_Binding::init_unobserve_methodinfo::<D>();
769crate::codegen::GenericBindings::ResizeObserverBinding::ResizeObserver_Binding::init_disconnect_methodinfo::<D>();
770
771
772
773            init_sMethods_specs::<D>();
774init_sMethods_prefs::<D>();
775init_sAttributes_specs::<D>();
776init_sAttributes_prefs::<D>();
777        }
778        } // mod ResizeObserver_Binding
779
780