diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs index 9785106c252..152601c4f71 100644 --- a/components/script/dom/vrdisplay.rs +++ b/components/script/dom/vrdisplay.rs @@ -74,6 +74,8 @@ pub struct VRDisplay { running_display_raf: Cell, paused: Cell, stopped_on_pause: Cell, + /// Whether or not this is XR mode + xr: Cell, } unsafe_no_jsmanaged_fields!(WebVRDisplayData); @@ -129,6 +131,7 @@ impl VRDisplay { // This flag is set when the Display was presenting when it received a VR Pause event. // When the VR Resume event is received and the flag is set, VR presentation automatically restarts. stopped_on_pause: Cell::new(false), + xr: Cell::new(false), } } @@ -551,8 +554,8 @@ impl VRDisplay { let this = address.clone(); let sender = raf_sender.clone(); let task = Box::new(task!(handle_vrdisplay_raf: move || { - this.root().handle_raf(&sender); - })); + this.root().handle_raf(&sender); + })); // NOTE: WebVR spec doesn't specify what task source we should use. Is // dom-manipulation a good choice long term? js_sender diff --git a/components/script/dom/webidls/XRSession.webidl b/components/script/dom/webidls/XRSession.webidl index 4945880697a..b0785764a18 100644 --- a/components/script/dom/webidls/XRSession.webidl +++ b/components/script/dom/webidls/XRSession.webidl @@ -18,7 +18,7 @@ enum XREnvironmentBlendMode { attribute double depthNear; attribute double depthFar; - // attribute XRLayer baseLayer; + attribute XRLayer? baseLayer; // // Methods // Promise requestReferenceSpace(XRReferenceSpaceType type, optional XRReferenceSpaceOptions options); diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs index bbb4626b5e8..40ccb90fbd3 100644 --- a/components/script/dom/xrsession.rs +++ b/components/script/dom/xrsession.rs @@ -7,10 +7,11 @@ use crate::dom::bindings::codegen::Bindings::XRSessionBinding; use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRSessionMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::reflect_dom_object; -use crate::dom::bindings::root::{Dom, DomRoot}; +use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::dom::vrdisplay::VRDisplay; +use crate::dom::xrlayer::XRLayer; use dom_struct::dom_struct; use std::cell::Cell; @@ -20,6 +21,7 @@ pub struct XRSession { display: Dom, depth_near: Cell, depth_far: Cell, + base_layer: MutNullableDom, } impl XRSession { @@ -29,6 +31,7 @@ impl XRSession { display: Dom::from_ref(display), depth_near: Cell::new(0.1), depth_far: Cell::new(1000.), + base_layer: Default::default(), } } @@ -61,4 +64,12 @@ impl XRSessionMethods for XRSession { fn Mode(&self) -> XRSessionMode { XRSessionMode::Immersive_vr } + + fn SetBaseLayer(&self, layer: Option<&XRLayer>) { + self.base_layer.set(layer) + } + + fn GetBaseLayer(&self) -> Option> { + self.base_layer.get() + } }