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::EventBinding::Event_Binding;
6use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
7use crate::import::base::*;
8
9#[derive(JSTraceable)]
10pub struct AnimationEventInit {
11 pub parent: crate::codegen::GenericBindings::EventBinding::EventInit,
12 pub animationName: DOMString,
13 pub elapsedTime: Finite<f32>,
14 pub pseudoElement: DOMString,
15}
16impl Default for AnimationEventInit {
17 fn default() -> Self {
18 Self::empty()
19 }
20}
21
22impl AnimationEventInit {
23 pub fn empty() -> Self {
24 Self {
25 parent: crate::codegen::GenericBindings::EventBinding::EventInit::empty(),
26 animationName: DOMString::from(""),
27 elapsedTime: Finite::wrap(0.0),
28 pseudoElement: DOMString::from(""),
29 }
30 }
31 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
32 -> Result<ConversionResult<AnimationEventInit>, ()> {
33 unsafe {
34 let object = if val.get().is_null_or_undefined() {
35 ptr::null_mut()
36 } else if val.get().is_object() {
37 val.get().to_object()
38 } else {
39 return Ok(ConversionResult::Failure("Value is not an object.".into()));
40 };
41 rooted!(&in(cx) let object = object);
42 let dictionary = AnimationEventInit {
43 parent: {
44 match crate::codegen::GenericBindings::EventBinding::EventInit::new(cx, val, can_gc)? {
45 ConversionResult::Success(v) => v,
46 ConversionResult::Failure(error) => {
47 throw_type_error(cx.raw_cx(), &error);
48 return Err(());
49 }
50 }
51 },
52 animationName: {
53 rooted!(&in(cx) let mut rval = UndefinedValue());
54 if get_dictionary_property(cx.raw_cx(), object.handle(), "animationName", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
55 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), StringificationBehavior::Default) {
56 Ok(ConversionResult::Success(value)) => value,
57 Ok(ConversionResult::Failure(error)) => {
58 throw_type_error(cx.raw_cx(), &error);
59 return Err(());
60
61 }
62 _ => {
63 return Err(());
64
65 },
66 }
67
68 } else {
69 DOMString::from("")
70 }
71 },
72 elapsedTime: {
73 rooted!(&in(cx) let mut rval = UndefinedValue());
74 if get_dictionary_property(cx.raw_cx(), object.handle(), "elapsedTime", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
75 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
76 Ok(ConversionResult::Success(value)) => value,
77 Ok(ConversionResult::Failure(error)) => {
78 throw_type_error(cx.raw_cx(), &error);
79 return Err(());
80
81 }
82 _ => {
83 return Err(());
84
85 },
86 }
87
88 } else {
89 Finite::wrap(0.0)
90 }
91 },
92 pseudoElement: {
93 rooted!(&in(cx) let mut rval = UndefinedValue());
94 if get_dictionary_property(cx.raw_cx(), object.handle(), "pseudoElement", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
95 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), StringificationBehavior::Default) {
96 Ok(ConversionResult::Success(value)) => value,
97 Ok(ConversionResult::Failure(error)) => {
98 throw_type_error(cx.raw_cx(), &error);
99 return Err(());
100
101 }
102 _ => {
103 return Err(());
104
105 },
106 }
107
108 } else {
109 DOMString::from("")
110 }
111 },
112 };
113 Ok(ConversionResult::Success(dictionary))
114 }
115 }
116}
117
118impl FromJSValConvertible for AnimationEventInit {
119 type Config = ();
120 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
121 -> Result<ConversionResult<AnimationEventInit>, ()> {
122 AnimationEventInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
123 }
124}
125
126impl AnimationEventInit {
127 #[allow(clippy::wrong_self_convention)]
128 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
129 self.parent.to_jsobject(cx, obj.reborrow());
130 let animationName = &self.animationName;
131 rooted!(in(cx) let mut animationName_js = UndefinedValue());
132 animationName.to_jsval(cx, animationName_js.handle_mut());
133 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "animationName", animationName_js.handle()).unwrap();
134 let elapsedTime = &self.elapsedTime;
135 rooted!(in(cx) let mut elapsedTime_js = UndefinedValue());
136 elapsedTime.to_jsval(cx, elapsedTime_js.handle_mut());
137 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "elapsedTime", elapsedTime_js.handle()).unwrap();
138 let pseudoElement = &self.pseudoElement;
139 rooted!(in(cx) let mut pseudoElement_js = UndefinedValue());
140 pseudoElement.to_jsval(cx, pseudoElement_js.handle_mut());
141 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "pseudoElement", pseudoElement_js.handle()).unwrap();
142 }
143}
144
145impl ToJSValConvertible for AnimationEventInit {
146 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
147 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
148 self.to_jsobject(cx, obj.handle_mut());
149 rval.set(ObjectOrNullValue(obj.get()))
150 }
151}
152
153
154pub use self::AnimationEvent_Binding::{Wrap, AnimationEventMethods, GetProtoObject, DefineDOMInterface};
155pub mod AnimationEvent_Binding {
156use crate::codegen::GenericBindings::AnimationEventBinding::AnimationEventInit;
157use crate::codegen::GenericBindings::EventBinding::Event_Binding;
158use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
159use crate::import::module::*;
160
161unsafe extern "C" fn get_animationName<D: DomTypes>
162(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
163 let mut result = false;
164 wrap_panic(&mut || result = (|| {
165 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
166 let this = &*(this as *const D::AnimationEvent);
167 let result: DOMString = this.AnimationName();
168
169 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
170 return true;
171 })());
172 result
173}
174
175
176static animationName_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
177
178pub(crate) fn init_animationName_getterinfo<D: DomTypes>() {
179 animationName_getterinfo.set(JSJitInfo {
180 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
181 getter: Some(get_animationName::<D>)
182 },
183 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
184 protoID: PrototypeList::ID::AnimationEvent as u16,
185 },
186 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
187 _bitfield_align_1: [],
188 _bitfield_1: __BindgenBitfieldUnit::new(
189 new_jsjitinfo_bitfield_1!(
190 JSJitInfo_OpType::Getter as u8,
191 JSJitInfo_AliasSet::AliasEverything as u8,
192 JSValueType::JSVAL_TYPE_STRING as u8,
193 true,
194 false,
195 false,
196 false,
197 false,
198 false,
199 0,
200 ).to_ne_bytes()
201 ),
202});
203}
204unsafe extern "C" fn get_elapsedTime<D: DomTypes>
205(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
206 let mut result = false;
207 wrap_panic(&mut || result = (|| {
208 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
209 let this = &*(this as *const D::AnimationEvent);
210 let result: Finite<f32> = this.ElapsedTime();
211
212 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
213 return true;
214 })());
215 result
216}
217
218
219static elapsedTime_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
220
221pub(crate) fn init_elapsedTime_getterinfo<D: DomTypes>() {
222 elapsedTime_getterinfo.set(JSJitInfo {
223 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
224 getter: Some(get_elapsedTime::<D>)
225 },
226 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
227 protoID: PrototypeList::ID::AnimationEvent as u16,
228 },
229 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
230 _bitfield_align_1: [],
231 _bitfield_1: __BindgenBitfieldUnit::new(
232 new_jsjitinfo_bitfield_1!(
233 JSJitInfo_OpType::Getter as u8,
234 JSJitInfo_AliasSet::AliasEverything as u8,
235 JSValueType::JSVAL_TYPE_DOUBLE as u8,
236 true,
237 false,
238 false,
239 false,
240 false,
241 false,
242 0,
243 ).to_ne_bytes()
244 ),
245});
246}
247unsafe extern "C" fn get_pseudoElement<D: DomTypes>
248(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
249 let mut result = false;
250 wrap_panic(&mut || result = (|| {
251 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
252 let this = &*(this as *const D::AnimationEvent);
253 let result: DOMString = this.PseudoElement();
254
255 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
256 return true;
257 })());
258 result
259}
260
261
262static pseudoElement_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
263
264pub(crate) fn init_pseudoElement_getterinfo<D: DomTypes>() {
265 pseudoElement_getterinfo.set(JSJitInfo {
266 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
267 getter: Some(get_pseudoElement::<D>)
268 },
269 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
270 protoID: PrototypeList::ID::AnimationEvent as u16,
271 },
272 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
273 _bitfield_align_1: [],
274 _bitfield_1: __BindgenBitfieldUnit::new(
275 new_jsjitinfo_bitfield_1!(
276 JSJitInfo_OpType::Getter as u8,
277 JSJitInfo_AliasSet::AliasEverything as u8,
278 JSValueType::JSVAL_TYPE_STRING as u8,
279 true,
280 false,
281 false,
282 false,
283 false,
284 false,
285 0,
286 ).to_ne_bytes()
287 ),
288});
289}
290unsafe extern "C" fn get_isTrusted<D: DomTypes>
291(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
292 let mut result = false;
293 wrap_panic(&mut || result = (|| {
294 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
295 let this = &*(this as *const D::AnimationEvent);
296 let result: bool = this.IsTrusted();
297
298 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
299 return true;
300 })());
301 result
302}
303
304
305static isTrusted_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
306
307pub(crate) fn init_isTrusted_getterinfo<D: DomTypes>() {
308 isTrusted_getterinfo.set(JSJitInfo {
309 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
310 getter: Some(get_isTrusted::<D>)
311 },
312 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
313 protoID: PrototypeList::ID::AnimationEvent as u16,
314 },
315 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
316 _bitfield_align_1: [],
317 _bitfield_1: __BindgenBitfieldUnit::new(
318 new_jsjitinfo_bitfield_1!(
319 JSJitInfo_OpType::Getter as u8,
320 JSJitInfo_AliasSet::AliasEverything as u8,
321 JSValueType::JSVAL_TYPE_BOOLEAN as u8,
322 true,
323 false,
324 false,
325 false,
326 false,
327 false,
328 0,
329 ).to_ne_bytes()
330 ),
331});
332}
333unsafe extern "C" fn _finalize<D: DomTypes>
334(_cx: *mut GCContext, obj: *mut JSObject){
335 wrap_panic(&mut || {
336
337 let this = native_from_object_static::<D::AnimationEvent>(obj).unwrap();
338 finalize_common(this);
339 })
340}
341
342unsafe extern "C" fn _trace<D: DomTypes>
343(trc: *mut JSTracer, obj: *mut JSObject){
344 wrap_panic(&mut || {
345
346 let this = native_from_object_static::<D::AnimationEvent>(obj).unwrap();
347 if this.is_null() { return; } (*this).trace(trc);
349 })
350}
351
352
353static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
354
355pub(crate) fn init_class_ops<D: DomTypes>() {
356 CLASS_OPS.set(JSClassOps {
357 addProperty: None,
358 delProperty: None,
359 enumerate: None,
360 newEnumerate: None,
361 resolve: None,
362 mayResolve: None,
363 finalize: Some(_finalize::<D>),
364 call: None,
365 construct: None,
366 trace: Some(_trace::<D>),
367 });
368}
369
370pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
371
372pub(crate) fn init_domjs_class<D: DomTypes>() {
373 init_class_ops::<D>();
374 Class.set(DOMJSClass {
375 base: JSClass {
376 name: c"AnimationEvent".as_ptr(),
377 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
378 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
379 ,
380 cOps: unsafe { CLASS_OPS.get() },
381 spec: ptr::null(),
382 ext: ptr::null(),
383 oOps: ptr::null(),
384 },
385 dom_class:
386DOMClass {
387 interface_chain: [ PrototypeList::ID::Event, PrototypeList::ID::AnimationEvent, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
388 depth: 1,
389 type_id: crate::codegen::InheritTypes::TopTypeId { event: (crate::codegen::InheritTypes::EventTypeId::AnimationEvent) },
390 malloc_size_of: malloc_size_of_including_raw_self::<D::AnimationEvent> as unsafe fn(&mut _, _) -> _,
391 global: Globals::EMPTY,
392},
393 });
394}
395
396#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
397(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::AnimationEvent>, _can_gc: CanGc) -> DomRoot<D::AnimationEvent>{
398
399 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
400
401 let scope = scope.reflector().get_jsobject();
402 assert!(!scope.get().is_null());
403 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
404 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
405
406 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
407 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
408 assert!(!canonical_proto.is_null());
409
410
411 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
412 if let Some(given) = given_proto {
413 proto.set(*given);
414 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
415 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
416 }
417 } else {
418 proto.set(*canonical_proto);
419 }
420 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
421 cx.raw_cx(),
422 &Class.get().base,
423 proto.handle(),
424 ));
425 assert!(!obj.is_null());
426 JS_SetReservedSlot(
427 obj.get(),
428 DOM_OBJECT_SLOT,
429 &PrivateValue(raw.as_ptr() as *const libc::c_void),
430 );
431
432 let root = raw.reflect_with(obj.get());
433
434
435 let mut slot = UndefinedValue();
436 JS_GetReservedSlot(canonical_proto.get(), DOM_PROTO_UNFORGEABLE_HOLDER_SLOT, &mut slot);
437 rooted!(&in(cx) let mut unforgeable_holder = ptr::null_mut::<JSObject>());
438 unforgeable_holder.handle_mut().set(slot.to_object());
439 assert!(JS_InitializePropertiesFromCompatibleNativeObject(cx.raw_cx(), obj.handle(), unforgeable_holder.handle()));
440
441
442 DomRoot::from_ref(&*root)
443}
444
445pub trait AnimationEventMethods<D: DomTypes> {
446 fn AnimationName(&self, ) -> DOMString;
447 fn ElapsedTime(&self, ) -> Finite<f32>;
448 fn PseudoElement(&self, ) -> DOMString;
449 fn IsTrusted(&self, ) -> bool;
450 fn Constructor(r#global: &D::Window, r#proto: Option<HandleObject>, r#can_gc: CanGc, r#type_: DOMString, r#eventInitDict: &crate::codegen::GenericBindings::AnimationEventBinding::AnimationEventInit) -> DomRoot<D::AnimationEvent>;
451}
452static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
453
454pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
455 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
456 JSPropertySpec {
457 name: JSPropertySpec_Name { string_: c"animationName".as_ptr() },
458 attributes_: (JSPROP_ENUMERATE),
459 kind_: (JSPropertySpec_Kind::NativeAccessor),
460 u: JSPropertySpec_AccessorsOrValue {
461 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
462 getter: JSPropertySpec_Accessor {
463 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { animationName_getterinfo.get() } },
464 },
465 setter: JSPropertySpec_Accessor {
466 native: JSNativeWrapper { op: None, info: ptr::null() },
467 }
468 }
469 }
470 }
471,
472 JSPropertySpec {
473 name: JSPropertySpec_Name { string_: c"elapsedTime".as_ptr() },
474 attributes_: (JSPROP_ENUMERATE),
475 kind_: (JSPropertySpec_Kind::NativeAccessor),
476 u: JSPropertySpec_AccessorsOrValue {
477 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
478 getter: JSPropertySpec_Accessor {
479 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { elapsedTime_getterinfo.get() } },
480 },
481 setter: JSPropertySpec_Accessor {
482 native: JSNativeWrapper { op: None, info: ptr::null() },
483 }
484 }
485 }
486 }
487,
488 JSPropertySpec {
489 name: JSPropertySpec_Name { string_: c"pseudoElement".as_ptr() },
490 attributes_: (JSPROP_ENUMERATE),
491 kind_: (JSPropertySpec_Kind::NativeAccessor),
492 u: JSPropertySpec_AccessorsOrValue {
493 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
494 getter: JSPropertySpec_Accessor {
495 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { pseudoElement_getterinfo.get() } },
496 },
497 setter: JSPropertySpec_Accessor {
498 native: JSNativeWrapper { op: None, info: ptr::null() },
499 }
500 }
501 }
502 }
503,
504 JSPropertySpec::ZERO]))[..]
505,
506&Box::leak(Box::new([
507 JSPropertySpec {
508 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
509 attributes_: (JSPROP_READONLY),
510 kind_: (JSPropertySpec_Kind::Value),
511 u: JSPropertySpec_AccessorsOrValue {
512 value: JSPropertySpec_ValueWrapper {
513 type_: JSPropertySpec_ValueWrapper_Type::String,
514 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
515 string: c"AnimationEvent".as_ptr(),
516 }
517 }
518 }
519 }
520,
521 JSPropertySpec::ZERO]))[..]
522])));
523}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
524
525pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
526 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sAttributes_specs.get() })[0]),
527 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
528}static sLegacyUnforgeableAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
529
530pub(crate) fn init_sLegacyUnforgeableAttributes_specs<D: DomTypes>() {
531 sLegacyUnforgeableAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
532 JSPropertySpec {
533 name: JSPropertySpec_Name { string_: c"isTrusted".as_ptr() },
534 attributes_: (JSPROP_ENUMERATE | JSPROP_PERMANENT),
535 kind_: (JSPropertySpec_Kind::NativeAccessor),
536 u: JSPropertySpec_AccessorsOrValue {
537 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
538 getter: JSPropertySpec_Accessor {
539 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { isTrusted_getterinfo.get() } },
540 },
541 setter: JSPropertySpec_Accessor {
542 native: JSNativeWrapper { op: None, info: ptr::null() },
543 }
544 }
545 }
546 }
547,
548 JSPropertySpec::ZERO]))[..]
549])));
550}static sLegacyUnforgeableAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
551
552pub(crate) fn init_sLegacyUnforgeableAttributes_prefs<D: DomTypes>() {
553 sLegacyUnforgeableAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW),Condition::Exposed(Globals::SERVICE_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::PAINT_WORKLET_GLOBAL_SCOPE),Condition::Exposed(Globals::DEDICATED_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::DEBUGGER_GLOBAL_SCOPE),Condition::Exposed(Globals::DISSIMILAR_ORIGIN_WINDOW),Condition::Exposed(Globals::TEST_WORKLET_GLOBAL_SCOPE)], (unsafe { sLegacyUnforgeableAttributes_specs.get() })[0])])));
554}
555pub fn GetProtoObject<D: DomTypes>
556(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
557 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::AnimationEvent), CreateInterfaceObjects::<D>, rval)
559}
560
561
562static PrototypeClass: JSClass = JSClass {
563 name: c"AnimationEventPrototype".as_ptr(),
564 flags:
565 (1 & JSCLASS_RESERVED_SLOTS_MASK ) << JSCLASS_RESERVED_SLOTS_SHIFT,
567 cOps: ptr::null(),
568 spec: ptr::null(),
569 ext: ptr::null(),
570 oOps: ptr::null(),
571};
572
573unsafe extern "C" fn _constructor<D: DomTypes>
574(cx: *mut RawJSContext, argc: u32, vp: *mut JSVal) -> bool{
575 let mut result = false;
576 wrap_panic(&mut || result = {
577 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
578 let args = CallArgs::from_vp(vp, argc);
579 let global = D::GlobalScope::from_object(JS_CALLEE(cx.raw_cx(), vp).to_object());
580
581 call_default_constructor::<D>(
582 SafeJSContext::from_ptr(cx.raw_cx()),
583 &args,
584 &global,
585 PrototypeList::ID::AnimationEvent,
586 "AnimationEvent",
587 CreateInterfaceObjects::<D>,
588 |cx: SafeJSContext, args: &CallArgs, global: &D::GlobalScope, desired_proto: HandleObject| {
589
590 if argc < 1 {
591 throw_type_error(cx.raw_cx(), "Not enough arguments to \"AnimationEvent.constructor\".");
592 return false;
593 }
594 let arg0: DOMString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
595 Ok(ConversionResult::Success(value)) => value,
596 Ok(ConversionResult::Failure(error)) => {
597 throw_type_error(cx.raw_cx(), &error);
598 return false;
599
600 }
601 _ => {
602 return false;
603
604 },
605 }
606 ;
607 let arg1: crate::codegen::GenericBindings::AnimationEventBinding::AnimationEventInit = if args.get(1).is_undefined() {
608 crate::codegen::GenericBindings::AnimationEventBinding::AnimationEventInit::empty()
609 } else {
610 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
611 Ok(ConversionResult::Success(value)) => value,
612 Ok(ConversionResult::Failure(error)) => {
613 throw_type_error(cx.raw_cx(), &error);
614 return false;
615
616 }
617 _ => {
618 return false;
619
620 },
621 }
622
623 };
624 let result: DomRoot<D::AnimationEvent> = <D::AnimationEvent>::Constructor(global.downcast::<D::Window>().unwrap(), Some(desired_proto), CanGc::note(), arg0, &arg1);
625
626 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
627 return true;
628 }
629 )
630
631 });
632 result
633}
634
635
636static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
637
638pub(crate) fn init_interface_object<D: DomTypes>() {
639 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
640 Box::leak(Box::new(InterfaceConstructorBehavior::call(_constructor::<D>))),
641 b"function AnimationEvent() {\n [native code]\n}",
642 PrototypeList::ID::AnimationEvent,
643 1,
644 ));
645}
646
647pub fn DefineDOMInterface<D: DomTypes>
648(cx: SafeJSContext, global: HandleObject){
649 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::AnimationEvent),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
650}
651
652pub fn ConstructorEnabled<D: DomTypes>
653(aCx: SafeJSContext, aObj: HandleObject) -> bool{
654 is_exposed_in(aObj, Globals::WINDOW)
655}
656
657unsafe fn CreateInterfaceObjects<D: DomTypes>
658(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
659
660 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
661 Event_Binding::GetProtoObject::<D>(cx, global, prototype_proto.handle_mut());
662 assert!(!prototype_proto.is_null());
663
664 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
665 create_interface_prototype_object::<D>(cx,
666 global,
667 prototype_proto.handle(),
668 &PrototypeClass,
669 &[],
670 sAttributes.get(),
671 &[],
672 &[],
673 prototype.handle_mut());
674 assert!(!prototype.is_null());
675 assert!((*cache)[PrototypeList::ID::AnimationEvent as usize].is_null());
676 (*cache)[PrototypeList::ID::AnimationEvent as usize] = prototype.get();
677 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::AnimationEvent as isize),
678 ptr::null_mut(),
679 prototype.get());
680
681 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
682
683 Event_Binding::GetConstructorObject::<D>(cx, global, interface_proto.handle_mut());
684
685 assert!(!interface_proto.is_null());
686
687 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
688 create_noncallback_interface_object::<D>(cx,
689 global,
690 interface_proto.handle(),
691 INTERFACE_OBJECT_CLASS.get(),
692 &[],
693 &[],
694 &[],
695 prototype.handle(),
696 c"AnimationEvent",
697 1,
698 &[],
699 interface.handle_mut());
700 assert!(!interface.is_null());
701
702 rooted!(&in(cx) let mut unforgeable_holder = ptr::null_mut::<JSObject>());
703 unforgeable_holder.handle_mut().set(
704 JS_NewObjectWithoutMetadata(cx.raw_cx(), &Class.get().base as *const JSClass, prototype.handle()));
705 assert!(!unforgeable_holder.is_null());
706
707 define_guarded_properties::<D>(cx, unforgeable_holder.handle(), unsafe { sLegacyUnforgeableAttributes.get() }, global);
708 let val = ObjectValue(unforgeable_holder.get());
709 JS_SetReservedSlot(prototype.get(), DOM_PROTO_UNFORGEABLE_HOLDER_SLOT, &val)
710}
711
712
713 pub(crate) fn init_statics<D: DomTypes>() {
714 init_interface_object::<D>();
715 init_domjs_class::<D>();
716
717 init_animationName_getterinfo::<D>();
718init_elapsedTime_getterinfo::<D>();
719init_pseudoElement_getterinfo::<D>();
720init_isTrusted_getterinfo::<D>();
721
722
723 init_sAttributes_specs::<D>();
724init_sAttributes_prefs::<D>();
725init_sLegacyUnforgeableAttributes_specs::<D>();
726init_sLegacyUnforgeableAttributes_prefs::<D>();
727 }
728 }