Bug 1007344 - Ignore inactive windows when moving alerts. r=MattN

Differential Revision: https://phabricator.services.mozilla.com/D66605

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Michał Sobkiewicz 2020-03-15 22:30:03 +00:00
Родитель 2ef4614ee8
Коммит 347e2e933b
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -21,6 +21,7 @@ var gReplacedWindow = null;
var gAlertListener = null; var gAlertListener = null;
var gAlertTextClickable = false; var gAlertTextClickable = false;
var gAlertCookie = ""; var gAlertCookie = "";
var gIsActive = false;
var gIsReplaced = false; var gIsReplaced = false;
var gRequireInteraction = false; var gRequireInteraction = false;
@ -234,6 +235,8 @@ function onAlertLoad() {
alertSettings.addEventListener("focus", onAlertSettingsFocus); alertSettings.addEventListener("focus", onAlertSettingsFocus);
alertSettings.addEventListener("click", onAlertSettingsClick); alertSettings.addEventListener("click", onAlertSettingsClick);
gIsActive = true;
let ev = new CustomEvent("AlertActive", { bubbles: true, cancelable: true }); let ev = new CustomEvent("AlertActive", { bubbles: true, cancelable: true });
document.documentElement.dispatchEvent(ev); document.documentElement.dispatchEvent(ev);
@ -248,6 +251,9 @@ function moveWindowToReplace(aReplacedAlert) {
// Move windows that come after the replaced alert if the height is different. // Move windows that come after the replaced alert if the height is different.
if (heightDelta != 0) { if (heightDelta != 0) {
for (let alertWindow of Services.wm.getEnumerator("alert:alert")) { 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. // boolean to determine if the alert window is after the replaced alert.
let alertIsAfter = let alertIsAfter =
gOrigin & NS_ALERT_TOP gOrigin & NS_ALERT_TOP
@ -284,7 +290,7 @@ function moveWindowToEnd() {
// Position the window at the end of all alerts. // Position the window at the end of all alerts.
for (let alertWindow of Services.wm.getEnumerator("alert:alert")) { for (let alertWindow of Services.wm.getEnumerator("alert:alert")) {
if (alertWindow != window) { if (alertWindow != window && alertWindow.gIsActive) {
if (gOrigin & NS_ALERT_TOP) { if (gOrigin & NS_ALERT_TOP) {
y = Math.max( y = Math.max(
y, y,
@ -311,7 +317,7 @@ function onAlertBeforeUnload() {
// Move other alert windows to fill the gap left by closing alert. // Move other alert windows to fill the gap left by closing alert.
let heightDelta = window.outerHeight + WINDOW_MARGIN - WINDOW_SHADOW_SPREAD; let heightDelta = window.outerHeight + WINDOW_MARGIN - WINDOW_SHADOW_SPREAD;
for (let alertWindow of Services.wm.getEnumerator("alert:alert")) { for (let alertWindow of Services.wm.getEnumerator("alert:alert")) {
if (alertWindow != window) { if (alertWindow != window && alertWindow.gIsActive) {
if (gOrigin & NS_ALERT_TOP) { if (gOrigin & NS_ALERT_TOP) {
if (alertWindow.screenY > window.screenY) { if (alertWindow.screenY > window.screenY) {
alertWindow.moveTo( alertWindow.moveTo(