Add pending fullscreen request flag and promise to document state#251
Add pending fullscreen request flag and promise to document state#251marcoscaceres wants to merge 4 commits intowhatwg:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the Fullscreen API specification by adding exported document state for tracking pending fullscreen requests. The changes enable other specifications (like Screen Orientation) to detect and react to fullscreen requests using modern WebIDL promise patterns rather than relying on state flag changes.
Key Changes:
- Introduces two new exported document state definitions: a flag to indicate pending requests and a promise to enable promise-based reactions
- Updates the requestFullscreen() algorithm to set/clear the flag and promise at appropriate points in the request lifecycle
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
annevk
left a comment
There was a problem hiding this comment.
I vaguely recall promises not being a great building block for specifications, but I can't find the specific issue for this.
fullscreen.bs
Outdated
| <p>All <a for=/>documents</a> have an associated <dfn>list of pending fullscreen events</dfn>, which | ||
| is an <a>ordered set</a> of (<a>string</a>, <a>element</a>) <a>tuples</a>. It is initially empty. | ||
|
|
||
| <p>All <a for=/>documents</a> have an associated <dfn export>pending fullscreen request flag</dfn>. |
There was a problem hiding this comment.
Let's rename this to "has pending fullscreen request" and make it a boolean. Should also maybe use for=Document?
fullscreen.bs
Outdated
| <li><p>If <var>error</var> is false, then <a>consume user activation</a> given | ||
| <var>pendingDoc</var>'s <a>relevant global object</a>. | ||
|
|
||
| <li><p>If <var>error</var> is false, set <var>pendingDoc</var>'s <a>pending fullscreen request</a> flag. |
fullscreen.bs
Outdated
| <p>If <var>error</var> is true: | ||
|
|
||
| <ol> | ||
| <li><p>Unset <var>pendingDoc</var>'s <a>pending fullscreen request</a> flag. |
fullscreen.bs
Outdated
| Unless stated otherwise it is unset. When set, it indicates that the document has an outstanding | ||
| fullscreen request that has not yet resolved or been rejected. | ||
|
|
||
| <p>All <a for=/>documents</a> have an associated <dfn export>pending fullscreen request promise</dfn>. |
There was a problem hiding this comment.
I would prefer it if these follow the existing pattern:
All documents have an associated X, which is a Y. It is initially Z.
It's not super great for implementation sake either - it suddenly starts to depend on JS while the implementation otherwise wouldn't need to. Doing so implicitly makes things depend on JS Promise behavior. Interestingly the spec creates a promise without defining what a promise is. (Filed whatwg/infra#691) |
This commit adds exported definitions for both 'pending fullscreen request flag' and 'pending fullscreen request promise' to document state, enabling other specifications to use modern WebIDL patterns. Changes: - Add 'pending fullscreen request flag' to document state (exported) - Add 'pending fullscreen request promise' to document state (exported) - Set flag and store promise when requestFullscreen() starts processing - Clear flag and promise when request resolves (success) or rejects (error) - Use consistent naming conventions without interface binding The flag enables detecting pending fullscreen requests, while the promise enables other specifications to use WebIDL 'react' patterns to respond to fullscreen request rejections instead of relying on flag state changes. This enables other specifications (like Screen Orientation) to detect when a document has a pending fullscreen request and react to promise rejections, allowing modern promise-based integration for web compatibility. Related to w3c/screen-orientation#254 and w3c/screen-orientation#255
ec09747 to
467cd0a
Compare
I'm not following, particularly when you involve Anyway, can follow up in whatwg/infra#691 ... |
Motivated by w3c/screen-orientation#254 and w3c/screen-orientation#255 and w3c/screen-orientation#269
This commit adds exported definitions for both 'pending fullscreen request flag' and 'pending fullscreen request promise' to document state, enabling other specifications to use modern WebIDL patterns.
Changes:
The flag enables detecting pending fullscreen requests, while the promise enables other specifications to use WebIDL 'react' patterns to respond to fullscreen request rejections instead of relying on flag state changes.
This enables other specifications (like Screen Orientation) to detect when a document has a pending fullscreen request and react to promise rejections, allowing modern promise-based integration for web compatibility.
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff