From 81aece863f31a6179473ed25273b852ff14b0b73 Mon Sep 17 00:00:00 2001 From: "mr. m" <91018726+mr-cheffy@users.noreply.github.com> Date: Wed, 26 Aug 2026 08:30:00 +0200 Subject: [PATCH] gh-14710: Fixed minimizing PiP window failing to collapse into the sidebar (gh-15111) --- .../firefox/issue_14710.patch | 55 +++++++++++++++++++ src/external-patches/manifest.json | 5 ++ 2 files changed, 60 insertions(+) create mode 100644 src/external-patches/firefox/issue_14710.patch diff --git a/src/external-patches/firefox/issue_14710.patch b/src/external-patches/firefox/issue_14710.patch new file mode 100644 index 000000000..54e288ed8 --- /dev/null +++ b/src/external-patches/firefox/issue_14710.patch @@ -0,0 +1,55 @@ +diff --git a/toolkit/components/pictureinpicture/PictureInPicture.sys.mjs b/toolkit/components/pictureinpicture/PictureInPicture.sys.mjs +--- a/toolkit/components/pictureinpicture/PictureInPicture.sys.mjs ++++ b/toolkit/components/pictureinpicture/PictureInPicture.sys.mjs +@@ -119,10 +119,19 @@ + } + case "PictureInPicture:VideoTabHidden": { + if (!lazy.PIP_ENABLED || !lazy.PIP_WHEN_SWITCHING_TABS) { + break; + } ++ ++ // Suppress auto-toggle if the user deliberately closed this PiP window ++ if ( ++ PictureInPicture.weakAutoPipBrowserClosedDeliberately.has(browser) ++ ) { ++ PictureInPicture.weakAutoPipBrowserClosedDeliberately.delete(browser); ++ break; ++ } ++ + // If the tab is still selected, then we can ignore this event + if (browser.documentGlobal.gBrowser.selectedBrowser == browser) { + break; + } + let actor = browsingContext.currentWindowGlobal.getActor( +@@ -261,10 +270,12 @@ + maxConcurrentPlayerCount: 0, + + // Maps auto pip browser to PictureInPictureParent actor + weakAutoPipBrowserToParent: new WeakMap(), + ++ weakAutoPipBrowserClosedDeliberately: new WeakSet(), ++ + /** + * Returns the player window if one exists and if it hasn't yet been closed. + * + * @param {PictureInPictureParent} pipActorRef + * Reference to the calling PictureInPictureParent actor +@@ -899,10 +910,17 @@ + const { reason, actorRef } = closeData; + const win = this.getWeakPipPlayer(actorRef); + if (!win) { + return; + } ++ ++ const browser = this.weakWinToBrowser.get(win); ++ ++ if (reason === "CloseButton") { ++ PictureInPicture.weakAutoPipBrowserClosedDeliberately.add(browser); ++ } ++ + this.removePiPBrowserFromWeakMap(this.weakWinToBrowser.get(win)); + this.weakAutoPipBrowserToParent.delete(this.weakWinToBrowser.get(win)); + + Glean.pictureinpicture["closedMethod" + reason].record(); + await this.closePipWindow(win); + diff --git a/src/external-patches/manifest.json b/src/external-patches/manifest.json index 8c71d8623..7c794ef9c 100644 --- a/src/external-patches/manifest.json +++ b/src/external-patches/manifest.json @@ -51,5 +51,10 @@ "@@ -59,11 +67,12 @@": "@@ -59,9 +67,10 @@", "aLoadState->TypeHint())) {\n MOZ_DIAGNOSTIC_ASSERT(!mURI->SchemeIs(\"javascript\"));\n \n // Pull": "aLoadState->TypeHint())) {\n // Pull" } + }, + { + "type": "phabricator", + "id": "D321446", + "name": "Issue 14710" } ]