From 347e2e933b9efe284d57fa44b5f5347fad67410e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sobkiewicz?= Date: Sun, 15 Mar 2020 22:30:03 +0000 Subject: [PATCH] Bug 1007344 - Ignore inactive windows when moving alerts. r=MattN Differential Revision: https://phabricator.services.mozilla.com/D66605 --HG-- extra : moz-landing-system : lando --- toolkit/components/alerts/resources/content/alert.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/toolkit/components/alerts/resources/content/alert.js b/toolkit/components/alerts/resources/content/alert.js index c1a7e32da088..86e4e77724d1 100644 --- a/toolkit/components/alerts/resources/content/alert.js +++ b/toolkit/components/alerts/resources/content/alert.js @@ -21,6 +21,7 @@ var gReplacedWindow = null; var gAlertListener = null; var gAlertTextClickable = false; var gAlertCookie = ""; +var gIsActive = false; var gIsReplaced = false; var gRequireInteraction = false; @@ -234,6 +235,8 @@ function onAlertLoad() { alertSettings.addEventListener("focus", onAlertSettingsFocus); alertSettings.addEventListener("click", onAlertSettingsClick); + gIsActive = true; + let ev = new CustomEvent("AlertActive", { bubbles: true, cancelable: true }); document.documentElement.dispatchEvent(ev); @@ -248,6 +251,9 @@ function moveWindowToReplace(aReplacedAlert) { // Move windows that come after the replaced alert if the height is different. if (heightDelta != 0) { for (let alertWindow of Services.wm.getEnumerator("alert:alert")) { + if (!alertWindow.gIsActive) { + continue; + } // boolean to determine if the alert window is after the replaced alert. let alertIsAfter = gOrigin & NS_ALERT_TOP @@ -284,7 +290,7 @@ function moveWindowToEnd() { // Position the window at the end of all alerts. for (let alertWindow of Services.wm.getEnumerator("alert:alert")) { - if (alertWindow != window) { + if (alertWindow != window && alertWindow.gIsActive) { if (gOrigin & NS_ALERT_TOP) { y = Math.max( y, @@ -311,7 +317,7 @@ function onAlertBeforeUnload() { // Move other alert windows to fill the gap left by closing alert. let heightDelta = window.outerHeight + WINDOW_MARGIN - WINDOW_SHADOW_SPREAD; for (let alertWindow of Services.wm.getEnumerator("alert:alert")) { - if (alertWindow != window) { + if (alertWindow != window && alertWindow.gIsActive) { if (gOrigin & NS_ALERT_TOP) { if (alertWindow.screenY > window.screenY) { alertWindow.moveTo(