Bug 586712 - Lighten tabOnFocus (and rename it), [r=dolske a=dolske]

--HG--
extra : rebase_source : 737e30c88ff59739149aa238dad1d558c580c783
This commit is contained in:
Raymond Lee 2010-08-17 22:13:45 +08:00
parent a116c7afc9
commit 95adc882fc
3 changed files with 38 additions and 57 deletions

View File

@ -1604,15 +1604,13 @@ window.GroupItems = {
},
// ----------
// Function: updateTabBar
// Function: _updateTabBar
// Hides and shows tabs in the tab bar based on the active groupItem or
// currently active orphan tabItem
updateTabBar: function() {
_updateTabBar: function() {
if (!window.UI)
return; // called too soon
// Utils.log('updateTabBar', this._activeGroupItem, this._activeOrphanTab);
if (!this._activeGroupItem && !this._activeOrphanTab) {
Utils.assert(false, "There must be something to show in the tab bar!");
return;
@ -1623,6 +1621,21 @@ window.GroupItems = {
gBrowser.showOnlyTheseTabs(tabItems.map(function(item) item.tab));
},
// ----------
// Function: updateActiveGroupItemAndTabBar
// Sets active group item and updates tab bar
updateActiveGroupItemAndTabBar: function(tabItem) {
if (tabItem.parent) {
let groupItem = tabItem.parent;
this.setActiveGroupItem(groupItem);
groupItem.setActiveTab(tabItem);
} else {
this.setActiveGroupItem(null);
this.setActiveOrphanTab(tabItem);
}
this._updateTabBar();
},
// ----------
// Function: getOrphanedTabs
// Returns an array of all tabs that aren't in a groupItem.
@ -1749,7 +1762,7 @@ window.GroupItems = {
}
if (shouldUpdateTabBar)
this.updateTabBar();
this._updateTabBar();
else if (shouldShowTabView) {
tab.tabItem.setZoomPrep(false);
UI.showTabView();

View File

@ -525,27 +525,14 @@ window.TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
TabItems.resumePainting();
// If it's not focused, the onFocus lsitener would handle it.
if (gBrowser.selectedTab == tab)
UI.tabOnFocus(tab);
UI.onTabSelect(tab);
else
gBrowser.selectedTab = tab;
$tabEl
.css(orig.css())
.removeClass("front");
// If the tab is in a groupItem set then set the active
// groupItem to the tab's parent.
if (self.parent) {
var gID = self.parent.id;
var groupItem = GroupItems.groupItem(gID);
GroupItems.setActiveGroupItem(groupItem);
groupItem.setActiveTab(self);
} else {
GroupItems.setActiveGroupItem(null);
GroupItems.setActiveOrphanTab(self);
}
GroupItems.updateTabBar();
if (isNewBlankTab)
gWindow.gURLBar.focus();

View File

@ -453,19 +453,17 @@ var UIManager = {
if (tab.ownerDocument.defaultView != gWindow)
return;
self.tabOnFocus(tab);
self.onTabSelect(tab);
});
},
// ----------
// Function: tabOnFocus
// Function: onTabSelect
// Called when the user switches from one tab to another outside of the TabView UI.
tabOnFocus: function(tab) {
var self = this;
var focusTab = tab;
var currentTab = this._currentTab;
onTabSelect: function(tab) {
let currentTab = this._currentTab;
this._currentTab = tab;
this._currentTab = focusTab;
// if the last visible tab has just been closed, don't show the chrome UI.
if (this._isTabViewVisible() &&
(this._closedLastVisibleTab || this._closedSelectedTabInTabView)) {
@ -473,50 +471,33 @@ var UIManager = {
this._closedSelectedTabInTabView = false;
return;
}
// reset these vars, just in case.
this._closedLastVisibleTab = false;
this._closedSelectedTabInTabView = false;
// if TabView is visible but we didn't just close the last tab or
// selected tab, show chrome.
if (this._isTabViewVisible())
this.hideTabView();
// reset these vars, just in case.
this._closedLastVisibleTab = false;
this._closedSelectedTabInTabView = false;
// have things have changed while we were in timeout?
if (focusTab != self._currentTab)
return;
let oldItem = null;
let newItem = null;
if (focusTab && focusTab.tabItem) {
newItem = focusTab.tabItem;
if (newItem.parent)
GroupItems.setActiveGroupItem(newItem.parent);
else {
GroupItems.setActiveGroupItem(null);
GroupItems.setActiveOrphanTab(newItem);
}
GroupItems.updateTabBar();
if (currentTab && currentTab.tabItem)
oldItem = currentTab.tabItem;
if (tab && tab.tabItem) {
newItem = tab.tabItem;
GroupItems.updateActiveGroupItemAndTabBar(newItem);
}
// ___ prepare for when we return to TabView
let oldItem = null;
if (currentTab && currentTab.tabItem)
oldItem = currentTab.tabItem;
if (newItem != oldItem) {
if (oldItem)
oldItem.setZoomPrep(false);
// if the last visible tab is removed, don't set zoom prep because
// we should be in the TabView interface.
let visibleTabCount = gBrowser.visibleTabs.length;
if (visibleTabCount > 0 && newItem && !self._isTabViewVisible())
if (newItem)
newItem.setZoomPrep(true);
}
// the tab is already focused so the new and old items are the same.
else if (oldItem)
oldItem.setZoomPrep(!self._isTabViewVisible());
} else if (oldItem)
oldItem.setZoomPrep(true);
},
// ----------