1#![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::DOMRectReadOnlyBinding::DOMRectInit;
6use crate::codegen::GenericBindings::DOMRectReadOnlyBinding::DOMRectReadOnly_Binding;
7use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
8use crate::codegen::GenericBindings::WorkerGlobalScopeBinding::WorkerGlobalScope_Binding;
9use crate::import::base::*;
10
11pub use self::DOMRect_Binding::{Wrap, DOMRectMethods, GetProtoObject, DefineDOMInterface};
12pub mod DOMRect_Binding {
13use crate::codegen::GenericBindings::DOMRectReadOnlyBinding::DOMRectInit;
14use crate::codegen::GenericBindings::DOMRectReadOnlyBinding::DOMRectReadOnly_Binding;
15use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
16use crate::codegen::GenericBindings::WorkerGlobalScopeBinding::WorkerGlobalScope_Binding;
17use crate::import::module::*;
18
19unsafe extern "C" fn fromRect<D: DomTypes>
20(cx: *mut RawJSContext, argc: libc::c_uint, vp: *mut JSVal) -> bool{
21 let mut result = false;
22 wrap_panic(&mut || result = (|| {
23 let args = CallArgs::from_vp(vp, argc);
24 let global = D::GlobalScope::from_object(args.callee());
25 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
26 let args = CallArgs::from_vp(vp, argc);
27 let arg0: crate::codegen::GenericBindings::DOMRectReadOnlyBinding::DOMRectInit = if args.get(0).is_undefined() {
28 crate::codegen::GenericBindings::DOMRectReadOnlyBinding::DOMRectInit::empty()
29 } else {
30 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
31 Ok(ConversionResult::Success(value)) => value,
32 Ok(ConversionResult::Failure(error)) => {
33 throw_type_error(cx.raw_cx(), &error);
34 return false;
35
36 }
37 _ => {
38 return false;
39
40 },
41 }
42
43 };
44 let result: DomRoot<D::DOMRect> = <D::DOMRect>::FromRect(&global, &arg0, CanGc::note());
45
46 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
47 return true;
48 })());
49 result
50}
51
52unsafe extern "C" fn get_x<D: DomTypes>
53(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
54 let mut result = false;
55 wrap_panic(&mut || result = (|| {
56 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
57 let this = &*(this as *const D::DOMRect);
58 let result: f64 = this.X();
59
60 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
61 return true;
62 })());
63 result
64}
65
66unsafe extern "C" fn set_x<D: DomTypes>
67(cx: *mut RawJSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool{
68 let mut result = false;
69 wrap_panic(&mut || result = (|| {
70 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
71 let this = &*(this as *const D::DOMRect);
72 let arg0: f64 = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
73 Ok(ConversionResult::Success(value)) => value,
74 Ok(ConversionResult::Failure(error)) => {
75 throw_type_error(cx.raw_cx(), &error);
76 return false;
77
78 }
79 _ => {
80 return false;
81
82 },
83 }
84 ;
85 let result: () = this.SetX(arg0);
86
87 true
88 })());
89 result
90}
91
92
93static x_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
94
95pub(crate) fn init_x_getterinfo<D: DomTypes>() {
96 x_getterinfo.set(JSJitInfo {
97 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
98 getter: Some(get_x::<D>)
99 },
100 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
101 protoID: PrototypeList::ID::DOMRect as u16,
102 },
103 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
104 _bitfield_align_1: [],
105 _bitfield_1: __BindgenBitfieldUnit::new(
106 new_jsjitinfo_bitfield_1!(
107 JSJitInfo_OpType::Getter as u8,
108 JSJitInfo_AliasSet::AliasEverything as u8,
109 JSValueType::JSVAL_TYPE_DOUBLE as u8,
110 true,
111 false,
112 false,
113 false,
114 false,
115 false,
116 0,
117 ).to_ne_bytes()
118 ),
119});
120}
121static x_setterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
122
123pub(crate) fn init_x_setterinfo<D: DomTypes>() {
124 x_setterinfo.set(JSJitInfo {
125 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
126 setter: Some(set_x::<D>)
127 },
128 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
129 protoID: PrototypeList::ID::DOMRect as u16,
130 },
131 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
132 _bitfield_align_1: [],
133 _bitfield_1: __BindgenBitfieldUnit::new(
134 new_jsjitinfo_bitfield_1!(
135 JSJitInfo_OpType::Setter as u8,
136 JSJitInfo_AliasSet::AliasEverything as u8,
137 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
138 false,
139 false,
140 false,
141 false,
142 false,
143 false,
144 0,
145 ).to_ne_bytes()
146 ),
147});
148}
149unsafe extern "C" fn get_y<D: DomTypes>
150(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
151 let mut result = false;
152 wrap_panic(&mut || result = (|| {
153 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
154 let this = &*(this as *const D::DOMRect);
155 let result: f64 = this.Y();
156
157 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
158 return true;
159 })());
160 result
161}
162
163unsafe extern "C" fn set_y<D: DomTypes>
164(cx: *mut RawJSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool{
165 let mut result = false;
166 wrap_panic(&mut || result = (|| {
167 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
168 let this = &*(this as *const D::DOMRect);
169 let arg0: f64 = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
170 Ok(ConversionResult::Success(value)) => value,
171 Ok(ConversionResult::Failure(error)) => {
172 throw_type_error(cx.raw_cx(), &error);
173 return false;
174
175 }
176 _ => {
177 return false;
178
179 },
180 }
181 ;
182 let result: () = this.SetY(arg0);
183
184 true
185 })());
186 result
187}
188
189
190static y_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
191
192pub(crate) fn init_y_getterinfo<D: DomTypes>() {
193 y_getterinfo.set(JSJitInfo {
194 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
195 getter: Some(get_y::<D>)
196 },
197 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
198 protoID: PrototypeList::ID::DOMRect as u16,
199 },
200 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
201 _bitfield_align_1: [],
202 _bitfield_1: __BindgenBitfieldUnit::new(
203 new_jsjitinfo_bitfield_1!(
204 JSJitInfo_OpType::Getter as u8,
205 JSJitInfo_AliasSet::AliasEverything as u8,
206 JSValueType::JSVAL_TYPE_DOUBLE as u8,
207 true,
208 false,
209 false,
210 false,
211 false,
212 false,
213 0,
214 ).to_ne_bytes()
215 ),
216});
217}
218static y_setterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
219
220pub(crate) fn init_y_setterinfo<D: DomTypes>() {
221 y_setterinfo.set(JSJitInfo {
222 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
223 setter: Some(set_y::<D>)
224 },
225 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
226 protoID: PrototypeList::ID::DOMRect as u16,
227 },
228 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
229 _bitfield_align_1: [],
230 _bitfield_1: __BindgenBitfieldUnit::new(
231 new_jsjitinfo_bitfield_1!(
232 JSJitInfo_OpType::Setter as u8,
233 JSJitInfo_AliasSet::AliasEverything as u8,
234 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
235 false,
236 false,
237 false,
238 false,
239 false,
240 false,
241 0,
242 ).to_ne_bytes()
243 ),
244});
245}
246unsafe extern "C" fn get_width<D: DomTypes>
247(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
248 let mut result = false;
249 wrap_panic(&mut || result = (|| {
250 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
251 let this = &*(this as *const D::DOMRect);
252 let result: f64 = this.Width();
253
254 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
255 return true;
256 })());
257 result
258}
259
260unsafe extern "C" fn set_width<D: DomTypes>
261(cx: *mut RawJSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool{
262 let mut result = false;
263 wrap_panic(&mut || result = (|| {
264 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
265 let this = &*(this as *const D::DOMRect);
266 let arg0: f64 = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
267 Ok(ConversionResult::Success(value)) => value,
268 Ok(ConversionResult::Failure(error)) => {
269 throw_type_error(cx.raw_cx(), &error);
270 return false;
271
272 }
273 _ => {
274 return false;
275
276 },
277 }
278 ;
279 let result: () = this.SetWidth(arg0);
280
281 true
282 })());
283 result
284}
285
286
287static width_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
288
289pub(crate) fn init_width_getterinfo<D: DomTypes>() {
290 width_getterinfo.set(JSJitInfo {
291 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
292 getter: Some(get_width::<D>)
293 },
294 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
295 protoID: PrototypeList::ID::DOMRect as u16,
296 },
297 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
298 _bitfield_align_1: [],
299 _bitfield_1: __BindgenBitfieldUnit::new(
300 new_jsjitinfo_bitfield_1!(
301 JSJitInfo_OpType::Getter as u8,
302 JSJitInfo_AliasSet::AliasEverything as u8,
303 JSValueType::JSVAL_TYPE_DOUBLE as u8,
304 true,
305 false,
306 false,
307 false,
308 false,
309 false,
310 0,
311 ).to_ne_bytes()
312 ),
313});
314}
315static width_setterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
316
317pub(crate) fn init_width_setterinfo<D: DomTypes>() {
318 width_setterinfo.set(JSJitInfo {
319 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
320 setter: Some(set_width::<D>)
321 },
322 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
323 protoID: PrototypeList::ID::DOMRect as u16,
324 },
325 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
326 _bitfield_align_1: [],
327 _bitfield_1: __BindgenBitfieldUnit::new(
328 new_jsjitinfo_bitfield_1!(
329 JSJitInfo_OpType::Setter as u8,
330 JSJitInfo_AliasSet::AliasEverything as u8,
331 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
332 false,
333 false,
334 false,
335 false,
336 false,
337 false,
338 0,
339 ).to_ne_bytes()
340 ),
341});
342}
343unsafe extern "C" fn get_height<D: DomTypes>
344(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
345 let mut result = false;
346 wrap_panic(&mut || result = (|| {
347 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
348 let this = &*(this as *const D::DOMRect);
349 let result: f64 = this.Height();
350
351 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
352 return true;
353 })());
354 result
355}
356
357unsafe extern "C" fn set_height<D: DomTypes>
358(cx: *mut RawJSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool{
359 let mut result = false;
360 wrap_panic(&mut || result = (|| {
361 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
362 let this = &*(this as *const D::DOMRect);
363 let arg0: f64 = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
364 Ok(ConversionResult::Success(value)) => value,
365 Ok(ConversionResult::Failure(error)) => {
366 throw_type_error(cx.raw_cx(), &error);
367 return false;
368
369 }
370 _ => {
371 return false;
372
373 },
374 }
375 ;
376 let result: () = this.SetHeight(arg0);
377
378 true
379 })());
380 result
381}
382
383
384static height_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
385
386pub(crate) fn init_height_getterinfo<D: DomTypes>() {
387 height_getterinfo.set(JSJitInfo {
388 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
389 getter: Some(get_height::<D>)
390 },
391 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
392 protoID: PrototypeList::ID::DOMRect as u16,
393 },
394 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
395 _bitfield_align_1: [],
396 _bitfield_1: __BindgenBitfieldUnit::new(
397 new_jsjitinfo_bitfield_1!(
398 JSJitInfo_OpType::Getter as u8,
399 JSJitInfo_AliasSet::AliasEverything as u8,
400 JSValueType::JSVAL_TYPE_DOUBLE as u8,
401 true,
402 false,
403 false,
404 false,
405 false,
406 false,
407 0,
408 ).to_ne_bytes()
409 ),
410});
411}
412static height_setterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
413
414pub(crate) fn init_height_setterinfo<D: DomTypes>() {
415 height_setterinfo.set(JSJitInfo {
416 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
417 setter: Some(set_height::<D>)
418 },
419 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
420 protoID: PrototypeList::ID::DOMRect as u16,
421 },
422 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
423 _bitfield_align_1: [],
424 _bitfield_1: __BindgenBitfieldUnit::new(
425 new_jsjitinfo_bitfield_1!(
426 JSJitInfo_OpType::Setter as u8,
427 JSJitInfo_AliasSet::AliasEverything as u8,
428 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
429 false,
430 false,
431 false,
432 false,
433 false,
434 false,
435 0,
436 ).to_ne_bytes()
437 ),
438});
439}
440unsafe extern "C" fn _finalize<D: DomTypes>
441(_cx: *mut GCContext, obj: *mut JSObject){
442 wrap_panic(&mut || {
443
444 let this = native_from_object_static::<D::DOMRect>(obj).unwrap();
445 finalize_common(this);
446 })
447}
448
449unsafe extern "C" fn _trace<D: DomTypes>
450(trc: *mut JSTracer, obj: *mut JSObject){
451 wrap_panic(&mut || {
452
453 let this = native_from_object_static::<D::DOMRect>(obj).unwrap();
454 if this.is_null() { return; } (*this).trace(trc);
456 })
457}
458
459
460static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
461
462pub(crate) fn init_class_ops<D: DomTypes>() {
463 CLASS_OPS.set(JSClassOps {
464 addProperty: None,
465 delProperty: None,
466 enumerate: None,
467 newEnumerate: None,
468 resolve: None,
469 mayResolve: None,
470 finalize: Some(_finalize::<D>),
471 call: None,
472 construct: None,
473 trace: Some(_trace::<D>),
474 });
475}
476
477pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
478
479pub(crate) fn init_domjs_class<D: DomTypes>() {
480 init_class_ops::<D>();
481 Class.set(DOMJSClass {
482 base: JSClass {
483 name: c"DOMRect".as_ptr(),
484 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
485 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
486 ,
487 cOps: unsafe { CLASS_OPS.get() },
488 spec: ptr::null(),
489 ext: ptr::null(),
490 oOps: ptr::null(),
491 },
492 dom_class:
493DOMClass {
494 interface_chain: [ PrototypeList::ID::DOMRectReadOnly, PrototypeList::ID::DOMRect, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
495 depth: 1,
496 type_id: crate::codegen::InheritTypes::TopTypeId { domrectreadonly: (crate::codegen::InheritTypes::DOMRectReadOnlyTypeId::DOMRect) },
497 malloc_size_of: malloc_size_of_including_raw_self::<D::DOMRect> as unsafe fn(&mut _, _) -> _,
498 global: Globals::EMPTY,
499},
500 });
501}
502
503#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
504(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::DOMRect>, _can_gc: CanGc) -> DomRoot<D::DOMRect>{
505
506 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
507
508 let scope = scope.reflector().get_jsobject();
509 assert!(!scope.get().is_null());
510 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
511 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
512
513 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
514 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
515 assert!(!canonical_proto.is_null());
516
517
518 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
519 if let Some(given) = given_proto {
520 proto.set(*given);
521 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
522 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
523 }
524 } else {
525 proto.set(*canonical_proto);
526 }
527 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
528 cx.raw_cx(),
529 &Class.get().base,
530 proto.handle(),
531 ));
532 assert!(!obj.is_null());
533 JS_SetReservedSlot(
534 obj.get(),
535 DOM_OBJECT_SLOT,
536 &PrivateValue(raw.as_ptr() as *const libc::c_void),
537 );
538
539 let root = raw.reflect_with(obj.get());
540
541
542
543 DomRoot::from_ref(&*root)
544}
545
546pub trait DOMRectMethods<D: DomTypes> {
547 fn FromRect(r#global: &D::GlobalScope, r#other: &crate::codegen::GenericBindings::DOMRectReadOnlyBinding::DOMRectInit, r#_can_gc: CanGc) -> DomRoot<D::DOMRect>;
548 fn X(&self, ) -> f64;
549 fn SetX(&self, r#value: f64);
550 fn Y(&self, ) -> f64;
551 fn SetY(&self, r#value: f64);
552 fn Width(&self, ) -> f64;
553 fn SetWidth(&self, r#value: f64);
554 fn Height(&self, ) -> f64;
555 fn SetHeight(&self, r#value: f64);
556 fn Constructor(r#global: &D::GlobalScope, r#proto: Option<HandleObject>, r#can_gc: CanGc, r#x: f64, r#y: f64, r#width: f64, r#height: f64) -> Fallible<DomRoot<D::DOMRect>>;
557}
558const legacy_window_aliases: &[&std::ffi::CStr] = &[
559 c"SVGRect"
560];
561
562static sStaticMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
563
564pub(crate) fn init_sStaticMethods_specs<D: DomTypes>() {
565 sStaticMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
566 JSFunctionSpec {
567 name: JSPropertySpec_Name { string_: c"fromRect".as_ptr() },
568 call: JSNativeWrapper { op: Some(fromRect::<D>), info: ptr::null() },
569 nargs: 0,
570 flags: (JSPROP_ENUMERATE) as u16,
571 selfHostedName: ptr::null()
572 },
573 JSFunctionSpec {
574 name: JSPropertySpec_Name { string_: ptr::null() },
575 call: JSNativeWrapper { op: None, info: ptr::null() },
576 nargs: 0,
577 flags: 0,
578 selfHostedName: ptr::null()
579 }]))[..]
580])));
581}static sStaticMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
582
583pub(crate) fn init_sStaticMethods_prefs<D: DomTypes>() {
584 sStaticMethods.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW),Condition::Exposed(Globals::SERVICE_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::DEDICATED_WORKER_GLOBAL_SCOPE)], (unsafe { sStaticMethods_specs.get() })[0])])));
585}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
586
587pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
588 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
589 JSPropertySpec {
590 name: JSPropertySpec_Name { string_: c"x".as_ptr() },
591 attributes_: (JSPROP_ENUMERATE),
592 kind_: (JSPropertySpec_Kind::NativeAccessor),
593 u: JSPropertySpec_AccessorsOrValue {
594 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
595 getter: JSPropertySpec_Accessor {
596 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { x_getterinfo.get() } },
597 },
598 setter: JSPropertySpec_Accessor {
599 native: JSNativeWrapper { op: Some(generic_setter), info: unsafe { x_setterinfo.get() } },
600 }
601 }
602 }
603 }
604,
605 JSPropertySpec {
606 name: JSPropertySpec_Name { string_: c"y".as_ptr() },
607 attributes_: (JSPROP_ENUMERATE),
608 kind_: (JSPropertySpec_Kind::NativeAccessor),
609 u: JSPropertySpec_AccessorsOrValue {
610 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
611 getter: JSPropertySpec_Accessor {
612 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { y_getterinfo.get() } },
613 },
614 setter: JSPropertySpec_Accessor {
615 native: JSNativeWrapper { op: Some(generic_setter), info: unsafe { y_setterinfo.get() } },
616 }
617 }
618 }
619 }
620,
621 JSPropertySpec {
622 name: JSPropertySpec_Name { string_: c"width".as_ptr() },
623 attributes_: (JSPROP_ENUMERATE),
624 kind_: (JSPropertySpec_Kind::NativeAccessor),
625 u: JSPropertySpec_AccessorsOrValue {
626 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
627 getter: JSPropertySpec_Accessor {
628 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { width_getterinfo.get() } },
629 },
630 setter: JSPropertySpec_Accessor {
631 native: JSNativeWrapper { op: Some(generic_setter), info: unsafe { width_setterinfo.get() } },
632 }
633 }
634 }
635 }
636,
637 JSPropertySpec {
638 name: JSPropertySpec_Name { string_: c"height".as_ptr() },
639 attributes_: (JSPROP_ENUMERATE),
640 kind_: (JSPropertySpec_Kind::NativeAccessor),
641 u: JSPropertySpec_AccessorsOrValue {
642 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
643 getter: JSPropertySpec_Accessor {
644 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { height_getterinfo.get() } },
645 },
646 setter: JSPropertySpec_Accessor {
647 native: JSNativeWrapper { op: Some(generic_setter), info: unsafe { height_setterinfo.get() } },
648 }
649 }
650 }
651 }
652,
653 JSPropertySpec::ZERO]))[..]
654,
655&Box::leak(Box::new([
656 JSPropertySpec {
657 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
658 attributes_: (JSPROP_READONLY),
659 kind_: (JSPropertySpec_Kind::Value),
660 u: JSPropertySpec_AccessorsOrValue {
661 value: JSPropertySpec_ValueWrapper {
662 type_: JSPropertySpec_ValueWrapper_Type::String,
663 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
664 string: c"DOMRect".as_ptr(),
665 }
666 }
667 }
668 }
669,
670 JSPropertySpec::ZERO]))[..]
671])));
672}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
673
674pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
675 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW),Condition::Exposed(Globals::SERVICE_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::DEDICATED_WORKER_GLOBAL_SCOPE)], (unsafe { sAttributes_specs.get() })[0]),
676 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
677}
678pub fn GetProtoObject<D: DomTypes>
679(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
680 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::DOMRect), CreateInterfaceObjects::<D>, rval)
682}
683
684
685static PrototypeClass: JSClass = JSClass {
686 name: c"DOMRectPrototype".as_ptr(),
687 flags:
688 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
690 cOps: ptr::null(),
691 spec: ptr::null(),
692 ext: ptr::null(),
693 oOps: ptr::null(),
694};
695
696unsafe extern "C" fn _constructor<D: DomTypes>
697(cx: *mut RawJSContext, argc: u32, vp: *mut JSVal) -> bool{
698 let mut result = false;
699 wrap_panic(&mut || result = {
700 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
701 let args = CallArgs::from_vp(vp, argc);
702 let global = D::GlobalScope::from_object(JS_CALLEE(cx.raw_cx(), vp).to_object());
703
704 call_default_constructor::<D>(
705 SafeJSContext::from_ptr(cx.raw_cx()),
706 &args,
707 &global,
708 PrototypeList::ID::DOMRect,
709 "DOMRect",
710 CreateInterfaceObjects::<D>,
711 |cx: SafeJSContext, args: &CallArgs, global: &D::GlobalScope, desired_proto: HandleObject| {
712 let arg0: f64 = if args.get(0).is_undefined() {
713 0.0
714 } else {
715 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
716 Ok(ConversionResult::Success(value)) => value,
717 Ok(ConversionResult::Failure(error)) => {
718 throw_type_error(cx.raw_cx(), &error);
719 return false;
720
721 }
722 _ => {
723 return false;
724
725 },
726 }
727
728 };
729 let arg1: f64 = if args.get(1).is_undefined() {
730 0.0
731 } else {
732 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
733 Ok(ConversionResult::Success(value)) => value,
734 Ok(ConversionResult::Failure(error)) => {
735 throw_type_error(cx.raw_cx(), &error);
736 return false;
737
738 }
739 _ => {
740 return false;
741
742 },
743 }
744
745 };
746 let arg2: f64 = if args.get(2).is_undefined() {
747 0.0
748 } else {
749 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(2)), ()) {
750 Ok(ConversionResult::Success(value)) => value,
751 Ok(ConversionResult::Failure(error)) => {
752 throw_type_error(cx.raw_cx(), &error);
753 return false;
754
755 }
756 _ => {
757 return false;
758
759 },
760 }
761
762 };
763 let arg3: f64 = if args.get(3).is_undefined() {
764 0.0
765 } else {
766 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(3)), ()) {
767 Ok(ConversionResult::Success(value)) => value,
768 Ok(ConversionResult::Failure(error)) => {
769 throw_type_error(cx.raw_cx(), &error);
770 return false;
771
772 }
773 _ => {
774 return false;
775
776 },
777 }
778
779 };
780 let result: Result<DomRoot<D::DOMRect>, Error> = <D::DOMRect>::Constructor(global, Some(desired_proto), CanGc::note(), arg0, arg1, arg2, arg3);
781 let result = match result {
782 Ok(result) => result,
783 Err(e) => {
784 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), global.upcast::<D::GlobalScope>(), e, CanGc::note());
785 return false;
786 },
787 };
788
789 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
790 return true;
791 }
792 )
793
794 });
795 result
796}
797
798
799static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
800
801pub(crate) fn init_interface_object<D: DomTypes>() {
802 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
803 Box::leak(Box::new(InterfaceConstructorBehavior::call(_constructor::<D>))),
804 b"function DOMRect() {\n [native code]\n}",
805 PrototypeList::ID::DOMRect,
806 1,
807 ));
808}
809
810pub fn DefineDOMInterface<D: DomTypes>
811(cx: SafeJSContext, global: HandleObject){
812 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::DOMRect),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
813}
814
815pub fn ConstructorEnabled<D: DomTypes>
816(aCx: SafeJSContext, aObj: HandleObject) -> bool{
817 is_exposed_in(aObj, Globals::DEDICATED_WORKER_GLOBAL_SCOPE | Globals::SERVICE_WORKER_GLOBAL_SCOPE | Globals::WINDOW)
818}
819
820unsafe fn CreateInterfaceObjects<D: DomTypes>
821(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
822
823 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
824 DOMRectReadOnly_Binding::GetProtoObject::<D>(cx, global, prototype_proto.handle_mut());
825 assert!(!prototype_proto.is_null());
826
827 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
828 create_interface_prototype_object::<D>(cx,
829 global,
830 prototype_proto.handle(),
831 &PrototypeClass,
832 &[],
833 sAttributes.get(),
834 &[],
835 &[],
836 prototype.handle_mut());
837 assert!(!prototype.is_null());
838 assert!((*cache)[PrototypeList::ID::DOMRect as usize].is_null());
839 (*cache)[PrototypeList::ID::DOMRect as usize] = prototype.get();
840 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::DOMRect as isize),
841 ptr::null_mut(),
842 prototype.get());
843
844 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
845
846 DOMRectReadOnly_Binding::GetConstructorObject::<D>(cx, global, interface_proto.handle_mut());
847
848 assert!(!interface_proto.is_null());
849
850 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
851 create_noncallback_interface_object::<D>(cx,
852 global,
853 interface_proto.handle(),
854 INTERFACE_OBJECT_CLASS.get(),
855 sStaticMethods.get(),
856 &[],
857 &[],
858 prototype.handle(),
859 c"DOMRect",
860 0,
861 legacy_window_aliases,
862 interface.handle_mut());
863 assert!(!interface.is_null());
864}
865
866
867 pub(crate) fn init_statics<D: DomTypes>() {
868 init_interface_object::<D>();
869 init_domjs_class::<D>();
870
871 init_x_getterinfo::<D>();
872init_y_getterinfo::<D>();
873init_width_getterinfo::<D>();
874init_height_getterinfo::<D>();
875 init_x_setterinfo::<D>();
876init_y_setterinfo::<D>();
877init_width_setterinfo::<D>();
878init_height_setterinfo::<D>();
879
880 init_sStaticMethods_specs::<D>();
881init_sStaticMethods_prefs::<D>();
882init_sAttributes_specs::<D>();
883init_sAttributes_prefs::<D>();
884 }
885 }