зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1681796: Prevent superfluous PictureInPictureParent actors from being associated with each tab r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D99489
This commit is contained in:
Родитель
9d09a04500
Коммит
3580d30873
|
@ -336,11 +336,7 @@ var PictureInPicture = {
|
||||||
let browser = wgp.browsingContext.top.embedderElement;
|
let browser = wgp.browsingContext.top.embedderElement;
|
||||||
let parentWin = browser.ownerGlobal;
|
let parentWin = browser.ownerGlobal;
|
||||||
|
|
||||||
let actorRef = browser.browsingContext.currentWindowGlobal.getActor(
|
let win = await this.openPipWindow(parentWin, videoData);
|
||||||
"PictureInPicture"
|
|
||||||
);
|
|
||||||
|
|
||||||
let win = await this.openPipWindow(parentWin, videoData, actorRef);
|
|
||||||
win.setIsPlayingState(videoData.playing);
|
win.setIsPlayingState(videoData.playing);
|
||||||
win.setIsMutedState(videoData.isMuted);
|
win.setIsMutedState(videoData.isMuted);
|
||||||
|
|
||||||
|
@ -404,12 +400,8 @@ var PictureInPicture = {
|
||||||
* @returns Promise
|
* @returns Promise
|
||||||
* Resolves once the window has opened and loaded the player component.
|
* Resolves once the window has opened and loaded the player component.
|
||||||
*/
|
*/
|
||||||
async openPipWindow(parentWin, videoData, actorReference) {
|
async openPipWindow(parentWin, videoData) {
|
||||||
let { top, left, width, height } = this.fitToScreen(
|
let { top, left, width, height } = this.fitToScreen(parentWin, videoData);
|
||||||
parentWin,
|
|
||||||
videoData,
|
|
||||||
actorReference
|
|
||||||
);
|
|
||||||
|
|
||||||
let features =
|
let features =
|
||||||
`${PLAYER_FEATURES},top=${top},left=${left},` +
|
`${PLAYER_FEATURES},top=${top},left=${left},` +
|
||||||
|
@ -447,7 +439,7 @@ var PictureInPicture = {
|
||||||
* and size. If those values are unknown or offscreen, then a default
|
* and size. If those values are unknown or offscreen, then a default
|
||||||
* location and size is used.
|
* location and size is used.
|
||||||
*
|
*
|
||||||
* @param windowOrPlayer (chrome window|player window)
|
* @param requestingWin (chrome window|player window)
|
||||||
* The window hosting the browser that requested the Picture in
|
* The window hosting the browser that requested the Picture in
|
||||||
* Picture window. If this is an existing player window then the returned
|
* Picture window. If this is an existing player window then the returned
|
||||||
* player size and position will be determined based on the existing
|
* player size and position will be determined based on the existing
|
||||||
|
@ -462,9 +454,6 @@ var PictureInPicture = {
|
||||||
* videoWidth (int):
|
* videoWidth (int):
|
||||||
* The preferred width of the video.
|
* The preferred width of the video.
|
||||||
*
|
*
|
||||||
* @param actorReference (PictureInPictureParent)
|
|
||||||
* Reference to calling PictureInPictureParent actor
|
|
||||||
*
|
|
||||||
* @returns (object)
|
* @returns (object)
|
||||||
* The size and position for the player window.
|
* The size and position for the player window.
|
||||||
*
|
*
|
||||||
|
@ -480,19 +469,22 @@ var PictureInPicture = {
|
||||||
* height (int):
|
* height (int):
|
||||||
* The height of the player window.
|
* The height of the player window.
|
||||||
*/
|
*/
|
||||||
fitToScreen(windowOrPlayer, videoData, actorReference) {
|
fitToScreen(requestingWin, videoData) {
|
||||||
let { videoHeight, videoWidth } = videoData;
|
let { videoHeight, videoWidth } = videoData;
|
||||||
|
|
||||||
// if current PiP window is being resized, the underlying video is changing,
|
const isPlayer = requestingWin.document.location.href == PLAYER_URI;
|
||||||
// then save the location and size for opening the new window
|
|
||||||
let isPlayerWindow =
|
|
||||||
windowOrPlayer == this.getWeakPipPlayer(actorReference);
|
|
||||||
if (isPlayerWindow) {
|
|
||||||
this.savePosition(windowOrPlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The last PiP location and size
|
let top, left, width, height;
|
||||||
let { top, left, width, height } = this.loadPosition();
|
if (isPlayer) {
|
||||||
|
// requestingWin is a PiP player, conserve its dimensions in this case
|
||||||
|
left = requestingWin.screenX;
|
||||||
|
top = requestingWin.screenY;
|
||||||
|
width = requestingWin.innerWidth;
|
||||||
|
height = requestingWin.innerHeight;
|
||||||
|
} else {
|
||||||
|
// requestingWin is a content window, load last PiP's dimensions
|
||||||
|
({ top, left, width, height } = this.loadPosition());
|
||||||
|
}
|
||||||
|
|
||||||
// Check that previous location and size were loaded
|
// Check that previous location and size were loaded
|
||||||
if (!isNaN(top) && !isNaN(left) && !isNaN(width) && !isNaN(height)) {
|
if (!isNaN(top) && !isNaN(left) && !isNaN(width) && !isNaN(height)) {
|
||||||
|
@ -577,10 +569,10 @@ var PictureInPicture = {
|
||||||
// We don't have the size or position of the last PiP window, so fall
|
// We don't have the size or position of the last PiP window, so fall
|
||||||
// back to calculating the default location.
|
// back to calculating the default location.
|
||||||
let screen = this.getWorkingScreen(
|
let screen = this.getWorkingScreen(
|
||||||
windowOrPlayer.screenX,
|
requestingWin.screenX,
|
||||||
windowOrPlayer.screenY,
|
requestingWin.screenY,
|
||||||
windowOrPlayer.innerWidth,
|
requestingWin.innerWidth,
|
||||||
windowOrPlayer.innerHeight
|
requestingWin.innerHeight
|
||||||
);
|
);
|
||||||
let [
|
let [
|
||||||
screenLeft,
|
screenLeft,
|
||||||
|
@ -647,11 +639,7 @@ var PictureInPicture = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { top, left, width, height } = this.fitToScreen(
|
let { top, left, width, height } = this.fitToScreen(win, videoData);
|
||||||
win,
|
|
||||||
videoData,
|
|
||||||
actorRef
|
|
||||||
);
|
|
||||||
win.resizeTo(width, height);
|
win.resizeTo(width, height);
|
||||||
win.moveTo(left, top);
|
win.moveTo(left, top);
|
||||||
},
|
},
|
||||||
|
|
Загрузка…
Ссылка в новой задаче