diff --git a/components/script/dom/webidls/XRWebGLLayer.webidl b/components/script/dom/webidls/XRWebGLLayer.webidl index 0007b457f8e..5b26716ebd2 100644 --- a/components/script/dom/webidls/XRWebGLLayer.webidl +++ b/components/script/dom/webidls/XRWebGLLayer.webidl @@ -24,6 +24,7 @@ interface XRWebGLLayer: XRLayer { // Attributes readonly attribute boolean antialias; readonly attribute boolean ignoreDepthValues; + attribute float? fixedFoveation; [SameObject] readonly attribute WebGLFramebuffer? framebuffer; readonly attribute unsigned long framebufferWidth; @@ -32,8 +33,8 @@ interface XRWebGLLayer: XRLayer { // Methods XRViewport? getViewport(XRView view); - // // Static Methods - // static double getNativeFramebufferScaleFactor(XRSession session); + // Static Methods + static double getNativeFramebufferScaleFactor(XRSession session); }; partial interface mixin WebGLRenderingContextBase { diff --git a/components/script/dom/xrwebgllayer.rs b/components/script/dom/xrwebgllayer.rs index 933e8537f1d..6a86671ccff 100644 --- a/components/script/dom/xrwebgllayer.rs +++ b/components/script/dom/xrwebgllayer.rs @@ -17,6 +17,7 @@ use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::{ }; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; +use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::globalscope::GlobalScope; @@ -156,6 +157,13 @@ impl XRWebGLLayer { )) } + /// + #[allow(non_snake_case)] + pub fn GetNativeFramebufferScaleFactor(_window: &Window, session: &XRSession) -> Finite { + let value: f64 = if session.is_ended() { 0.0 } else { 1.0 }; + Finite::wrap(value) + } + pub fn layer_id(&self) -> Option { self.xr_layer.layer_id() } @@ -292,6 +300,17 @@ impl XRWebGLLayerMethods for XRWebGLLayer { self.ignore_depth_values } + /// + fn GetFixedFoveation(&self) -> Option> { + // Fixed foveation is only available on Quest/Pico headset runtimes + None + } + + /// + fn SetFixedFoveation(&self, _value: Option>) { + // no-op until fixed foveation is supported + } + /// fn GetFramebuffer(&self) -> Option> { self.framebuffer.as_ref().map(|x| DomRoot::from_ref(&**x)) 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 4a83da3fb77..f7d261b8002 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 @@ -20,9 +20,6 @@ [XRBoundedReferenceSpace interface object length] expected: FAIL - [XRWebGLLayer interface: operation getNativeFramebufferScaleFactor(XRSession)] - expected: FAIL - [XRRay interface: attribute matrix] expected: FAIL @@ -314,9 +311,6 @@ [XRSession interface: calling cancelAnimationFrame(unsigned long) on xrSession with too few arguments must throw TypeError] expected: FAIL - [XRWebGLLayer interface: attribute fixedFoveation] - expected: FAIL - [XRWebGLLayer interface: xrWebGLLayer must inherit property "fixedFoveation" 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 47f46135676..15162e81c1c 100644 --- a/tests/wpt/meta/webxr/idlharness.https.window.js.ini +++ b/tests/wpt/meta/webxr/idlharness.https.window.js.ini @@ -56,9 +56,6 @@ [XRBoundedReferenceSpace interface object length] expected: FAIL - [XRWebGLLayer interface: operation getNativeFramebufferScaleFactor(XRSession)] - expected: FAIL - [XRWebGLLayer interface: xrWebGLLayer must inherit property "framebuffer" with the proper type] expected: FAIL @@ -257,9 +254,6 @@ [XRSession interface: calling cancelAnimationFrame(unsigned long) on xrSession with too few arguments must throw TypeError] expected: FAIL - [XRWebGLLayer interface: attribute fixedFoveation] - expected: FAIL - [XRWebGLLayer interface: xrWebGLLayer must inherit property "fixedFoveation" with the proper type] expected: FAIL