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::StyleSheetBinding::StyleSheet_Binding;
6use crate::import::base::*;
7
8pub use self::CSSRule_Binding::{CSSRuleConstants, CSSRuleMethods, GetProtoObject, GetConstructorObject, DefineDOMInterface};
9pub mod CSSRule_Binding {
10use crate::codegen::GenericBindings::StyleSheetBinding::StyleSheet_Binding;
11use crate::import::module::*;
12
13unsafe extern "C" fn get_type<D: DomTypes>
14(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
15 let mut result = false;
16 wrap_panic(&mut || result = (|| {
17 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
18 let this = &*(this as *const D::CSSRule);
19 let result: u16 = this.Type();
20
21 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
22 return true;
23 })());
24 result
25}
26
27
28static type_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
29
30pub(crate) fn init_type_getterinfo<D: DomTypes>() {
31 type_getterinfo.set(JSJitInfo {
32 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
33 getter: Some(get_type::<D>)
34 },
35 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
36 protoID: PrototypeList::ID::CSSRule as u16,
37 },
38 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
39 _bitfield_align_1: [],
40 _bitfield_1: __BindgenBitfieldUnit::new(
41 new_jsjitinfo_bitfield_1!(
42 JSJitInfo_OpType::Getter as u8,
43 JSJitInfo_AliasSet::AliasEverything as u8,
44 JSValueType::JSVAL_TYPE_INT32 as u8,
45 true,
46 false,
47 false,
48 false,
49 false,
50 false,
51 0,
52 ).to_ne_bytes()
53 ),
54});
55}
56unsafe extern "C" fn get_cssText<D: DomTypes>
57(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
58 let mut result = false;
59 wrap_panic(&mut || result = (|| {
60 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
61 let this = &*(this as *const D::CSSRule);
62 let result: DOMString = this.CssText();
63
64 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
65 return true;
66 })());
67 result
68}
69
70unsafe extern "C" fn set_cssText<D: DomTypes>
71(cx: *mut RawJSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool{
72 let mut result = false;
73 wrap_panic(&mut || result = (|| {
74 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
75 let this = &*(this as *const D::CSSRule);
76 let arg0: DOMString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
77 Ok(ConversionResult::Success(value)) => value,
78 Ok(ConversionResult::Failure(error)) => {
79 throw_type_error(cx.raw_cx(), &error);
80 return false;
81
82 }
83 _ => {
84 return false;
85
86 },
87 }
88 ;
89 let result: () = this.SetCssText(arg0);
90
91 true
92 })());
93 result
94}
95
96
97static cssText_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
98
99pub(crate) fn init_cssText_getterinfo<D: DomTypes>() {
100 cssText_getterinfo.set(JSJitInfo {
101 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
102 getter: Some(get_cssText::<D>)
103 },
104 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
105 protoID: PrototypeList::ID::CSSRule as u16,
106 },
107 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
108 _bitfield_align_1: [],
109 _bitfield_1: __BindgenBitfieldUnit::new(
110 new_jsjitinfo_bitfield_1!(
111 JSJitInfo_OpType::Getter as u8,
112 JSJitInfo_AliasSet::AliasEverything as u8,
113 JSValueType::JSVAL_TYPE_STRING as u8,
114 true,
115 false,
116 false,
117 false,
118 false,
119 false,
120 0,
121 ).to_ne_bytes()
122 ),
123});
124}
125static cssText_setterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
126
127pub(crate) fn init_cssText_setterinfo<D: DomTypes>() {
128 cssText_setterinfo.set(JSJitInfo {
129 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
130 setter: Some(set_cssText::<D>)
131 },
132 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
133 protoID: PrototypeList::ID::CSSRule as u16,
134 },
135 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
136 _bitfield_align_1: [],
137 _bitfield_1: __BindgenBitfieldUnit::new(
138 new_jsjitinfo_bitfield_1!(
139 JSJitInfo_OpType::Setter as u8,
140 JSJitInfo_AliasSet::AliasEverything as u8,
141 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
142 false,
143 false,
144 false,
145 false,
146 false,
147 false,
148 0,
149 ).to_ne_bytes()
150 ),
151});
152}
153unsafe extern "C" fn get_parentStyleSheet<D: DomTypes>
154(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
155 let mut result = false;
156 wrap_panic(&mut || result = (|| {
157 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
158 let this = &*(this as *const D::CSSRule);
159 let result: Option<DomRoot<D::CSSStyleSheet>> = this.GetParentStyleSheet();
160
161 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
162 return true;
163 })());
164 result
165}
166
167
168static parentStyleSheet_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
169
170pub(crate) fn init_parentStyleSheet_getterinfo<D: DomTypes>() {
171 parentStyleSheet_getterinfo.set(JSJitInfo {
172 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
173 getter: Some(get_parentStyleSheet::<D>)
174 },
175 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
176 protoID: PrototypeList::ID::CSSRule as u16,
177 },
178 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
179 _bitfield_align_1: [],
180 _bitfield_1: __BindgenBitfieldUnit::new(
181 new_jsjitinfo_bitfield_1!(
182 JSJitInfo_OpType::Getter as u8,
183 JSJitInfo_AliasSet::AliasEverything as u8,
184 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
185 true,
186 false,
187 false,
188 false,
189 false,
190 false,
191 0,
192 ).to_ne_bytes()
193 ),
194});
195}
196pub mod CSSRuleConstants {
197 pub const STYLE_RULE: u16 = 1;
198 pub const CHARSET_RULE: u16 = 2;
199 pub const IMPORT_RULE: u16 = 3;
200 pub const MEDIA_RULE: u16 = 4;
201 pub const FONT_FACE_RULE: u16 = 5;
202 pub const PAGE_RULE: u16 = 6;
203 pub const MARGIN_RULE: u16 = 9;
204 pub const NAMESPACE_RULE: u16 = 10;
205 pub const KEYFRAMES_RULE: u16 = 7;
206 pub const KEYFRAME_RULE: u16 = 8;
207 pub const SUPPORTS_RULE: u16 = 12;
208} pub trait CSSRuleMethods<D: DomTypes> {
210 fn Type(&self, ) -> u16;
211 fn CssText(&self, ) -> DOMString;
212 fn SetCssText(&self, r#value: DOMString);
213 fn GetParentStyleSheet(&self, ) -> Option<DomRoot<D::CSSStyleSheet>>;
214}
215static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
216
217pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
218 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
219 JSPropertySpec {
220 name: JSPropertySpec_Name { string_: c"type".as_ptr() },
221 attributes_: (JSPROP_ENUMERATE),
222 kind_: (JSPropertySpec_Kind::NativeAccessor),
223 u: JSPropertySpec_AccessorsOrValue {
224 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
225 getter: JSPropertySpec_Accessor {
226 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { type_getterinfo.get() } },
227 },
228 setter: JSPropertySpec_Accessor {
229 native: JSNativeWrapper { op: None, info: ptr::null() },
230 }
231 }
232 }
233 }
234,
235 JSPropertySpec {
236 name: JSPropertySpec_Name { string_: c"cssText".as_ptr() },
237 attributes_: (JSPROP_ENUMERATE),
238 kind_: (JSPropertySpec_Kind::NativeAccessor),
239 u: JSPropertySpec_AccessorsOrValue {
240 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
241 getter: JSPropertySpec_Accessor {
242 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { cssText_getterinfo.get() } },
243 },
244 setter: JSPropertySpec_Accessor {
245 native: JSNativeWrapper { op: Some(generic_setter), info: unsafe { cssText_setterinfo.get() } },
246 }
247 }
248 }
249 }
250,
251 JSPropertySpec {
252 name: JSPropertySpec_Name { string_: c"parentStyleSheet".as_ptr() },
253 attributes_: (JSPROP_ENUMERATE),
254 kind_: (JSPropertySpec_Kind::NativeAccessor),
255 u: JSPropertySpec_AccessorsOrValue {
256 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
257 getter: JSPropertySpec_Accessor {
258 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { parentStyleSheet_getterinfo.get() } },
259 },
260 setter: JSPropertySpec_Accessor {
261 native: JSNativeWrapper { op: None, info: ptr::null() },
262 }
263 }
264 }
265 }
266,
267 JSPropertySpec::ZERO]))[..]
268,
269&Box::leak(Box::new([
270 JSPropertySpec {
271 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
272 attributes_: (JSPROP_READONLY),
273 kind_: (JSPropertySpec_Kind::Value),
274 u: JSPropertySpec_AccessorsOrValue {
275 value: JSPropertySpec_ValueWrapper {
276 type_: JSPropertySpec_ValueWrapper_Type::String,
277 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
278 string: c"CSSRule".as_ptr(),
279 }
280 }
281 }
282 }
283,
284 JSPropertySpec::ZERO]))[..]
285])));
286}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
287
288pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
289 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sAttributes_specs.get() })[0]),
290 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
291}static sConstants_specs: ThreadUnsafeOnceLock<&[&[ConstantSpec]]> = ThreadUnsafeOnceLock::new();
292
293pub(crate) fn init_sConstants_specs<D: DomTypes>() {
294 sConstants_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
295 ConstantSpec { name: c"STYLE_RULE", value: ConstantVal::Int(1) },
296 ConstantSpec { name: c"CHARSET_RULE", value: ConstantVal::Int(2) },
297 ConstantSpec { name: c"IMPORT_RULE", value: ConstantVal::Int(3) },
298 ConstantSpec { name: c"MEDIA_RULE", value: ConstantVal::Int(4) },
299 ConstantSpec { name: c"FONT_FACE_RULE", value: ConstantVal::Int(5) },
300 ConstantSpec { name: c"PAGE_RULE", value: ConstantVal::Int(6) },
301 ConstantSpec { name: c"MARGIN_RULE", value: ConstantVal::Int(9) },
302 ConstantSpec { name: c"NAMESPACE_RULE", value: ConstantVal::Int(10) },
303 ConstantSpec { name: c"KEYFRAMES_RULE", value: ConstantVal::Int(7) },
304 ConstantSpec { name: c"KEYFRAME_RULE", value: ConstantVal::Int(8) },
305 ConstantSpec { name: c"SUPPORTS_RULE", value: ConstantVal::Int(12) }]))[..]
306])));
307}static sConstants: ThreadUnsafeOnceLock<&[Guard<&[ConstantSpec]>]> = ThreadUnsafeOnceLock::new();
308
309pub(crate) fn init_sConstants_prefs<D: DomTypes>() {
310 sConstants.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sConstants_specs.get() })[0])])));
311}
312pub fn GetProtoObject<D: DomTypes>
313(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
314 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::CSSRule), CreateInterfaceObjects::<D>, rval)
316}
317
318
319static PrototypeClass: JSClass = JSClass {
320 name: c"CSSRulePrototype".as_ptr(),
321 flags:
322 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
324 cOps: ptr::null(),
325 spec: ptr::null(),
326 ext: ptr::null(),
327 oOps: ptr::null(),
328};
329
330
331static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
332
333pub(crate) fn init_interface_object<D: DomTypes>() {
334 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
335 Box::leak(Box::new(InterfaceConstructorBehavior::throw())),
336 b"function CSSRule() {\n [native code]\n}",
337 PrototypeList::ID::CSSRule,
338 0,
339 ));
340}
341
342pub fn GetConstructorObject<D: DomTypes>
343(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
344 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::Constructor(PrototypeList::Constructor::CSSRule), CreateInterfaceObjects::<D>, rval)
346}
347
348pub fn DefineDOMInterface<D: DomTypes>
349(cx: SafeJSContext, global: HandleObject){
350 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::CSSRule),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
351}
352
353pub fn ConstructorEnabled<D: DomTypes>
354(aCx: SafeJSContext, aObj: HandleObject) -> bool{
355 is_exposed_in(aObj, Globals::WINDOW)
356}
357
358unsafe fn CreateInterfaceObjects<D: DomTypes>
359(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
360
361 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
362 prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
363 assert!(!prototype_proto.is_null());
364
365 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
366 create_interface_prototype_object::<D>(cx,
367 global,
368 prototype_proto.handle(),
369 &PrototypeClass,
370 &[],
371 sAttributes.get(),
372 sConstants.get(),
373 &[],
374 prototype.handle_mut());
375 assert!(!prototype.is_null());
376 assert!((*cache)[PrototypeList::ID::CSSRule as usize].is_null());
377 (*cache)[PrototypeList::ID::CSSRule as usize] = prototype.get();
378 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::CSSRule as isize),
379 ptr::null_mut(),
380 prototype.get());
381
382 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
383 interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
384
385 assert!(!interface_proto.is_null());
386
387 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
388 create_noncallback_interface_object::<D>(cx,
389 global,
390 interface_proto.handle(),
391 INTERFACE_OBJECT_CLASS.get(),
392 &[],
393 &[],
394 sConstants.get(),
395 prototype.handle(),
396 c"CSSRule",
397 0,
398 &[],
399 interface.handle_mut());
400 assert!(!interface.is_null());
401
402 assert!((*cache)[PrototypeList::Constructor::CSSRule as usize].is_null());
403 (*cache)[PrototypeList::Constructor::CSSRule as usize] = interface.get();
404 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::CSSRule as isize),
405 ptr::null_mut(),
406 interface.get());
407
408}
409
410
411 pub(crate) fn init_statics<D: DomTypes>() {
412 init_interface_object::<D>();
413
414
415 init_type_getterinfo::<D>();
416init_cssText_getterinfo::<D>();
417init_parentStyleSheet_getterinfo::<D>();
418 init_cssText_setterinfo::<D>();
419
420 init_sAttributes_specs::<D>();
421init_sAttributes_prefs::<D>();
422init_sConstants_specs::<D>();
423init_sConstants_prefs::<D>();
424 }
425 }