Skip to content
Permalink
Browse files

Consistently use GlobalScope in XR code

  • Loading branch information...
Manishearth committed Apr 3, 2019
1 parent f7745ed commit fcec93ae162798274576ff3b4d3c7310dd9fb3e3
@@ -27,7 +27,7 @@ impl XRPose {

#[allow(unused)]
pub fn new(global: &GlobalScope, transform: RigidTransform3D<f64>) -> DomRoot<XRPose> {
let transform = XRRigidTransform::new(&global.as_window(), transform);
let transform = XRRigidTransform::new(global, transform);
reflect_dom_object(
Box::new(XRPose::new_inherited(&transform)),
global,
@@ -7,7 +7,7 @@ use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding::XRReferenc
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::root::{DomRoot, MutDom};
use crate::dom::window::Window;
use crate::dom::globalscope::GlobalScope;
use crate::dom::xrrigidtransform::XRRigidTransform;
use crate::dom::xrsession::XRSession;
use crate::dom::xrspace::XRSpace;
@@ -31,7 +31,7 @@ impl XRReferenceSpace {
}

#[allow(unused)]
pub fn identity(global: &Window, session: &XRSession) -> DomRoot<XRReferenceSpace> {
pub fn identity(global: &GlobalScope, session: &XRSession) -> DomRoot<XRReferenceSpace> {
let transform = XRRigidTransform::identity(global);
reflect_dom_object(
Box::new(XRReferenceSpace::new_inherited(session, &transform)),
@@ -11,6 +11,7 @@ use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
use crate::dom::dompointreadonly::DOMPointReadOnly;
use crate::dom::globalscope::GlobalScope;
use crate::dom::window::Window;
use dom_struct::dom_struct;
use euclid::{RigidTransform3D, Rotation3D, Vector3D};
@@ -34,15 +35,18 @@ impl XRRigidTransform {
}
}

pub fn new(global: &Window, transform: RigidTransform3D<f64>) -> DomRoot<XRRigidTransform> {
pub fn new(
global: &GlobalScope,
transform: RigidTransform3D<f64>,
) -> DomRoot<XRRigidTransform> {
reflect_dom_object(
Box::new(XRRigidTransform::new_inherited(transform)),
global,
XRRigidTransformBinding::Wrap,
)
}

pub fn identity(window: &Window) -> DomRoot<XRRigidTransform> {
pub fn identity(window: &GlobalScope) -> DomRoot<XRRigidTransform> {
let transform = RigidTransform3D::identity();
XRRigidTransform::new(window, transform)
}
@@ -68,7 +72,7 @@ impl XRRigidTransform {
orientation.w as f64,
);
let transform = RigidTransform3D::new(rotate, translate);
Ok(XRRigidTransform::new(window, transform))
Ok(XRRigidTransform::new(&window.global(), transform))
}
}

@@ -89,8 +93,7 @@ impl XRRigidTransformMethods for XRRigidTransform {
}
// https://immersive-web.github.io/webxr/#dom-xrrigidtransform-inverse
fn Inverse(&self) -> DomRoot<XRRigidTransform> {
let global = self.global();
XRRigidTransform::new(global.as_window(), self.transform.inverse())
XRRigidTransform::new(&self.global(), self.transform.inverse())
}
}

@@ -115,15 +115,12 @@ impl XRSessionMethods for XRSession {

match options.type_ {
XRReferenceSpaceType::Identity => {
p.resolve_native(&XRReferenceSpace::identity(
&self.global().as_window(),
self,
));
p.resolve_native(&XRReferenceSpace::identity(&self.global(), self));
},
XRReferenceSpaceType::Stationary => {
if let Some(subtype) = options.subtype {
p.resolve_native(&XRStationaryReferenceSpace::new(
&self.global().as_window(),
&self.global(),
self,
subtype,
));
@@ -6,7 +6,7 @@ use crate::dom::bindings::codegen::Bindings::XRStationaryReferenceSpaceBinding;
use crate::dom::bindings::codegen::Bindings::XRStationaryReferenceSpaceBinding::XRStationaryReferenceSpaceSubtype;
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::root::DomRoot;
use crate::dom::window::Window;
use crate::dom::globalscope::GlobalScope;
use crate::dom::xrreferencespace::XRReferenceSpace;
use crate::dom::xrrigidtransform::XRRigidTransform;
use crate::dom::xrsession::XRSession;
@@ -34,16 +34,16 @@ impl XRStationaryReferenceSpace {
}

pub fn new(
window: &Window,
global: &GlobalScope,
session: &XRSession,
ty: XRStationaryReferenceSpaceSubtype,
) -> DomRoot<XRStationaryReferenceSpace> {
let transform = XRRigidTransform::identity(window);
let transform = XRRigidTransform::identity(global);
reflect_dom_object(
Box::new(XRStationaryReferenceSpace::new_inherited(
session, ty, &transform,
)),
window,
global,
XRStationaryReferenceSpaceBinding::Wrap,
)
}
@@ -42,7 +42,7 @@ impl XRViewerPose {
) -> DomRoot<XRViewerPose> {
let left = XRView::new(global, session, XREye::Left, &pose, &data);
let right = XRView::new(global, session, XREye::Right, &pose, &data);
let transform = XRRigidTransform::new(&global.as_window(), pose);
let transform = XRRigidTransform::new(global, pose);
let pose = reflect_dom_object(
Box::new(XRViewerPose::new_inherited(&transform)),
global,

0 comments on commit fcec93a

Please sign in to comment.
You can’t perform that action at this time.