Add XRHitTestResult

This commit is contained in:
Manish Goregaokar 2020-04-09 15:01:01 -07:00
parent 341d36a826
commit c7b91523d0
4 changed files with 52 additions and 1 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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);
};

View file

@ -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<XRFrame>,
}
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<XRHitTestResult> {
reflect_dom_object(
Box::new(XRHitTestResult::new_inherited(result, frame)),
global,
)
}
}