diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2019-04-29 19:15:27 -0700 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2019-05-03 14:37:41 -0700 |
commit | 5c8132c379a2d5612d5c904c7fe65b54d7f8ec70 (patch) | |
tree | 80d6ac10053cec9bdb961067583b2971bcecc213 /components/script | |
parent | 3a08e917e0c8501b4d56a31ae3ef6788743b4f9f (diff) | |
download | servo-5c8132c379a2d5612d5c904c7fe65b54d7f8ec70.tar.gz servo-5c8132c379a2d5612d5c904c7fe65b54d7f8ec70.zip |
Use initialized input sources in getInputSources()
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/vrdisplay.rs | 11 | ||||
-rw-r--r-- | components/script/dom/webidls/XRSession.webidl | 3 | ||||
-rw-r--r-- | components/script/dom/xrsession.rs | 6 |
3 files changed, 19 insertions, 1 deletions
diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs index c00d1c75e64..1f7480e2ef0 100644 --- a/components/script/dom/vrdisplay.rs +++ b/components/script/dom/vrdisplay.rs @@ -926,7 +926,7 @@ impl VRDisplay { /// Initialize XRInputSources fn initialize_inputs(&self) { if self.initialized_inputs.get() { - return + return; } self.initialized_inputs.set(true); @@ -955,6 +955,15 @@ impl VRDisplay { Err(_) => {}, } } + + pub fn get_input_sources(&self) -> Vec<DomRoot<XRInputSource>> { + self.initialize_inputs(); + self.input_sources + .borrow() + .iter() + .map(|(_, x)| DomRoot::from_ref(&**x)) + .collect() + } } // WebVR Spec: If the number of values in the leftBounds/rightBounds arrays diff --git a/components/script/dom/webidls/XRSession.webidl b/components/script/dom/webidls/XRSession.webidl index f22918d469d..798a8f7b7ae 100644 --- a/components/script/dom/webidls/XRSession.webidl +++ b/components/script/dom/webidls/XRSession.webidl @@ -25,7 +25,10 @@ interface XRSession : EventTarget { // // Methods Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceOptions options); + // workaround until we have FrozenArray + // see https://github.com/servo/servo/issues/10427#issuecomment-449593626 // FrozenArray<XRInputSource> getInputSources(); + sequence<XRInputSource> getInputSources(); Promise<void> updateRenderState(optional XRRenderStateInit state); long requestAnimationFrame(XRFrameRequestCallback callback); diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs index 4b855cba4c8..67c7a10e36c 100644 --- a/components/script/dom/xrsession.rs +++ b/components/script/dom/xrsession.rs @@ -19,6 +19,7 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::dom::vrdisplay::VRDisplay; +use crate::dom::xrinputsource::XRInputSource; use crate::dom::xrlayer::XRLayer; use crate::dom::xrreferencespace::XRReferenceSpace; use crate::dom::xrrenderstate::XRRenderState; @@ -153,4 +154,9 @@ impl XRSessionMethods for XRSession { p } + + /// https://immersive-web.github.io/webxr/#dom-xrsession-getinputsources + fn GetInputSources(&self) -> Vec<DomRoot<XRInputSource>> { + self.display.get_input_sources() + } } |