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