mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 528440 - Should skip windows that are closed but not yet destroyed when using nsIWindowMediator. r=zeniko
This commit is contained in:
parent
50543d8818
commit
c164850eaa
@ -110,6 +110,10 @@ const CAPABILITIES = [
|
||||
"DNSPrefetch", "Auth"
|
||||
];
|
||||
|
||||
#ifndef XP_WIN
|
||||
#define BROKEN_WM_Z_ORDER
|
||||
#endif
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
function debug(aMsg) {
|
||||
@ -2598,7 +2602,7 @@ SessionStoreService.prototype = {
|
||||
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
var window = windowsEnum.getNext();
|
||||
if (window.__SSi) {
|
||||
if (window.__SSi && !window.closed) {
|
||||
aFunc.call(this, window);
|
||||
}
|
||||
}
|
||||
@ -2609,9 +2613,34 @@ SessionStoreService.prototype = {
|
||||
* @returns Window reference
|
||||
*/
|
||||
_getMostRecentBrowserWindow: function sss_getMostRecentBrowserWindow() {
|
||||
var windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
return windowMediator.getMostRecentWindow("navigator:browser");
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
|
||||
var win = wm.getMostRecentWindow("navigator:browser");
|
||||
if (!win)
|
||||
return null;
|
||||
if (!win.closed)
|
||||
return win;
|
||||
|
||||
#ifdef BROKEN_WM_Z_ORDER
|
||||
win = null;
|
||||
var windowsEnum = wm.getEnumerator("navigator:browser");
|
||||
// this is oldest to newest, so this gets a bit ugly
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let nextWin = windowsEnum.getNext();
|
||||
if (!nextWin.closed)
|
||||
win = nextWin;
|
||||
}
|
||||
return win;
|
||||
#else
|
||||
var windowsEnum = wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
win = windowsEnum.getNext();
|
||||
if (!win.closed)
|
||||
return win;
|
||||
}
|
||||
return null;
|
||||
#endif
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user