-
Notifications
You must be signed in to change notification settings - Fork 44
Overhaul exit Picture-in-Picture algorithm #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
theIDinside
wants to merge
10
commits into
w3c:main
Choose a base branch
from
theIDinside:exit-picture-in-picture-overhaul
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+57
−34
Open
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7ed1fed
Overhaul exit Picture-in-Picture algorithm
theIDinside 4fb83af
Fix specfmt-caused formatting errors
theIDinside 89b43f2
Change promise-or-null till nullable {{Promise}}
theIDinside a63d659
Change use of [=/Resolve]
theIDinside 39a9130
Use if-then wording
theIDinside 846790f
Change [=/Resolve] wording
theIDinside bf7bba9
Remove note, use bikeshed syntax for asserts
theIDinside 00918f8
Better wording for exitPictureInPicture steps
theIDinside 5330f78
Add non-fully active document checks & enqueue steps for fullscreen f…
theIDinside 81e4c56
Unloading steps
theIDinside File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,21 +221,32 @@ Picture-in-Picture window. | |
|
|
||
| ## Exit Picture-in-Picture ## {#exit-pip} | ||
|
|
||
| When the <dfn>exit Picture-in-Picture algorithm</dfn> is invoked, | ||
| the user agent MUST run the following steps: | ||
|
|
||
| 1. If {{pictureInPictureElement}} is `null`, throw a {{InvalidStateError}} and | ||
| abort these steps. | ||
| 2. Run the <a>close window algorithm</a> with the <a>Picture-in-Picture | ||
| window</a> associated with {{pictureInPictureElement}}. | ||
| 3. <a>Queue a task</a> to <a>fire an event</a> named | ||
| {{leavepictureinpicture}} using {{PictureInPictureEvent}} at the | ||
| |video| with its {{bubbles}} attribute initialized to `true` and its | ||
| {{PictureInPictureEvent/pictureInPictureWindow}} attribute initialized to | ||
| <a>Picture-in-Picture window</a> associated with {{pictureInPictureElement}}. | ||
| 4. Unset {{pictureInPictureElement}}. | ||
| 5. Remove one <a>item</a> matching <a>relevant settings object</a>'s <a>origin</a> from | ||
| <a>initiators of active Picture-in-Picture sessions</a>. | ||
| When the <dfn>exit Picture-in-Picture algorithm</dfn> is invoked given |doc| and promise-or-null | ||
| |p|, run these steps: | ||
|
|
||
| 1. Assert that |doc|'s [=Picture-in-Picture element=] is not `null`. | ||
| 2. Assert that these steps are running on the [=picture-in-picture parallel queue=]. | ||
|
theIDinside marked this conversation as resolved.
Outdated
|
||
|
|
||
| Note: This algorithm is called from {{exitPictureInPicture}} and {{requestPictureInPicture}}. | ||
|
theIDinside marked this conversation as resolved.
Outdated
|
||
| The document unloading steps have to be structured differently due to running on the event loop | ||
| and can therefore not call this algorithm. | ||
|
theIDinside marked this conversation as resolved.
Outdated
|
||
| 3. Let |global| be |doc|'s [=relevant global object=]. | ||
| 4. Run the <a>close window algorithm</a> with the <a>Picture-in-Picture window</a> associated with | ||
| |doc|'s [=Picture-in-Picture element=]. | ||
| 5. [=Queue a global task=] on the [=media element event task source=] given |global|, to perform the | ||
| following steps: | ||
| 1. If |doc|'s [=Picture-in-Picture element=] is `null`: | ||
| 1. [=/Resolve=] |p| if |p| is not `null`. | ||
|
theIDinside marked this conversation as resolved.
Outdated
|
||
| 2. Return. | ||
| 2. Let |element| be |doc|'s [=Picture-in-Picture element=]. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can element be null? |
||
| 3. Set |doc|'s [=Picture-in-Picture element=] to `null`. | ||
| 4. <a>Fire an event</a> named {{leavepictureinpicture}} using {{PictureInPictureEvent}} at the | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [=Queue a task=] to perform the follow steps? |
||
| |element| with its {{bubbles}} attribute initialized to `true` and its | ||
| {{PictureInPictureEvent/pictureInPictureWindow}} attribute initialized to | ||
| <a>Picture-in-Picture window</a> associated with |element|. | ||
| 5. Remove one <a>item</a> matching <a>relevant settings object</a>'s <a>origin</a> from | ||
| <a>initiators of active Picture-in-Picture sessions</a>. | ||
| 6. [=/Resolve=] |p| if |p| is not `null`. | ||
|
theIDinside marked this conversation as resolved.
Outdated
|
||
|
|
||
| It is NOT RECOMMENDED that the video playback state changes when the <a>exit | ||
| Picture-in-Picture algorithm</a> is invoked. The website SHOULD be in control | ||
|
|
@@ -340,18 +351,19 @@ The {{requestPictureInPicture()}} method steps <dfn export>request Picture-in-Pi | |
| [=/reject=] |p| with {{InvalidStateError}} {{DOMException}}. | ||
| 2. Abort these steps. | ||
| 4. Let |pipWindow| be a new instance of {{PictureInPictureWindow}} that represents [=this=]'s associated [=Picture-in-Picture window=]. | ||
| 5. [=Queue a global task=] on the [=media element event task source=] given |global|, to perform | ||
| 5. If |doc|'s [=Picture-in-Picture element=] is not `null`, run the [=exit Picture-in-Picture | ||
| algorithm=] given |doc| and `null`. | ||
| 6. [=Queue a global task=] on the [=media element event task source=] given |global|, to perform | ||
| the following steps: | ||
| 1. If {{pictureInPictureElement}} is not `null`, run the [=exit Picture-in-Picture algorithm=]. | ||
| 2. Set |doc|'s [=Picture-in-Picture element=] to [=this=]. | ||
| 3. [=list/Append=] [=relevant settings object=]'s [=origin=] to [=initiators of active | ||
| 1. Set |doc|'s [=Picture-in-Picture element=] to [=this=]. | ||
| 2. [=list/Append=] [=relevant settings object=]'s [=origin=] to [=initiators of active | ||
| Picture-in-Picture sessions=]. | ||
| 4. If [=this=] is [=fullscreenElement=], [=exit fullscreen=]. | ||
| 5. [=Fire an event=] named {{enterpictureinpicture}} using {{PictureInPictureEvent}} at | ||
| 3. If [=this=] is [=fullscreenElement=], [=exit fullscreen=]. | ||
|
theIDinside marked this conversation as resolved.
Outdated
|
||
| 4. [=Fire an event=] named {{enterpictureinpicture}} using {{PictureInPictureEvent}} at | ||
| [=this=] with its {{bubbles}} attribute initialized to `true` and its | ||
| {{PictureInPictureEvent/pictureInPictureWindow}} attribute initialized to | ||
| [=Picture-in-Picture window=]. | ||
| 6. [=/Resolve=] |p| with |pipWindow|. | ||
| 5. [=/Resolve=] |p| with |pipWindow|. | ||
|
|
||
|
|
||
| ## Extensions to <code>Document</code> ## {#document-extensions} | ||
|
|
@@ -372,14 +384,19 @@ The {{pictureInPictureEnabled}} attribute's getter must return `true` if | |
| <dfn>Picture-in-Picture support</dfn> is `false` if there's a user preference | ||
| that disables it or a platform limitation. It is `true` otherwise. | ||
|
|
||
| The {{exitPictureInPicture()}} method, when invoked, MUST | ||
| return <a>a new promise</a> |promise| and run the following steps <a>in | ||
| parallel</a>: | ||
|
|
||
| 1. Run the <a>exit Picture-in-Picture algorithm</a>. | ||
| 2. If the previous step threw an exception, reject |promise| with that | ||
| exception and abort these steps. | ||
| 3. [=/Resolve=] |promise|. | ||
| The {{exitPictureInPicture()}} method, when invoked, MUST return <a>a new promise</a> and run the | ||
| following steps: | ||
|
theIDinside marked this conversation as resolved.
Outdated
|
||
|
|
||
| 1. If [=this=]'s [=Picture-in-Picture element=] is `null`, return [=a promise rejected with=] | ||
| {{InvalidStateError}} {{DOMException}}. | ||
| 2. Let |p| be [=a new promise=] created in [=this=]'s [=relevant realm=]. | ||
| 3. Return |p|, and [=enqueue the following steps=] to [=this=]'s [=picture-in-picture parallel | ||
| queue=]: | ||
| 1. If [=this=]'s [=Picture-in-Picture element=] is `null`: | ||
| 1. [=Queue a global task=] on the [=media element event task source=] given [=this=]'s | ||
| [=relevant global object=] to [=/resolve=] |p|. | ||
| 2. Return. | ||
| 2. Run the <a>exit Picture-in-Picture algorithm</a> given [=this=] and |p|. | ||
|
|
||
| ## Extension to <code>DocumentOrShadowRoot</code> ## {#documentorshadowroot-extension} | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.