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::ElementBinding::Element_Binding;
6use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
7use crate::codegen::GenericBindings::HTMLElementBinding::HTMLElement_Binding;
8use crate::codegen::GenericBindings::NodeBinding::Node_Binding;
9use crate::import::base::*;
10
11pub use self::HTMLBaseElement_Binding::{Wrap, HTMLBaseElementMethods, GetProtoObject, GetConstructorObject, DefineDOMInterface};
12pub mod HTMLBaseElement_Binding {
13use crate::codegen::GenericBindings::ElementBinding::Element_Binding;
14use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
15use crate::codegen::GenericBindings::HTMLElementBinding::HTMLElement_Binding;
16use crate::codegen::GenericBindings::NodeBinding::Node_Binding;
17use crate::import::module::*;
18
19unsafe extern "C" fn get_href<D: DomTypes>
20(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
21 let mut result = false;
22 wrap_panic(&mut || result = (|| {
23 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
24 let this = &*(this as *const D::HTMLBaseElement);
25 <D as DomHelpers<D>>::push_new_element_queue();
26
27 let result: DOMString = this.Href();
28 <D as DomHelpers<D>>::pop_current_element_queue(CanGc::note());
29
30
31 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
32 return true;
33 })());
34 result
35}
36
37unsafe extern "C" fn set_href<D: DomTypes>
38(cx: *mut RawJSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool{
39 let mut result = false;
40 wrap_panic(&mut || result = (|| {
41 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
42 let this = &*(this as *const D::HTMLBaseElement);
43 let arg0: DOMString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
44 Ok(ConversionResult::Success(value)) => value,
45 Ok(ConversionResult::Failure(error)) => {
46 throw_type_error(cx.raw_cx(), &error);
47 return false;
48
49 }
50 _ => {
51 return false;
52
53 },
54 }
55 ;
56 <D as DomHelpers<D>>::push_new_element_queue();
57
58 let result: () = this.SetHref(arg0);
59 <D as DomHelpers<D>>::pop_current_element_queue(CanGc::note());
60
61
62 true
63 })());
64 result
65}
66
67
68static href_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
69
70pub(crate) fn init_href_getterinfo<D: DomTypes>() {
71 href_getterinfo.set(JSJitInfo {
72 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
73 getter: Some(get_href::<D>)
74 },
75 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
76 protoID: PrototypeList::ID::HTMLBaseElement as u16,
77 },
78 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 4 },
79 _bitfield_align_1: [],
80 _bitfield_1: __BindgenBitfieldUnit::new(
81 new_jsjitinfo_bitfield_1!(
82 JSJitInfo_OpType::Getter as u8,
83 JSJitInfo_AliasSet::AliasEverything as u8,
84 JSValueType::JSVAL_TYPE_STRING as u8,
85 true,
86 false,
87 false,
88 false,
89 false,
90 false,
91 0,
92 ).to_ne_bytes()
93 ),
94});
95}
96static href_setterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
97
98pub(crate) fn init_href_setterinfo<D: DomTypes>() {
99 href_setterinfo.set(JSJitInfo {
100 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
101 setter: Some(set_href::<D>)
102 },
103 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
104 protoID: PrototypeList::ID::HTMLBaseElement as u16,
105 },
106 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 4 },
107 _bitfield_align_1: [],
108 _bitfield_1: __BindgenBitfieldUnit::new(
109 new_jsjitinfo_bitfield_1!(
110 JSJitInfo_OpType::Setter as u8,
111 JSJitInfo_AliasSet::AliasEverything as u8,
112 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
113 false,
114 false,
115 false,
116 false,
117 false,
118 false,
119 0,
120 ).to_ne_bytes()
121 ),
122});
123}
124unsafe extern "C" fn _finalize<D: DomTypes>
125(_cx: *mut GCContext, obj: *mut JSObject){
126 wrap_panic(&mut || {
127
128 let this = native_from_object_static::<D::HTMLBaseElement>(obj).unwrap();
129 finalize_common(this);
130 })
131}
132
133unsafe extern "C" fn _trace<D: DomTypes>
134(trc: *mut JSTracer, obj: *mut JSObject){
135 wrap_panic(&mut || {
136
137 let this = native_from_object_static::<D::HTMLBaseElement>(obj).unwrap();
138 if this.is_null() { return; } (*this).trace(trc);
140 })
141}
142
143
144static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
145
146pub(crate) fn init_class_ops<D: DomTypes>() {
147 CLASS_OPS.set(JSClassOps {
148 addProperty: None,
149 delProperty: None,
150 enumerate: None,
151 newEnumerate: None,
152 resolve: None,
153 mayResolve: None,
154 finalize: Some(_finalize::<D>),
155 call: None,
156 construct: None,
157 trace: Some(_trace::<D>),
158 });
159}
160
161pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
162
163pub(crate) fn init_domjs_class<D: DomTypes>() {
164 init_class_ops::<D>();
165 Class.set(DOMJSClass {
166 base: JSClass {
167 name: c"HTMLBaseElement".as_ptr(),
168 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
169 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
170 ,
171 cOps: unsafe { CLASS_OPS.get() },
172 spec: ptr::null(),
173 ext: ptr::null(),
174 oOps: ptr::null(),
175 },
176 dom_class:
177DOMClass {
178 interface_chain: [ PrototypeList::ID::EventTarget, PrototypeList::ID::Node, PrototypeList::ID::Element, PrototypeList::ID::HTMLElement, PrototypeList::ID::HTMLBaseElement, PrototypeList::ID::Last ],
179 depth: 4,
180 type_id: crate::codegen::InheritTypes::TopTypeId { eventtarget: (crate::codegen::InheritTypes::EventTargetTypeId::Node(crate::codegen::InheritTypes::NodeTypeId::Element(crate::codegen::InheritTypes::ElementTypeId::HTMLElement(crate::codegen::InheritTypes::HTMLElementTypeId::HTMLBaseElement)))) },
181 malloc_size_of: malloc_size_of_including_raw_self::<D::HTMLBaseElement> as unsafe fn(&mut _, _) -> _,
182 global: Globals::EMPTY,
183},
184 });
185}
186
187#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
188(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::HTMLBaseElement>, _can_gc: CanGc) -> DomRoot<D::HTMLBaseElement>{
189
190 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
191
192 let scope = scope.reflector().get_jsobject();
193 assert!(!scope.get().is_null());
194 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
195 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
196
197 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
198 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
199 assert!(!canonical_proto.is_null());
200
201
202 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
203 if let Some(given) = given_proto {
204 proto.set(*given);
205 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
206 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
207 }
208 } else {
209 proto.set(*canonical_proto);
210 }
211 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
212 cx.raw_cx(),
213 &Class.get().base,
214 proto.handle(),
215 ));
216 assert!(!obj.is_null());
217 JS_SetReservedSlot(
218 obj.get(),
219 DOM_OBJECT_SLOT,
220 &PrivateValue(raw.as_ptr() as *const libc::c_void),
221 );
222
223 let root = raw.reflect_with(obj.get());
224
225
226
227 DomRoot::from_ref(&*root)
228}
229
230pub trait HTMLBaseElementMethods<D: DomTypes> {
231 fn Href(&self, ) -> DOMString;
232 fn SetHref(&self, r#value: DOMString);
233}
234static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
235
236pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
237 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
238 JSPropertySpec {
239 name: JSPropertySpec_Name { string_: c"href".as_ptr() },
240 attributes_: (JSPROP_ENUMERATE),
241 kind_: (JSPropertySpec_Kind::NativeAccessor),
242 u: JSPropertySpec_AccessorsOrValue {
243 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
244 getter: JSPropertySpec_Accessor {
245 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { href_getterinfo.get() } },
246 },
247 setter: JSPropertySpec_Accessor {
248 native: JSNativeWrapper { op: Some(generic_setter), info: unsafe { href_setterinfo.get() } },
249 }
250 }
251 }
252 }
253,
254 JSPropertySpec::ZERO]))[..]
255,
256&Box::leak(Box::new([
257 JSPropertySpec {
258 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
259 attributes_: (JSPROP_READONLY),
260 kind_: (JSPropertySpec_Kind::Value),
261 u: JSPropertySpec_AccessorsOrValue {
262 value: JSPropertySpec_ValueWrapper {
263 type_: JSPropertySpec_ValueWrapper_Type::String,
264 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
265 string: c"HTMLBaseElement".as_ptr(),
266 }
267 }
268 }
269 }
270,
271 JSPropertySpec::ZERO]))[..]
272])));
273}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
274
275pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
276 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sAttributes_specs.get() })[0]),
277 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
278}
279pub fn GetProtoObject<D: DomTypes>
280(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
281 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::HTMLBaseElement), CreateInterfaceObjects::<D>, rval)
283}
284
285
286static PrototypeClass: JSClass = JSClass {
287 name: c"HTMLBaseElementPrototype".as_ptr(),
288 flags:
289 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
291 cOps: ptr::null(),
292 spec: ptr::null(),
293 ext: ptr::null(),
294 oOps: ptr::null(),
295};
296
297unsafe extern "C" fn _constructor<D: DomTypes>
298(cx: *mut RawJSContext, argc: u32, vp: *mut JSVal) -> bool{
299 let mut result = false;
300 wrap_panic(&mut || result = {
301 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
302 let args = CallArgs::from_vp(vp, argc);
303 let global = D::GlobalScope::from_object(JS_CALLEE(cx.raw_cx(), vp).to_object());
304
305 <D as DomHelpers<D>>::call_html_constructor::<D::HTMLBaseElement>(
306 SafeJSContext::from_ptr(cx.raw_cx()),
307 &args,
308 &global,
309 PrototypeList::ID::HTMLBaseElement,
310 CreateInterfaceObjects::<D>,
311 CanGc::note()
312 )
313
314 });
315 result
316}
317
318
319static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
320
321pub(crate) fn init_interface_object<D: DomTypes>() {
322 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
323 Box::leak(Box::new(InterfaceConstructorBehavior::call(_constructor::<D>))),
324 b"function HTMLBaseElement() {\n [native code]\n}",
325 PrototypeList::ID::HTMLBaseElement,
326 4,
327 ));
328}
329
330pub fn GetConstructorObject<D: DomTypes>
331(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
332 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::Constructor(PrototypeList::Constructor::HTMLBaseElement), CreateInterfaceObjects::<D>, rval)
334}
335
336pub fn DefineDOMInterface<D: DomTypes>
337(cx: SafeJSContext, global: HandleObject){
338 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::HTMLBaseElement),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
339}
340
341pub fn ConstructorEnabled<D: DomTypes>
342(aCx: SafeJSContext, aObj: HandleObject) -> bool{
343 is_exposed_in(aObj, Globals::WINDOW)
344}
345
346unsafe fn CreateInterfaceObjects<D: DomTypes>
347(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
348
349 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
350 HTMLElement_Binding::GetProtoObject::<D>(cx, global, prototype_proto.handle_mut());
351 assert!(!prototype_proto.is_null());
352
353 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
354 create_interface_prototype_object::<D>(cx,
355 global,
356 prototype_proto.handle(),
357 &PrototypeClass,
358 &[],
359 sAttributes.get(),
360 &[],
361 &[],
362 prototype.handle_mut());
363 assert!(!prototype.is_null());
364 assert!((*cache)[PrototypeList::ID::HTMLBaseElement as usize].is_null());
365 (*cache)[PrototypeList::ID::HTMLBaseElement as usize] = prototype.get();
366 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::HTMLBaseElement as isize),
367 ptr::null_mut(),
368 prototype.get());
369
370 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
371
372 HTMLElement_Binding::GetConstructorObject::<D>(cx, global, interface_proto.handle_mut());
373
374 assert!(!interface_proto.is_null());
375
376 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
377 create_noncallback_interface_object::<D>(cx,
378 global,
379 interface_proto.handle(),
380 INTERFACE_OBJECT_CLASS.get(),
381 &[],
382 &[],
383 &[],
384 prototype.handle(),
385 c"HTMLBaseElement",
386 0,
387 &[],
388 interface.handle_mut());
389 assert!(!interface.is_null());
390
391 assert!((*cache)[PrototypeList::Constructor::HTMLBaseElement as usize].is_null());
392 (*cache)[PrototypeList::Constructor::HTMLBaseElement as usize] = interface.get();
393 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::HTMLBaseElement as isize),
394 ptr::null_mut(),
395 interface.get());
396
397}
398
399
400 pub(crate) fn init_statics<D: DomTypes>() {
401 init_interface_object::<D>();
402 init_domjs_class::<D>();
403
404 init_href_getterinfo::<D>();
405 init_href_setterinfo::<D>();
406
407 init_sAttributes_specs::<D>();
408init_sAttributes_prefs::<D>();
409 }
410 }