diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index b460a90b4b0..97fffe52853 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -554,7 +554,8 @@ unsafe_no_jsmanaged_fields!( webxr_api::Frame, webxr_api::InputSource, webxr_api::InputId, - webxr_api::HitTestId + webxr_api::HitTestId, + webxr_api::HitTestResult ); unsafe_no_jsmanaged_fields!(ScriptToConstellationChan); unsafe_no_jsmanaged_fields!(InteractiveMetrics); diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 17653d9536b..a410220b427 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -572,6 +572,7 @@ pub mod xmlhttprequesteventtarget; pub mod xmlhttprequestupload; pub mod xmlserializer; pub mod xrframe; +pub mod xrhittestresult; pub mod xrhittestsource; pub mod xrinputsource; pub mod xrinputsourcearray; diff --git a/components/script/dom/webidls/XRHitTestResult.webidl b/components/script/dom/webidls/XRHitTestResult.webidl new file mode 100644 index 00000000000..37be75d7ec6 --- /dev/null +++ b/components/script/dom/webidls/XRHitTestResult.webidl @@ -0,0 +1,10 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +// https://immersive-web.github.io/hit-test/#xrhittestresult-interface + +[SecureContext, Exposed=Window] +interface XRHitTestResult { + // XRPose? getPose(XRSpace baseSpace); +}; \ No newline at end of file diff --git a/components/script/dom/xrhittestresult.rs b/components/script/dom/xrhittestresult.rs new file mode 100644 index 00000000000..00b4cf5e5c1 --- /dev/null +++ b/components/script/dom/xrhittestresult.rs @@ -0,0 +1,39 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; +use crate::dom::bindings::root::{Dom, DomRoot}; +use crate::dom::globalscope::GlobalScope; +use crate::dom::xrframe::XRFrame; +use dom_struct::dom_struct; +use webxr_api::HitTestResult; + +#[dom_struct] +pub struct XRHitTestResult { + reflector_: Reflector, + #[ignore_malloc_size_of = "defined in webxr"] + result: HitTestResult, + frame: Dom, +} + +impl XRHitTestResult { + fn new_inherited(result: HitTestResult, frame: &XRFrame) -> XRHitTestResult { + XRHitTestResult { + reflector_: Reflector::new(), + result, + frame: Dom::from_ref(frame), + } + } + + pub fn new( + global: &GlobalScope, + result: HitTestResult, + frame: &XRFrame, + ) -> DomRoot { + reflect_dom_object( + Box::new(XRHitTestResult::new_inherited(result, frame)), + global, + ) + } +}