[Pkg-mozext-commits] [tabmixplus] 25/26: Don't close window when closing blank tab that opened from downloading link
David Prévot
taffit at moszumanska.debian.org
Fri Mar 25 21:56:17 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag 0.4.2.3pre.160319a1
in repository tabmixplus.
commit b72d47a4eed1d512af6fe8ed4d317681e1f8b2ce
Author: onemen <tabmix.onemen at gmail.com>
Date: Fri Mar 18 20:03:38 2016 +0200
Don't close window when closing blank tab that opened from downloading link
---
chrome/content/links/removeBlankTab.js | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/chrome/content/links/removeBlankTab.js b/chrome/content/links/removeBlankTab.js
index 68e94c4..f70ec9a 100644
--- a/chrome/content/links/removeBlankTab.js
+++ b/chrome/content/links/removeBlankTab.js
@@ -1,5 +1,11 @@
"use strict";
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Services",
+ "resource://gre/modules/Services.jsm");
+
var TabmixRemoveBlankTab = {
initialize: function() {
switch (window.document.documentElement.id) {
@@ -68,7 +74,15 @@ var TabmixRemoveBlankTab = {
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow)
.wrappedJSObject;
- result.b = result.win.gBrowser.getBrowserForDocument(doc);
+ let tabBrowser = result.win.gBrowser;
+ result.b = tabBrowser.getBrowserForDocument(doc);
+ if (!result.b) {
+ // try to find tab with _tabmix_downloadingTimeout
+ let tabs = Array.prototype.filter.call(tabBrowser.tabs, t => t._tabmix_downloadingTimeout);
+ if (tabs.length) {
+ result.b = tabs[0].linkedBrowser;
+ }
+ }
}
return result;
},
@@ -78,8 +92,17 @@ var TabmixRemoveBlankTab = {
aEvent.currentTarget.removeEventListener("unload", _unload, false);
if (win && !win.closed) {
win.setTimeout(function() {
- if (win && win.gBrowser && tab && tab.parentNode)
- win.gBrowser.removeTab(tab, {animate: false});
+ let tabBrowser = win && win.gBrowser;
+ if (!tabBrowser || !tab || !tab.parentNode) {
+ return;
+ }
+ // don't remove the tab if it going to close the window
+ let closeWindow = tabBrowser.tabs.length - tabBrowser._removingTabs.length == 1 &&
+ Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab");
+ if (closeWindow) {
+ return;
+ }
+ tabBrowser.removeTab(tab, {animate: false});
}, 250);
}
}, false);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list