mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 01:57:00 +00:00
Bug 737032 - add isValidXULTab() method to ease tab checking r=ttaubert
This commit is contained in:
parent
8b443bebd8
commit
d353100cfc
@ -1192,7 +1192,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||
addAppTab: function GroupItem_addAppTab(xulTab, options) {
|
||||
GroupItems.getAppTabFavIconUrl(xulTab, function(iconUrl) {
|
||||
// The tab might have been removed or unpinned while waiting.
|
||||
if (xulTab.closing || !xulTab.parentNode || !xulTab.pinned)
|
||||
if (!Utils.isValidXULTab(xulTab) || !xulTab.pinned)
|
||||
return;
|
||||
|
||||
let self = this;
|
||||
|
@ -636,6 +636,15 @@ let Utils = {
|
||||
return object instanceof Ci.nsIDOMElement;
|
||||
},
|
||||
|
||||
// ----------
|
||||
// Function: isValidXULTab
|
||||
// A xulTab is valid if it has not been closed,
|
||||
// and it has not been removed from the DOM
|
||||
// Returns true if the tab is valid.
|
||||
isValidXULTab: function Utils_isValidXULTab(xulTab) {
|
||||
return !xulTab.closing && xulTab.parentNode;
|
||||
},
|
||||
|
||||
// ----------
|
||||
// Function: isNumber
|
||||
// Returns true if the argument is a valid number.
|
||||
|
@ -239,7 +239,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||
// Store persistent for this object.
|
||||
save: function TabItem_save() {
|
||||
try {
|
||||
if (!this.tab || this.tab.parentNode == null || !this._reconnected) // too soon/late to save
|
||||
if (!this.tab || !Utils.isValidXULTab(this.tab) || !this._reconnected) // too soon/late to save
|
||||
return;
|
||||
|
||||
let data = this.getStorageData();
|
||||
@ -571,7 +571,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||
|
||||
Utils.assert(Utils.isRect(this.bounds), 'TabItem.setBounds: this.bounds is not a real rectangle!');
|
||||
|
||||
if (!this.parent && this.tab.parentNode != null)
|
||||
if (!this.parent && Utils.isValidXULTab(this.tab))
|
||||
this.setTrenches(rect);
|
||||
|
||||
this.save();
|
||||
|
@ -60,7 +60,7 @@ let AllTabs = {
|
||||
},
|
||||
|
||||
get tabs() {
|
||||
return Array.filter(gBrowser.tabs, function (tab) !tab.closing);
|
||||
return Array.filter(gBrowser.tabs, function (tab) Utils.isValidXULTab(tab));
|
||||
},
|
||||
|
||||
register: function AllTabs_register(eventName, callback) {
|
||||
|
@ -791,7 +791,7 @@ let UI = {
|
||||
if (gBrowser.tabs.length > 1) {
|
||||
// Don't return to TabView if there are any app tabs
|
||||
for (let a = 0; a < gBrowser._numPinnedTabs; a++) {
|
||||
if (!gBrowser.tabs[a].closing)
|
||||
if (Utils.isValidXULTab(gBrowser.tabs[a]))
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user