use dom_struct::dom_struct;
use euclid::Rect;
use webxr_api::Viewport;
use crate::dom::bindings::codegen::Bindings::XRViewportBinding::XRViewportMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::globalscope::GlobalScope;
use crate::script_runtime::CanGc;
#[dom_struct]
pub struct XRViewport {
reflector_: Reflector,
#[no_trace]
viewport: Rect<i32, Viewport>,
}
impl XRViewport {
fn new_inherited(viewport: Rect<i32, Viewport>) -> XRViewport {
XRViewport {
reflector_: Reflector::new(),
viewport,
}
}
pub fn new(global: &GlobalScope, viewport: Rect<i32, Viewport>) -> DomRoot<XRViewport> {
reflect_dom_object(
Box::new(XRViewport::new_inherited(viewport)),
global,
CanGc::note(),
)
}
}
impl XRViewportMethods<crate::DomTypeHolder> for XRViewport {
fn X(&self) -> i32 {
self.viewport.origin.x
}
fn Y(&self) -> i32 {
self.viewport.origin.y
}
fn Width(&self) -> i32 {
self.viewport.size.width
}
fn Height(&self) -> i32 {
self.viewport.size.height
}
}