use std::marker::PhantomData;
use dom_struct::dom_struct;
use js::context::JSContext;
use malloc_size_of_derive::MallocSizeOf;
use script_bindings::DomTypes;
use script_bindings::codegen::GenericBindings::WebGPUBinding::{
GPUDeviceLostInfoMethods, GPUDeviceLostInfoWrap, GPUDeviceLostReason,
};
use script_bindings::reflector::{Reflector, reflect_dom_object_with_wrap};
use crate::JSTraceable;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
#[dom_struct]
pub struct GPUDeviceLostInfo<D: DomTypes> {
reflector_: Reflector,
message: DOMString,
reason: GPUDeviceLostReason,
#[no_trace = "PhantomData does not exist"]
phantom: PhantomData<D>,
}
impl<D> GPUDeviceLostInfo<D>
where
D: DomTypes<GPUDeviceLostInfo = GPUDeviceLostInfo<D>>,
{
fn new_inherited(message: DOMString, reason: GPUDeviceLostReason) -> Self {
Self {
reflector_: Reflector::new(),
message,
reason,
phantom: PhantomData,
}
}
pub fn new(
cx: &mut JSContext,
global: &D::GlobalScope,
message: DOMString,
reason: GPUDeviceLostReason,
) -> DomRoot<Self> {
reflect_dom_object_with_wrap::<D, _, _>(
Box::new(GPUDeviceLostInfo::new_inherited(message, reason)),
global,
cx,
GPUDeviceLostInfoWrap::<D>,
)
}
}
impl<D: DomTypes> GPUDeviceLostInfoMethods<D> for GPUDeviceLostInfo<D> {
fn Message(&self) -> DOMString {
self.message.clone()
}
fn Reason(&self) -> GPUDeviceLostReason {
self.reason
}
}