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
This commit is contained in:
Daniel Adams 2024-03-12 08:32:30 -04:00 committed by GitHub
parent 31a50feb4a
commit 48fa77df67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 124 additions and 45 deletions

View file

@ -69,7 +69,7 @@ partial interface Navigator {
// https://w3c.github.io/gamepad/#navigator-interface-extension
partial interface Navigator {
[Pref="dom.gamepad.enabled"] GamepadList getGamepads();
[Pref="dom.gamepad.enabled"] sequence<Gamepad?> getGamepads();
};
// https://html.spec.whatwg.org/multipage/#navigatorconcurrenthardware