Expose XRSession.visibilityState

This commit is contained in:
Manish Goregaokar 2019-10-11 13:11:35 -07:00
parent 26b2f02210
commit 75c763120f
3 changed files with 15 additions and 4 deletions

View file

@ -10,6 +10,12 @@ enum XREnvironmentBlendMode {
"alpha-blend", "alpha-blend",
}; };
enum XRVisibilityState {
"visible",
"visible-blurred",
"hidden",
};
callback XRFrameRequestCallback = void (DOMHighResTimeStamp time, XRFrame frame); callback XRFrameRequestCallback = void (DOMHighResTimeStamp time, XRFrame frame);
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"] [SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
@ -17,7 +23,7 @@ interface XRSession : EventTarget {
// // Attributes // // Attributes
readonly attribute XREnvironmentBlendMode environmentBlendMode; readonly attribute XREnvironmentBlendMode environmentBlendMode;
// readonly attribute XRVisibilityState visibilityState; readonly attribute XRVisibilityState visibilityState;
[SameObject] readonly attribute XRRenderState renderState; [SameObject] readonly attribute XRRenderState renderState;
[SameObject] readonly attribute XRInputSourceArray inputSources; [SameObject] readonly attribute XRInputSourceArray inputSources;

View file

@ -16,6 +16,7 @@ use crate::dom::bindings::codegen::Bindings::XRSessionBinding;
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XREnvironmentBlendMode; use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XREnvironmentBlendMode;
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRFrameRequestCallback; use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRFrameRequestCallback;
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRSessionMethods; use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRSessionMethods;
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRVisibilityState;
use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerMethods; use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerMethods;
use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::error::{Error, ErrorResult};
use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::inheritance::Castable;
@ -55,6 +56,7 @@ pub struct XRSession {
eventtarget: EventTarget, eventtarget: EventTarget,
base_layer: MutNullableDom<XRWebGLLayer>, base_layer: MutNullableDom<XRWebGLLayer>,
blend_mode: XREnvironmentBlendMode, blend_mode: XREnvironmentBlendMode,
visibility_state: Cell<XRVisibilityState>,
viewer_space: MutNullableDom<XRSpace>, viewer_space: MutNullableDom<XRSpace>,
#[ignore_malloc_size_of = "defined in webxr"] #[ignore_malloc_size_of = "defined in webxr"]
session: DomRefCell<Session>, session: DomRefCell<Session>,
@ -85,6 +87,7 @@ impl XRSession {
eventtarget: EventTarget::new_inherited(), eventtarget: EventTarget::new_inherited(),
base_layer: Default::default(), base_layer: Default::default(),
blend_mode: session.environment_blend_mode().into(), blend_mode: session.environment_blend_mode().into(),
visibility_state: Cell::new(XRVisibilityState::Visible),
viewer_space: Default::default(), viewer_space: Default::default(),
session: DomRefCell::new(session), session: DomRefCell::new(session),
frame_requested: Cell::new(false), frame_requested: Cell::new(false),
@ -405,6 +408,11 @@ impl XRSessionMethods for XRSession {
self.blend_mode self.blend_mode
} }
/// https://immersive-web.github.io/webxr/#dom-xrsession-visibilitystate
fn VisibilityState(&self) -> XRVisibilityState {
self.visibility_state.get()
}
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestreferencespace /// https://immersive-web.github.io/webxr/#dom-xrsession-requestreferencespace
fn RequestReferenceSpace(&self, ty: XRReferenceSpaceType, comp: InCompartment) -> Rc<Promise> { fn RequestReferenceSpace(&self, ty: XRReferenceSpaceType, comp: InCompartment) -> Rc<Promise> {
let p = Promise::new_in_current_compartment(&self.global(), comp); let p = Promise::new_in_current_compartment(&self.global(), comp);

View file

@ -143,9 +143,6 @@
[XRBoundedReferenceSpace interface object name] [XRBoundedReferenceSpace interface object name]
expected: FAIL expected: FAIL
[XRSession interface: attribute visibilityState]
expected: FAIL
[XRWebGLLayer interface: attribute ignoreDepthValues] [XRWebGLLayer interface: attribute ignoreDepthValues]
expected: FAIL expected: FAIL