mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Add methods to XRInputSourceArray
This commit is contained in:
parent
0777233412
commit
868e5cbd62
2 changed files with 19 additions and 3 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRInputSourceArray {
|
||||
// iterable<XRInputSource>;
|
||||
// readonly attribute unsigned long length;
|
||||
// getter XRInputSource(unsigned long index);
|
||||
iterable<XRInputSource>;
|
||||
readonly attribute unsigned long length;
|
||||
getter XRInputSource(unsigned long index);
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::XRInputSourceArrayBinding;
|
||||
use crate::dom::bindings::codegen::Bindings::XRInputSourceArrayBinding::XRInputSourceArrayMethods;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
|
@ -46,3 +47,18 @@ impl XRInputSourceArray {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl XRInputSourceArrayMethods for XRInputSourceArray {
|
||||
/// https://immersive-web.github.io/webxr/#dom-xrinputsourcearray-length
|
||||
fn Length(&self) -> u32 {
|
||||
self.input_sources.borrow().len() as u32
|
||||
}
|
||||
|
||||
/// https://immersive-web.github.io/webxr/#xrinputsourcearray
|
||||
fn IndexedGetter(&self, n: u32) -> Option<DomRoot<XRInputSource>> {
|
||||
self.input_sources
|
||||
.borrow()
|
||||
.get(n as usize)
|
||||
.map(|x| DomRoot::from_ref(&**x))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue