mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Move VR interface to XR
The WebVR spec no longer has a navigator.vr, but there is a navigator.XR in the XR spec. Instead of duplicating work I've combined the two.
This commit is contained in:
parent
c553c43ba1
commit
376426a936
6 changed files with 55 additions and 42 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
use crate::dom::bindings::codegen::Bindings::NavigatorBinding;
|
||||
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::VRBinding::VRBinding::VRMethods;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
|
@ -16,8 +15,8 @@ use crate::dom::permissions::Permissions;
|
|||
use crate::dom::pluginarray::PluginArray;
|
||||
use crate::dom::promise::Promise;
|
||||
use crate::dom::serviceworkercontainer::ServiceWorkerContainer;
|
||||
use crate::dom::vr::VR;
|
||||
use crate::dom::window::Window;
|
||||
use crate::dom::xr::XR;
|
||||
use dom_struct::dom_struct;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -28,7 +27,7 @@ pub struct Navigator {
|
|||
plugins: MutNullableDom<PluginArray>,
|
||||
mime_types: MutNullableDom<MimeTypeArray>,
|
||||
service_worker: MutNullableDom<ServiceWorkerContainer>,
|
||||
vr: MutNullableDom<VR>,
|
||||
xr: MutNullableDom<XR>,
|
||||
gamepads: MutNullableDom<GamepadList>,
|
||||
permissions: MutNullableDom<Permissions>,
|
||||
}
|
||||
|
@ -41,7 +40,7 @@ impl Navigator {
|
|||
plugins: Default::default(),
|
||||
mime_types: Default::default(),
|
||||
service_worker: Default::default(),
|
||||
vr: Default::default(),
|
||||
xr: Default::default(),
|
||||
gamepads: Default::default(),
|
||||
permissions: Default::default(),
|
||||
}
|
||||
|
@ -135,7 +134,7 @@ impl NavigatorMethods for Navigator {
|
|||
.gamepads
|
||||
.or_init(|| GamepadList::new(&self.global(), &[]));
|
||||
|
||||
let vr_gamepads = self.Vr().get_gamepads();
|
||||
let vr_gamepads = self.Xr().get_gamepads();
|
||||
root.add_if_not_exists(&vr_gamepads);
|
||||
// TODO: Add not VR related gamepads
|
||||
root
|
||||
|
@ -149,12 +148,10 @@ impl NavigatorMethods for Navigator {
|
|||
// https://w3c.github.io/webvr/spec/1.1/#navigator-getvrdisplays-attribute
|
||||
#[allow(unrooted_must_root)]
|
||||
fn GetVRDisplays(&self) -> Rc<Promise> {
|
||||
self.Vr().GetDisplays()
|
||||
self.Xr().get_displays()
|
||||
}
|
||||
}
|
||||
|
||||
impl Navigator {
|
||||
pub fn Vr(&self) -> DomRoot<VR> {
|
||||
self.vr.or_init(|| VR::new(&self.global()))
|
||||
fn Xr(&self) -> DomRoot<XR> {
|
||||
self.xr.or_init(|| XR::new(&self.global()))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue