Bug 579222 - Expose a .visibleTabs property on the tabbrowser [r=iangilman]

Add .visibleTabs to tabbrowser and use local dereferences instead of gBrowser when possible.

--HG--
extra : rebase_source : c64695d6b437927a0d6fbae1b37ad2e17dc690c7
This commit is contained in:
Edward Lee 2010-07-16 13:23:03 -07:00
parent 6018174bc3
commit b5609139aa
4 changed files with 10 additions and 20 deletions

View File

@ -486,7 +486,7 @@ var PlacesCommandHook = {
var tabList = [];
var seenURIs = {};
var tabs = TabCandy.getVisibleTabs();
var tabs = gBrowser.visibleTabs;
for (var i = 0; i < tabs.length; ++i) {
let uri = tabs[i].linkedBrowser.currentURI;

View File

@ -51,18 +51,6 @@ var TabCandy = {
return (window.document.getElementById("tab-candy-deck").selectedIndex == 1);
},
getVisibleTabs: function() {
let visibleTabs = [];
let length = gBrowser.tabs.length;
for (let i = 0; i < length; i++) {
if (!gBrowser.tabs[i].collapsed) {
visibleTabs.push(gBrowser.tabs[i]);
}
}
return visibleTabs;
},
getWindowTitle: function() {
var brandBundle = document.getElementById("bundle_brand");
var brandShortName = brandBundle.getString("brandShortName");

View File

@ -6729,7 +6729,7 @@ var gBookmarkAllTabsHandler = {
},
_updateCommandState: function BATH__updateCommandState(aTabClose) {
var numTabs = TabCandy.getVisibleTabs().length;
var numTabs = gBrowser.visibleTabs.length;
// The TabClose event is fired before the tab is removed from the DOM
if (aTabClose)
@ -7752,7 +7752,7 @@ var TabContextMenu = {
updateContextMenu: function updateContextMenu(aPopupMenu) {
this.contextTab = document.popupNode.localName == "tab" ?
document.popupNode : gBrowser.selectedTab;
var disabled = TabCandy.getVisibleTabs().length == 1;
var disabled = gBrowser.visibleTabs.length == 1;
var menuItems = aPopupMenu.getElementsByAttribute("tbattr", "tabbrowser-multiple");
for (var i = 0; i < menuItems.length; i++)
menuItems[i].disabled = disabled;

View File

@ -88,6 +88,8 @@
<field name="tabs" readonly="true">
this.tabContainer.childNodes;
</field>
<property name="visibleTabs" readonly="true"
onget="return Array.filter(this.tabs, function(tab) !tab.collapsed);"/>
<field name="mURIFixup" readonly="true">
Components.classes["@mozilla.org/docshell/urifixup;1"]
.getService(Components.interfaces.nsIURIFixup);
@ -1225,7 +1227,7 @@
<![CDATA[
var tabsToClose = this.tabs.length;
if (!aAll)
tabsToClose = (TabCandy.getVisibleTabs().length - 1);
tabsToClose = this.visibleTabs.length - 1;
if (tabsToClose <= 1)
return true;
@ -1273,7 +1275,7 @@
<body>
<![CDATA[
if (this.warnAboutClosingTabs(false)) {
var tabs = TabCandy.getVisibleTabs();
var tabs = this.visibleTabs;
this.selectedTab = aTab;
for (let i = tabs.length - 1; i >= 0; --i) {
@ -1586,7 +1588,7 @@
<method name="reloadAllTabs">
<body>
<![CDATA[
var tabs = TabCandy.getVisibleTabs();
var tabs = this.visibleTabs;
var l = tabs.length;
for (var i = 0; i < l; i++) {
try {
@ -2508,7 +2510,7 @@
else {
let tab = this.childNodes.item(this.tabbrowser._numPinnedTabs);
if (tab && tab.collapsed) {
tab = TabCandy.getVisibleTabs()[0];
tab = this.tabbrowser.visibleTabs[0];
}
if (tab && tab.getBoundingClientRect().width > this.mTabClipWidth)
this.setAttribute("closebuttons", "alltabs");
@ -3294,7 +3296,7 @@
<![CDATA[
// set up the menu popup
var tabcontainer = gBrowser.tabContainer;
var tabs = TabCandy.getVisibleTabs();
var tabs = gBrowser.visibleTabs;
// Listen for changes in the tab bar.
tabcontainer.addEventListener("TabOpen", this, false);