diff --git a/components/script/dom/webidls/XRFrame.webidl b/components/script/dom/webidls/XRFrame.webidl index 4512f084954..8279b380efb 100644 --- a/components/script/dom/webidls/XRFrame.webidl +++ b/components/script/dom/webidls/XRFrame.webidl @@ -6,10 +6,11 @@ [SecureContext, Exposed=Window, Pref="dom.webxr.enabled"] interface XRFrame { - readonly attribute XRSession session; + [SameObject] readonly attribute XRSession session; + readonly attribute DOMHighResTimeStamp predictedDisplayTime; [Throws] XRViewerPose? getViewerPose(XRReferenceSpace referenceSpace); - [Throws] XRPose? getPose(XRSpace space, XRSpace relativeTo); + [Throws] XRPose? getPose(XRSpace space, XRSpace baseSpace); // WebXR Hand Input [Pref="dom.webxr.hands.enabled", Throws] diff --git a/components/script/dom/xrframe.rs b/components/script/dom/xrframe.rs index 4818752109c..8c3ac5e80e9 100644 --- a/components/script/dom/xrframe.rs +++ b/components/script/dom/xrframe.rs @@ -12,6 +12,7 @@ use webxr_api::{Frame, LayerId, SubImages}; use crate::dom::bindings::codegen::Bindings::XRFrameBinding::XRFrameMethods; use crate::dom::bindings::error::Error; use crate::dom::bindings::inheritance::Castable; +use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::globalscope::GlobalScope; @@ -79,6 +80,14 @@ impl XRFrameMethods for XRFrame { DomRoot::from_ref(&self.session) } + /// + fn PredictedDisplayTime(&self) -> Finite { + // TODO: If inline, return the same value + // as the timestamp passed to XRFrameRequestCallback + Finite::new(self.data.predicted_display_time) + .expect("Failed to create predictedDisplayTime") + } + /// fn GetViewerPose( &self, @@ -114,9 +123,9 @@ impl XRFrameMethods for XRFrame { fn GetPose( &self, space: &XRSpace, - relative_to: &XRSpace, + base_space: &XRSpace, ) -> Result>, Error> { - if self.session != space.session() || self.session != relative_to.session() { + if self.session != space.session() || self.session != base_space.session() { return Err(Error::InvalidState); } if !self.active.get() { @@ -127,12 +136,12 @@ impl XRFrameMethods for XRFrame { } else { return Ok(None); }; - let relative_to = if let Some(r) = self.get_pose(relative_to) { + let base_space = if let Some(r) = self.get_pose(base_space) { r } else { return Ok(None); }; - let pose = space.then(&relative_to.inverse()); + let pose = space.then(&base_space.inverse()); Ok(Some(XRPose::new(&self.global(), pose))) } @@ -140,10 +149,10 @@ impl XRFrameMethods for XRFrame { fn GetJointPose( &self, space: &XRJointSpace, - relative_to: &XRSpace, + base_space: &XRSpace, ) -> Result>, Error> { if self.session != space.upcast::().session() || - self.session != relative_to.session() + self.session != base_space.session() { return Err(Error::InvalidState); } @@ -155,12 +164,12 @@ impl XRFrameMethods for XRFrame { } else { return Ok(None); }; - let relative_to = if let Some(r) = self.get_pose(relative_to) { + let base_space = if let Some(r) = self.get_pose(base_space) { r } else { return Ok(None); }; - let pose = joint_frame.pose.then(&relative_to.inverse()); + let pose = joint_frame.pose.then(&base_space.inverse()); Ok(Some(XRJointPose::new( &self.global(), pose.cast_unit(), diff --git a/tests/wpt/meta-legacy-layout/webxr/idlharness.https.window.js.ini b/tests/wpt/meta-legacy-layout/webxr/idlharness.https.window.js.ini index f6d19c7dc93..dcf09636ea1 100644 --- a/tests/wpt/meta-legacy-layout/webxr/idlharness.https.window.js.ini +++ b/tests/wpt/meta-legacy-layout/webxr/idlharness.https.window.js.ini @@ -350,9 +350,6 @@ [XRSession interface: xrSession must inherit property "onframeratechange" with the proper type] expected: FAIL - [XRFrame interface: attribute predictedDisplayTime] - expected: FAIL - [XRSession interface: xrSession must inherit property "enabledFeatures" with the proper type] expected: FAIL diff --git a/tests/wpt/meta/webxr/idlharness.https.window.js.ini b/tests/wpt/meta/webxr/idlharness.https.window.js.ini index ab367a38d07..9b9b62d8b21 100644 --- a/tests/wpt/meta/webxr/idlharness.https.window.js.ini +++ b/tests/wpt/meta/webxr/idlharness.https.window.js.ini @@ -293,9 +293,6 @@ [XRSession interface: xrSession must inherit property "onframeratechange" with the proper type] expected: FAIL - [XRFrame interface: attribute predictedDisplayTime] - expected: FAIL - [XRSession interface: xrSession must inherit property "enabledFeatures" with the proper type] expected: FAIL