diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /browser/components/firefoxview/viewpage.mjs | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/firefoxview/viewpage.mjs')
-rw-r--r-- | browser/components/firefoxview/viewpage.mjs | 28 |
1 files changed, 13 insertions, 15 deletions
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); } } |