Bug 1529577 - stop tracking window minimization in BrowserWindowTracker, r=dao
Differential Revision: https://phabricator.services.mozilla.com/D19186
This commit is contained in:
@@ -1591,7 +1591,7 @@ var SessionStoreInternal = {
|
||||
onQuitApplicationGranted: function ssi_onQuitApplicationGranted(syncShutdown = false) {
|
||||
// Collect an initial snapshot of window data before we do the flush.
|
||||
let index = 0;
|
||||
for (let window of this._browserWindows) {
|
||||
for (let window of this._orderedBrowserWindows) {
|
||||
this._collectWindowData(window);
|
||||
this._windows[window.__SSi].zIndex = ++index;
|
||||
}
|
||||
@@ -3416,7 +3416,7 @@ var SessionStoreInternal = {
|
||||
if (RunState.isRunning) {
|
||||
// update the data for all windows with activities since the last save operation.
|
||||
let index = 0;
|
||||
for (let window of this._browserWindows) {
|
||||
for (let window of this._orderedBrowserWindows) {
|
||||
if (!this._isWindowLoaded(window)) // window data is still in _statesToRestore
|
||||
continue;
|
||||
if (aUpdateAll || DirtyWindows.has(window) || window == activeWindow) {
|
||||
@@ -4527,8 +4527,10 @@ var SessionStoreInternal = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Iterator that yields all currently opened browser windows, in order.
|
||||
* Iterator that yields all currently opened browser windows.
|
||||
* (Might miss the most recent one.)
|
||||
* This list is in focus order, but may include minimized windows
|
||||
* before non-minimized windows.
|
||||
*/
|
||||
_browserWindows: {
|
||||
* [Symbol.iterator]() {
|
||||
@@ -4539,6 +4541,30 @@ var SessionStoreInternal = {
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Iterator that yields all currently opened browser windows,
|
||||
* with minimized windows last.
|
||||
* (Might miss the most recent window.)
|
||||
*/
|
||||
_orderedBrowserWindows: {
|
||||
* [Symbol.iterator]() {
|
||||
let windows = BrowserWindowTracker.orderedWindows;
|
||||
windows.sort((a, b) => {
|
||||
if (a.windowState == a.STATE_MINIMIZED && b.windowState != b.STATE_MINIMIZED) {
|
||||
return 1;
|
||||
}
|
||||
if (a.windowState != a.STATE_MINIMIZED && b.windowState == b.STATE_MINIMIZED) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
for (let window of windows) {
|
||||
if (window.__SSi && !window.closed)
|
||||
yield window;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns most recent window
|
||||
* @returns Window reference
|
||||
|
||||
@@ -19,7 +19,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
|
||||
// Constants
|
||||
const TAB_EVENTS = ["TabBrowserInserted", "TabSelect"];
|
||||
const WINDOW_EVENTS = ["activate", "sizemodechange", "unload"];
|
||||
const WINDOW_EVENTS = ["activate", "unload"];
|
||||
const DEBUG = false;
|
||||
|
||||
// Variables
|
||||
@@ -64,9 +64,6 @@ function _handleEvent(event) {
|
||||
case "activate":
|
||||
WindowHelper.onActivate(event.target);
|
||||
break;
|
||||
case "sizemodechange":
|
||||
WindowHelper.onSizemodeChange(event.target);
|
||||
break;
|
||||
case "unload":
|
||||
WindowHelper.removeWindow(event.currentTarget);
|
||||
break;
|
||||
@@ -144,14 +141,6 @@ var WindowHelper = {
|
||||
|
||||
_updateCurrentContentOuterWindowID(window.gBrowser.selectedBrowser);
|
||||
},
|
||||
|
||||
onSizemodeChange(window) {
|
||||
if (window.windowState == window.STATE_MINIMIZED) {
|
||||
// Make sure to have the minimized window behind unminimized windows.
|
||||
_untrackWindowOrder(window);
|
||||
_trackWindowOrder(window);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
this.BrowserWindowTracker = {
|
||||
|
||||
@@ -110,16 +110,5 @@ add_task(async function test_orderedWindows() {
|
||||
let expected = [1, 6, 4, 9, 8, 7, 5, 3, 2, 0];
|
||||
Assert.deepEqual(expected, ordered2.map(w => windows.indexOf(w)),
|
||||
"After shuffle of focused windows, the order should've changed.");
|
||||
|
||||
// Minimizing a window should put it at the end of the ordered list of windows.
|
||||
let promise = BrowserTestUtils.waitForEvent(windows[9], "sizemodechange");
|
||||
windows[9].minimize();
|
||||
await promise;
|
||||
|
||||
let ordered3 = BrowserWindowTracker.orderedWindows.filter(w => w != TEST_WINDOW);
|
||||
// Test the end of the array of window indices, because Windows Debug builds
|
||||
// mysteriously swap the order of the first two windows.
|
||||
Assert.deepEqual([8, 7, 5, 3, 2, 0, 9], ordered3.map(w => windows.indexOf(w)).slice(3),
|
||||
"When a window is minimized, the order should've changed.");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user