code review: only clients of win watcher care about window type

This commit is contained in:
gorhill 2015-10-22 18:27:24 -04:00
parent afd77a3cef
commit 0eb0708a5b
1 changed files with 5 additions and 10 deletions

View File

@ -580,6 +580,7 @@ var winWatcher = (function() {
}
addWindow(win);
},
onCloseWindow: function(aWindow) {
var win;
try {
@ -589,6 +590,7 @@ var winWatcher = (function() {
}
removeWindow(win);
},
observe: function(aSubject, topic) {
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowWatcher#registerNotification%28%29
// "aSubject - the window being opened or closed, sent as an
@ -613,10 +615,10 @@ var winWatcher = (function() {
};
(function() {
var win, winumerator, docElement;
var winumerator, win;
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowMediator#getEnumerator%28%29
winumerator = Services.wm.getEnumerator(chromeWindowType);
winumerator = Services.wm.getEnumerator(null);
while ( winumerator.hasMoreElements() ) {
win = winumerator.getNext();
if ( !win.closed ) {
@ -630,14 +632,7 @@ var winWatcher = (function() {
win = winumerator.getNext()
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
if ( win.closed ) {
continue;
}
docElement = win.document && win.document.documentElement;
if ( !docElement ) {
continue;
}
if ( docElement.getAttribute('windowtype') === chromeWindowType ) {
if ( !win.closed ) {
windowToIdMap.set(win, windowIdGenerator++);
}
}