mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
code review
This commit is contained in:
parent
1598273d6a
commit
5a9b96d7b5
@ -1152,14 +1152,14 @@ var tabWatcher = (function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var onWindowLoad = function() {
|
var onWindowLoad = function(win) {
|
||||||
attachToTabBrowser(this);
|
attachToTabBrowser(win);
|
||||||
};
|
};
|
||||||
|
|
||||||
var onWindowUnload = function() {
|
var onWindowUnload = function(win) {
|
||||||
vAPI.contextMenu.unregister(this.document);
|
vAPI.contextMenu.unregister(win.document);
|
||||||
|
|
||||||
var tabBrowser = getTabBrowser(this);
|
var tabBrowser = getTabBrowser(win);
|
||||||
if ( !tabBrowser ) {
|
if ( !tabBrowser ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1202,7 +1202,7 @@ var tabWatcher = (function() {
|
|||||||
URI = browser.currentURI;
|
URI = browser.currentURI;
|
||||||
// Close extension tabs
|
// Close extension tabs
|
||||||
if ( URI.schemeIs('chrome') && URI.host === location.host ) {
|
if ( URI.schemeIs('chrome') && URI.host === location.host ) {
|
||||||
vAPI.tabs._remove(tab, getTabBrowser(this));
|
vAPI.tabs._remove(tab, getTabBrowser(win));
|
||||||
}
|
}
|
||||||
tabId = browserToTabIdMap.get(browser);
|
tabId = browserToTabIdMap.get(browser);
|
||||||
if ( tabId !== undefined ) {
|
if ( tabId !== undefined ) {
|
||||||
@ -1215,22 +1215,26 @@ var tabWatcher = (function() {
|
|||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowWatcher
|
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowWatcher
|
||||||
var windowWatcher = {
|
var windowWatcher = {
|
||||||
observe: function(subject, topic) {
|
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
|
||||||
|
// "nsISupports which can be ... QueryInterfaced to an
|
||||||
|
// "nsIDOMWindow."
|
||||||
var win;
|
var win;
|
||||||
try {
|
try {
|
||||||
win = subject.QueryInterface(Ci.nsIInterfaceRequestor)
|
win = aSubject.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Ci.nsIDOMWindow);
|
.getInterface(Ci.nsIDOMWindow);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
}
|
}
|
||||||
if ( !win ) {
|
if ( !win ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( topic === 'domwindowopened' ) {
|
if ( topic === 'domwindowopened' ) {
|
||||||
onWindowLoad.call(win);
|
onWindowLoad(win);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( topic === 'domwindowclosed' ) {
|
if ( topic === 'domwindowclosed' ) {
|
||||||
onWindowUnload.call(win);
|
onWindowUnload(win);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1240,7 +1244,7 @@ var tabWatcher = (function() {
|
|||||||
var start = function() {
|
var start = function() {
|
||||||
var tabBrowser, tabs, tab;
|
var tabBrowser, tabs, tab;
|
||||||
for ( var win of vAPI.tabs.getWindows() ) {
|
for ( var win of vAPI.tabs.getWindows() ) {
|
||||||
onWindowLoad.call(win);
|
onWindowLoad(win);
|
||||||
tabBrowser = getTabBrowser(win);
|
tabBrowser = getTabBrowser(win);
|
||||||
if ( tabBrowser === null ) {
|
if ( tabBrowser === null ) {
|
||||||
continue;
|
continue;
|
||||||
@ -1264,7 +1268,7 @@ var tabWatcher = (function() {
|
|||||||
Services.ww.unregisterNotification(windowWatcher);
|
Services.ww.unregisterNotification(windowWatcher);
|
||||||
|
|
||||||
for ( var win of vAPI.tabs.getWindows() ) {
|
for ( var win of vAPI.tabs.getWindows() ) {
|
||||||
onWindowUnload.call(win);
|
onWindowUnload(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
browserToTabIdMap.clear();
|
browserToTabIdMap.clear();
|
||||||
@ -2447,7 +2451,12 @@ vAPI.toolbarButton = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tbb.closePopup = function() {
|
tbb.closePopup = function() {
|
||||||
toolbarButtonPanel.hidePopup();
|
// `hidePopup` reported as not existing while testing legacy button
|
||||||
|
// on FF 41.0.2.
|
||||||
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1151796
|
||||||
|
if ( typeof toolbarButtonPanel.hidePopup === 'function' ) {
|
||||||
|
toolbarButtonPanel.hidePopup();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Find the place to put the button
|
// Find the place to put the button
|
||||||
|
Loading…
Reference in New Issue
Block a user