mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Update xr.requestSession() arguments
This commit is contained in:
parent
73f1bdac06
commit
df1f865cb2
5 changed files with 16 additions and 15 deletions
|
@ -6,8 +6,8 @@
|
|||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XR: EventTarget {
|
||||
// Methods
|
||||
Promise<void> supportsSessionMode(XRSessionMode mode);
|
||||
Promise<XRSession> requestSession(optional XRSessionCreationOptions parameters = {});
|
||||
Promise<void> supportsSession(XRSessionMode mode);
|
||||
Promise<XRSession> requestSession(XRSessionMode mode, optional XRSessionInit parameters = {});
|
||||
|
||||
// Events
|
||||
// attribute EventHandler ondevicechange;
|
||||
|
@ -24,9 +24,9 @@ enum XRSessionMode {
|
|||
"immersive-ar"
|
||||
};
|
||||
|
||||
dictionary XRSessionCreationOptions {
|
||||
XRSessionMode mode = "inline";
|
||||
// XRPresentationContext outputContext;
|
||||
dictionary XRSessionInit {
|
||||
sequence<DOMString> requiredFeatures;
|
||||
sequence<DOMString> optionalFeatures;
|
||||
};
|
||||
|
||||
partial interface XR {
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::compartments::InCompartment;
|
|||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::XRBinding;
|
||||
use crate::dom::bindings::codegen::Bindings::XRBinding::XRSessionCreationOptions;
|
||||
use crate::dom::bindings::codegen::Bindings::XRBinding::XRSessionInit;
|
||||
use crate::dom::bindings::codegen::Bindings::XRBinding::{XRMethods, XRSessionMode};
|
||||
use crate::dom::bindings::error::Error;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
|
@ -96,7 +96,7 @@ impl Into<SessionMode> for XRSessionMode {
|
|||
|
||||
impl XRMethods for XR {
|
||||
/// https://immersive-web.github.io/webxr/#dom-xr-supportssessionmode
|
||||
fn SupportsSessionMode(&self, mode: XRSessionMode, comp: InCompartment) -> Rc<Promise> {
|
||||
fn SupportsSession(&self, mode: XRSessionMode) -> Rc<Promise> {
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct SupportsSession {
|
||||
sender: IpcSender<bool>,
|
||||
|
@ -110,7 +110,7 @@ impl XRMethods for XR {
|
|||
}
|
||||
|
||||
// XXXManishearth this should select an XR device first
|
||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||
let promise = Promise::new(&self.global());
|
||||
let mut trusted = Some(TrustedPromise::new(promise.clone()));
|
||||
let global = self.global();
|
||||
let window = global.as_window();
|
||||
|
@ -152,7 +152,8 @@ impl XRMethods for XR {
|
|||
/// https://immersive-web.github.io/webxr/#dom-xr-requestsession
|
||||
fn RequestSession(
|
||||
&self,
|
||||
options: &XRSessionCreationOptions,
|
||||
mode: XRSessionMode,
|
||||
_: &XRSessionInit,
|
||||
comp: InCompartment,
|
||||
) -> Rc<Promise> {
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
|
@ -167,7 +168,7 @@ impl XRMethods for XR {
|
|||
}
|
||||
}
|
||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||
if options.mode != XRSessionMode::Immersive_vr {
|
||||
if mode != XRSessionMode::Immersive_vr {
|
||||
promise.reject_error(Error::NotSupported);
|
||||
return promise;
|
||||
}
|
||||
|
@ -210,7 +211,7 @@ impl XRMethods for XR {
|
|||
);
|
||||
window
|
||||
.webxr_registry()
|
||||
.request_session(options.mode.into(), RequestSession { sender });
|
||||
.request_session(mode.into(), RequestSession { sender });
|
||||
|
||||
promise
|
||||
}
|
||||
|
|
|
@ -19690,11 +19690,11 @@
|
|||
"testharness"
|
||||
],
|
||||
"webxr/create_session.html": [
|
||||
"ddec5add27b84e8e2febe3789d326f1e9fb7f508",
|
||||
"e68ea81893a65793094f9086cdd6d73800ee1c14",
|
||||
"testharness"
|
||||
],
|
||||
"webxr/obtain_frame.html": [
|
||||
"063008c7ebc0df9997b8286296b4f7fe4663b331",
|
||||
"39698805b476c7e469548d25ece59560a596604d",
|
||||
"testharness"
|
||||
],
|
||||
"webxr/resources/webxr-util.js": [
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
views: TEST_VIEWS,
|
||||
viewerOrigin: {position: [0.5, 0.1, 0.1], orientation: [1, 0, 0, 1] }
|
||||
}).then((m) => {
|
||||
return navigator.xr.requestSession({mode: "immersive-vr"})
|
||||
return navigator.xr.requestSession("immersive-vr")
|
||||
}).then(() => t.done());
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
views: TEST_VIEWS,
|
||||
viewerOrigin: {position: [0.5, 0.1, 0.1], orientation: [1, 0, 0, 1] }
|
||||
});
|
||||
let session = await navigator.xr.requestSession({mode: "immersive-vr"});
|
||||
let session = await navigator.xr.requestSession("immersive-vr");
|
||||
await session.updateRenderState({"baseLayer": new XRWebGLLayer(session, gl, {})});
|
||||
let resolve;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue