diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2020-01-21 23:19:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-21 23:19:40 -0500 |
commit | ee3fb92e53d08c34a41b748aa4e49ae336eaf611 (patch) | |
tree | 59c35028546b0be1d2931ea491399c301064ce7b /components/script/dom/xrinputsource.rs | |
parent | 35eb6dd0748dd9cd47e4b754166107aac72e62db (diff) | |
parent | 9a04a37c1cdd0f6f5fe5feca45f9468701fa3799 (diff) | |
download | servo-ee3fb92e53d08c34a41b748aa4e49ae336eaf611.tar.gz servo-ee3fb92e53d08c34a41b748aa4e49ae336eaf611.zip |
Auto merge of #25504 - Manishearth:features, r=asajeffrey
Support features in webxr
Based on https://github.com/servo/webxr/pull/119
Todo:
- [x] gate reference space creation on feature presence
- [x] Fix the `features_deviceSupport` test to correctly use simulateUserActivation
Fixes #24196, #24270
r? @jdm @asajeffrey
Diffstat (limited to 'components/script/dom/xrinputsource.rs')
-rw-r--r-- | components/script/dom/xrinputsource.rs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/components/script/dom/xrinputsource.rs b/components/script/dom/xrinputsource.rs index fed76937d9c..e0da8bea550 100644 --- a/components/script/dom/xrinputsource.rs +++ b/components/script/dom/xrinputsource.rs @@ -2,6 +2,7 @@ * 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::compartments::enter_realm; use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding; use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{ XRHandedness, XRInputSourceMethods, XRTargetRayMode, @@ -11,7 +12,11 @@ use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::globalscope::GlobalScope; use crate::dom::xrsession::XRSession; use crate::dom::xrspace::XRSpace; +use crate::script_runtime::JSContext; use dom_struct::dom_struct; +use js::conversions::ToJSValConvertible; +use js::jsapi::Heap; +use js::jsval::{JSVal, UndefinedValue}; use webxr_api::{Handedness, InputId, InputSource, TargetRayMode}; #[dom_struct] @@ -24,6 +29,8 @@ pub struct XRInputSource { target_ray_space: MutNullableDom<XRSpace>, #[ignore_malloc_size_of = "Defined in rust-webxr"] grip_space: MutNullableDom<XRSpace>, + #[ignore_malloc_size_of = "mozjs"] + profiles: Heap<JSVal>, } impl XRInputSource { @@ -34,19 +41,30 @@ impl XRInputSource { info, target_ray_space: Default::default(), grip_space: Default::default(), + profiles: Heap::default(), } } + #[allow(unsafe_code)] pub fn new( global: &GlobalScope, session: &XRSession, info: InputSource, ) -> DomRoot<XRInputSource> { - reflect_dom_object( + let source = reflect_dom_object( Box::new(XRInputSource::new_inherited(session, info)), global, XRInputSourceBinding::Wrap, - ) + ); + + let _ac = enter_realm(&*global); + let cx = global.get_cx(); + unsafe { + rooted!(in(*cx) let mut profiles = UndefinedValue()); + source.info.profiles.to_jsval(*cx, profiles.handle_mut()); + source.profiles.set(profiles.get()); + } + source } pub fn id(&self) -> InputId { @@ -92,4 +110,8 @@ impl XRInputSourceMethods for XRInputSource { None } } + // https://immersive-web.github.io/webxr/#dom-xrinputsource-profiles + fn Profiles(&self, _cx: JSContext) -> JSVal { + self.profiles.get() + } } |