From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- browser/components/firefoxview/viewpage.mjs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'browser/components/firefoxview/viewpage.mjs') diff --git a/browser/components/firefoxview/viewpage.mjs b/browser/components/firefoxview/viewpage.mjs index fee02b49d6..83b04faf5d 100644 --- a/browser/components/firefoxview/viewpage.mjs +++ b/browser/components/firefoxview/viewpage.mjs @@ -131,7 +131,7 @@ export class ViewPage extends ViewPageContent { super(); this.selectedTab = false; this.recentBrowsing = Boolean(this.recentBrowsingElement); - this.onVisibilityChange = this.onVisibilityChange.bind(this); + this.onTabSelect = this.onTabSelect.bind(this); this.onResize = this.onResize.bind(this); } @@ -148,14 +148,17 @@ export class ViewPage extends ViewPageContent { this.windowResizeTask?.arm(); } - onVisibilityChange(event) { - if (this.isVisible) { + onTabSelect({ target }) { + const win = target.ownerGlobal; + + let selfBrowser = window.docShell?.chromeEventHandler; + const { gBrowser } = this.getWindow(); + let isForegroundTab = gBrowser.selectedBrowser == selfBrowser; + + if (win.FirefoxViewHandler.tab?.selected && isForegroundTab) { this.paused = false; this.viewVisibleCallback(); - } else if ( - this.ownerViewPage.selectedTab && - this.ownerDocument.visibilityState == "hidden" - ) { + } else { this.paused = true; this.viewHiddenCallback(); } @@ -163,19 +166,12 @@ export class ViewPage extends ViewPageContent { connectedCallback() { super.connectedCallback(); - this.ownerDocument.addEventListener( - "visibilitychange", - this.onVisibilityChange - ); } disconnectedCallback() { super.disconnectedCallback(); - this.ownerDocument.removeEventListener( - "visibilitychange", - this.onVisibilityChange - ); this.getWindow().removeEventListener("resize", this.onResize); + this.getWindow().removeEventListener("TabSelect", this.onTabSelect); } updateAllVirtualLists() { @@ -246,6 +242,7 @@ export class ViewPage extends ViewPageContent { this.paused = false; this.viewVisibleCallback(); this.getWindow().addEventListener("resize", this.onResize); + this.getWindow().addEventListener("TabSelect", this.onTabSelect); } } @@ -257,5 +254,6 @@ export class ViewPage extends ViewPageContent { this.windowResizeTask?.finalize(); } this.getWindow().removeEventListener("resize", this.onResize); + this.getWindow().removeEventListener("TabSelect", this.onTabSelect); } } -- cgit v1.2.3