mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Expose XRSession.visibilityState
This commit is contained in:
parent
26b2f02210
commit
75c763120f
3 changed files with 15 additions and 4 deletions
|
@ -10,6 +10,12 @@ enum XREnvironmentBlendMode {
|
|||
"alpha-blend",
|
||||
};
|
||||
|
||||
enum XRVisibilityState {
|
||||
"visible",
|
||||
"visible-blurred",
|
||||
"hidden",
|
||||
};
|
||||
|
||||
callback XRFrameRequestCallback = void (DOMHighResTimeStamp time, XRFrame frame);
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
@ -17,7 +23,7 @@ interface XRSession : EventTarget {
|
|||
// // Attributes
|
||||
readonly attribute XREnvironmentBlendMode environmentBlendMode;
|
||||
|
||||
// readonly attribute XRVisibilityState visibilityState;
|
||||
readonly attribute XRVisibilityState visibilityState;
|
||||
[SameObject] readonly attribute XRRenderState renderState;
|
||||
[SameObject] readonly attribute XRInputSourceArray inputSources;
|
||||
|
||||
|
|
|
@ -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::XRFrameRequestCallback;
|
||||
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::error::{Error, ErrorResult};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
|
@ -55,6 +56,7 @@ pub struct XRSession {
|
|||
eventtarget: EventTarget,
|
||||
base_layer: MutNullableDom<XRWebGLLayer>,
|
||||
blend_mode: XREnvironmentBlendMode,
|
||||
visibility_state: Cell<XRVisibilityState>,
|
||||
viewer_space: MutNullableDom<XRSpace>,
|
||||
#[ignore_malloc_size_of = "defined in webxr"]
|
||||
session: DomRefCell<Session>,
|
||||
|
@ -85,6 +87,7 @@ impl XRSession {
|
|||
eventtarget: EventTarget::new_inherited(),
|
||||
base_layer: Default::default(),
|
||||
blend_mode: session.environment_blend_mode().into(),
|
||||
visibility_state: Cell::new(XRVisibilityState::Visible),
|
||||
viewer_space: Default::default(),
|
||||
session: DomRefCell::new(session),
|
||||
frame_requested: Cell::new(false),
|
||||
|
@ -405,6 +408,11 @@ impl XRSessionMethods for XRSession {
|
|||
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
|
||||
fn RequestReferenceSpace(&self, ty: XRReferenceSpaceType, comp: InCompartment) -> Rc<Promise> {
|
||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue