diff options
author | Daniel Adams <70986246+msub2@users.noreply.github.com> | 2024-03-12 08:32:30 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-12 12:32:30 +0000 |
commit | 48fa77df6710a89e156c8cebb7dec10c8cda4ae6 (patch) | |
tree | 20cd807a4ba546a9c9060096615364c8588b7ed1 /components/script/dom/gamepadlist.rs | |
parent | 31a50feb4a61707d661c6b72fe6479666a5c9832 (diff) | |
download | servo-48fa77df6710a89e156c8cebb7dec10c8cda4ae6.tar.gz servo-48fa77df6710a89e156c8cebb7dec10c8cda4ae6.zip |
Gamepad: Align closer to spec and implement missing slots (#31385)
* Implement missing gamepad slots, align to spec more
- Fixes TODO's from initial gamepad implementation
- Adds some missing spec steps
* Only handle gamepad events when pref is enabled
* Return empty list in getGamepads if document not active
* ./mach fmt
* Update getGamepads to return an array instead of GamepadList
* Add spec link for [[exposed]] slot
* Remove failing test expectations for not-fully-active
* A few fixes
- Change should_notify to has_gesture
- Add spec links and TODO to navigator
- Remove unneeded clone from GamepadList::list
- Move gamepadconnected event firing into has_gesture block
* Use queue_with_canceller for tasks and add expects
* Explicitly check for gamepad user gesture
* Move user gesture check into separate function
* Change contains_user_gesture to be a gamepad function
* mach fmt
* Change axis/button threshold constants to be private to module
Diffstat (limited to 'components/script/dom/gamepadlist.rs')
-rw-r--r-- | components/script/dom/gamepadlist.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/components/script/dom/gamepadlist.rs b/components/script/dom/gamepadlist.rs index 4f373e24d96..5efa99f7aa8 100644 --- a/components/script/dom/gamepadlist.rs +++ b/components/script/dom/gamepadlist.rs @@ -48,6 +48,14 @@ impl GamepadList { pub fn remove_gamepad(&self, index: usize) { self.list.borrow_mut().remove(index); } + + pub fn list(&self) -> Vec<Option<DomRoot<Gamepad>>> { + self.list + .borrow() + .iter() + .map(|gamepad| Some(DomRoot::from_ref(&**gamepad))) + .collect() + } } impl GamepadListMethods for GamepadList { |