Require system focus for gamepad user gesture#207
Conversation
|
This seems reasonable. I need to check if WebKit already does this or not. |
I think WebKit on macOS already requires focus even for normal gamepad inputs because it uses Game Controller API which requires focus. |
|
We might actually want this:
|
There was a problem hiding this comment.
Pull request overview
Updates the Gamepad spec’s “gamepad user gesture” handling to require the relevant document to have user attention (i.e., be focused/active) before the initial gesture unlocks exposure of gamepad data, addressing issue #206’s cross-tab gesture concerns.
Changes:
- Gate setting
Navigator/[[hasGamepadGesture]]on the associated document being a fully active descendant of a top-level traversable with user attention. - Hoist the associated
Documentlookup earlier in the “update gamepad state” algorithm (so it can be used for the new focus/user-attention check).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| |document| is a [=Document/fully active descendant of a top-level | ||
| traversable with user attention=] and |gamepad| [=contains a gamepad | ||
| user gesture=]: |
There was a problem hiding this comment.
The condition uses “|document| is a Document/fully active descendant …” but |document| is defined as Document? and can be null. Add an explicit |document| is not null (or change the condition to handle null) before applying the HTML definition, to avoid a type-mismatched check and make the focus requirement unambiguous.
| |document| is a [=Document/fully active descendant of a top-level | |
| traversable with user attention=] and |gamepad| [=contains a gamepad | |
| user gesture=]: | |
| |document| is not `null` and is a [=Document/fully active descendant | |
| of a top-level traversable with user attention=] and |gamepad| | |
| [=contains a gamepad user gesture=]: |
There was a problem hiding this comment.
Ok, yeah... maybe this check should also happen earlier. If you don't have a document anyway, then none of the above really matters, right?
| <li>Let |gamepads:sequence<Gamepad?>| be an empty [=list=]. | ||
| </li> |
There was a problem hiding this comment.
This algorithm step is duplicated: Let |gamepads:sequence<Gamepad?>| be an empty list appears twice in a row. Remove the extra step to avoid confusion about variable re-declaration and keep the algorithm consistent.
| <li>Let |gamepads:sequence<Gamepad?>| be an empty [=list=]. | |
| </li> |
Closes #206
The following tasks have been completed:
Implementation commitment:
Preview | Diff