aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/navigator.rs
diff options
context:
space:
mode:
authorImanol Fernandez <mortimergoro@gmail.com>2016-12-16 18:39:35 +0100
committerImanol Fernandez <mortimergoro@gmail.com>2017-01-09 12:44:39 +0100
commitc5705bff5003675d6d266c698653834027a78227 (patch)
tree8e2b4e6a91933ba147885210d9a360d46414189b /components/script/dom/navigator.rs
parent13826970c4d9fbbd67cdf9dfb39e8a847cf06541 (diff)
downloadservo-c5705bff5003675d6d266c698653834027a78227.tar.gz
servo-c5705bff5003675d6d266c698653834027a78227.zip
WebVR API Implementation, r=larsbergstrom
Diffstat (limited to 'components/script/dom/navigator.rs')
-rw-r--r--components/script/dom/navigator.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs
index b7d781f5eb0..dd9a1a789c6 100644
--- a/components/script/dom/navigator.rs
+++ b/components/script/dom/navigator.rs
@@ -12,7 +12,9 @@ use dom::mimetypearray::MimeTypeArray;
use dom::navigatorinfo;
use dom::pluginarray::PluginArray;
use dom::serviceworkercontainer::ServiceWorkerContainer;
+use dom::vr::VR;
use dom::window::Window;
+use script_traits::WebVREventMsg;
#[dom_struct]
pub struct Navigator {
@@ -21,6 +23,7 @@ pub struct Navigator {
plugins: MutNullableJS<PluginArray>,
mime_types: MutNullableJS<MimeTypeArray>,
service_worker: MutNullableJS<ServiceWorkerContainer>,
+ vr: MutNullableJS<VR>
}
impl Navigator {
@@ -31,6 +34,7 @@ impl Navigator {
plugins: Default::default(),
mime_types: Default::default(),
service_worker: Default::default(),
+ vr: Default::default(),
}
}
@@ -114,4 +118,16 @@ impl NavigatorMethods for Navigator {
true
}
+ #[allow(unrooted_must_root)]
+ // https://w3c.github.io/webvr/#interface-navigator
+ fn Vr(&self) -> Root<VR> {
+ self.vr.or_init(|| VR::new(&self.global()))
+ }
+}
+
+impl Navigator {
+ pub fn handle_webvr_event(&self, event: WebVREventMsg) {
+ self.vr.get().expect("Shouldn't arrive here with an empty VR instance")
+ .handle_webvr_event(event);
+ }
}