webxr: Add missing IDL members from AR Module (#33007)

* Add missing IDL members from AR module

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Update test expectations

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* ./mach fmt

Signed-off-by: Daniel Adams <msub2official@gmail.com>

---------

Signed-off-by: Daniel Adams <msub2official@gmail.com>
This commit is contained in:
Daniel Adams 2024-08-12 18:28:40 -10:00 committed by GitHub
parent 4744debdfd
commit 0d137d276a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 35 additions and 29 deletions

View file

@ -16,18 +16,21 @@ enum XRVisibilityState {
"hidden", "hidden",
}; };
enum XRInteractionMode {
"screen-space",
"world-space",
};
callback XRFrameRequestCallback = undefined (DOMHighResTimeStamp time, XRFrame frame); callback XRFrameRequestCallback = undefined (DOMHighResTimeStamp time, XRFrame frame);
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"] [SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
interface XRSession : EventTarget { interface XRSession : EventTarget {
// // Attributes // Attributes
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;
// // Methods // Methods
[Throws] undefined updateRenderState(optional XRRenderStateInit state = {}); [Throws] undefined updateRenderState(optional XRRenderStateInit state = {});
Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceType type); Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceType type);
@ -36,10 +39,7 @@ interface XRSession : EventTarget {
Promise<undefined> end(); Promise<undefined> end();
// hit test module // Events
Promise<XRHitTestSource> requestHitTestSource(XRHitTestOptionsInit options);
// // Events
attribute EventHandler onend; attribute EventHandler onend;
attribute EventHandler onselect; attribute EventHandler onselect;
attribute EventHandler onsqueeze; attribute EventHandler onsqueeze;
@ -49,4 +49,13 @@ interface XRSession : EventTarget {
attribute EventHandler onsqueezestart; attribute EventHandler onsqueezestart;
attribute EventHandler onsqueezeend; attribute EventHandler onsqueezeend;
attribute EventHandler onvisibilitychange; attribute EventHandler onvisibilitychange;
// AR Module
// Attributes
readonly attribute XREnvironmentBlendMode environmentBlendMode;
readonly attribute XRInteractionMode interactionMode;
// Hit Test Module
// Methods
Promise<XRHitTestSource> requestHitTestSource(XRHitTestOptionsInit options);
}; };

View file

@ -15,4 +15,7 @@ interface XRView {
readonly attribute XREye eye; readonly attribute XREye eye;
readonly attribute Float32Array projectionMatrix; readonly attribute Float32Array projectionMatrix;
readonly attribute XRRigidTransform transform; readonly attribute XRRigidTransform transform;
// AR Module
readonly attribute boolean isFirstPersonObserver;
}; };

View file

@ -33,7 +33,8 @@ use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::{
XRRenderStateInit, XRRenderStateMethods, XRRenderStateInit, XRRenderStateMethods,
}; };
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::{ use crate::dom::bindings::codegen::Bindings::XRSessionBinding::{
XREnvironmentBlendMode, XRFrameRequestCallback, XRSessionMethods, XRVisibilityState, XREnvironmentBlendMode, XRFrameRequestCallback, XRInteractionMode, XRSessionMethods,
XRVisibilityState,
}; };
use crate::dom::bindings::codegen::Bindings::XRSystemBinding::XRSessionMode; use crate::dom::bindings::codegen::Bindings::XRSystemBinding::XRSessionMode;
use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::error::{Error, ErrorResult};
@ -873,6 +874,13 @@ impl XRSessionMethods for XRSession {
p p
} }
/// <https://www.w3.org/TR/webxr-ar-module-1/#dom-xrsession-interactionmode>
fn InteractionMode(&self) -> XRInteractionMode {
// Until Servo supports WebXR sessions on mobile phones or similar non-XR devices,
// this should always be world space
XRInteractionMode::World_space
}
} }
// The pose of an object in native-space. Should never be exposed. // The pose of an object in native-space. Should never be exposed.

View file

@ -106,4 +106,10 @@ impl XRViewMethods for XRView {
fn Transform(&self) -> DomRoot<XRRigidTransform> { fn Transform(&self) -> DomRoot<XRRigidTransform> {
DomRoot::from_ref(&self.transform) DomRoot::from_ref(&self.transform)
} }
/// <https://www.w3.org/TR/webxr-ar-module-1/#dom-xrview-isfirstpersonobserver>
fn IsFirstPersonObserver(&self) -> bool {
// Servo is not currently supported anywhere that supports this, so return false
false
}
} }

View file

@ -1,7 +1,4 @@
[idlharness.https.window.html] [idlharness.https.window.html]
[XRSession interface: attribute interactionMode]
expected: FAIL
[idl_test setup] [idl_test setup]
expected: FAIL expected: FAIL
@ -10,7 +7,3 @@
[XRSession interface: xrSession must inherit property "interactionMode" with the proper type] [XRSession interface: xrSession must inherit property "interactionMode" with the proper type]
expected: FAIL expected: FAIL
[XRView interface: attribute isFirstPersonObserver]
expected: FAIL

View file

@ -8,12 +8,6 @@
[Tests interactionMode for an AR_SCREEN_DEVICE] [Tests interactionMode for an AR_SCREEN_DEVICE]
expected: FAIL expected: FAIL
[Tests interactionMode for an AR_HMD_DEVICE]
expected: FAIL
[Tests interactionMode for an VR_HMD_DEVICE]
expected: FAIL
[Tests interactionMode for an AR_HMD_DEVICE - webgl] [Tests interactionMode for an AR_HMD_DEVICE - webgl]
expected: FAIL expected: FAIL

View file

@ -1,7 +1,4 @@
[idlharness.https.window.html] [idlharness.https.window.html]
[XRSession interface: attribute interactionMode]
expected: FAIL
[idl_test setup] [idl_test setup]
expected: FAIL expected: FAIL
@ -10,7 +7,3 @@
[XRSession interface: xrSession must inherit property "interactionMode" with the proper type] [XRSession interface: xrSession must inherit property "interactionMode" with the proper type]
expected: FAIL expected: FAIL
[XRView interface: attribute isFirstPersonObserver]
expected: FAIL