When a parent tab is moved to another tab group, then descendant tabs also should be moved to the group.

This commit is contained in:
Piro / SHIMODA Hiroshi 2011-10-30 05:03:44 +09:00
parent 7938d32944
commit e466b9bccd

View File

@ -619,6 +619,7 @@ TreeStyleTabBrowser.prototype = {
w.addEventListener('customizationchange', this, false); w.addEventListener('customizationchange', this, false);
w.addEventListener(this.kEVENT_TYPE_PRINT_PREVIEW_ENTERED, this, false); w.addEventListener(this.kEVENT_TYPE_PRINT_PREVIEW_ENTERED, this, false);
w.addEventListener(this.kEVENT_TYPE_PRINT_PREVIEW_EXITED, this, false); w.addEventListener(this.kEVENT_TYPE_PRINT_PREVIEW_EXITED, this, false);
w.addEventListener('tabviewhidden', this, true);
b.addEventListener('nsDOMMultipleTabHandlerTabsClosing', this, false); b.addEventListener('nsDOMMultipleTabHandlerTabsClosing', this, false);
@ -1783,6 +1784,7 @@ TreeStyleTabBrowser.prototype = {
w.removeEventListener('customizationchange', this, false); w.removeEventListener('customizationchange', this, false);
w.removeEventListener(this.kEVENT_TYPE_PRINT_PREVIEW_ENTERED, this, false); w.removeEventListener(this.kEVENT_TYPE_PRINT_PREVIEW_ENTERED, this, false);
w.removeEventListener(this.kEVENT_TYPE_PRINT_PREVIEW_EXITED, this, false); w.removeEventListener(this.kEVENT_TYPE_PRINT_PREVIEW_EXITED, this, false);
w.removeEventListener('tabviewhidden', this, true);
b.removeEventListener('nsDOMMultipleTabHandlerTabsClosing', this, false); b.removeEventListener('nsDOMMultipleTabHandlerTabsClosing', this, false);
@ -2452,6 +2454,13 @@ TreeStyleTabBrowser.prototype = {
case 'customizationchange': case 'customizationchange':
return this.updateCustomizedTabsToolbar(); return this.updateCustomizedTabsToolbar();
case 'tabviewhidden':
this.tabViewHiding = true;
this._addedCountClearTimer = this.window.setTimeout(function(aSelf) {
aSelf.tabViewHiding = false;
}, 0, this);
return;
case this.kEVENT_TYPE_PRINT_PREVIEW_ENTERED: case this.kEVENT_TYPE_PRINT_PREVIEW_ENTERED:
return this.onTreeStyleTabPrintPreviewEntered(aEvent); return this.onTreeStyleTabPrintPreviewEntered(aEvent);
@ -2467,6 +2476,7 @@ TreeStyleTabBrowser.prototype = {
}, },
lastScrollX : -1, lastScrollX : -1,
lastScrollY : -1, lastScrollY : -1,
tabViewHiding : false,
restoreLastScrollPosition : function TSTBrowser_restoreLastScrollPosition() restoreLastScrollPosition : function TSTBrowser_restoreLastScrollPosition()
{ {
@ -3041,19 +3051,25 @@ TreeStyleTabBrowser.prototype = {
// for TabView (Panorama aka Tab Candy) // for TabView (Panorama aka Tab Candy)
onTabVisibilityChanged : function TSTBrowser_onTabVisibilityChanged(aEvent) onTabVisibilityChanged : function TSTBrowser_onTabVisibilityChanged(aEvent)
{ {
var tab = aEvent.originalTarget;
if (this.tabViewHiding) {
this.updateInvertedTabContentsOrder(aEvent.originalTarget); this.updateInvertedTabContentsOrder(aEvent.originalTarget);
if (this.tabVisibilityChangedTimer) { if (this.tabVisibilityChangedTimer) {
this.window.clearTimeout(this.tabVisibilityChangedTimer); this.window.clearTimeout(this.tabVisibilityChangedTimer);
this.tabVisibilityChangedTimer = null; this.tabVisibilityChangedTimer = null;
} }
this.tabVisibilityChangedTabs.push(aEvent.originalTarget); this.tabVisibilityChangedTabs.push(tab);
this.tabVisibilityChangedTimer = this.window.setTimeout(function(aSelf) { this.tabVisibilityChangedTimer = this.window.setTimeout(function(aSelf) {
aSelf.tabVisibilityChangedTimer = null; aSelf.tabVisibilityChangedTimer = null;
var tabs = aSelf.tabVisibilityChangedTabs; var tabs = aSelf.tabVisibilityChangedTabs;
aSelf.tabVisibilityChangedTabs = []; aSelf.tabVisibilityChangedTabs = [];
aSelf.updateTreeByTabVisibility(tabs); aSelf.updateTreeByTabVisibility(tabs);
}, 0, this); }, 0, this);
}
else if (aEvent.type == 'TabHide') {
this.subtreeFollowParentAcrossTabGroups(tab);
}
}, },
tabVisibilityChangedTimer : null, tabVisibilityChangedTimer : null,
updateTreeByTabVisibility : function TSTBrowser_updateTreeByTabVisibility(aChangedTabs) updateTreeByTabVisibility : function TSTBrowser_updateTreeByTabVisibility(aChangedTabs)
@ -3127,6 +3143,32 @@ TreeStyleTabBrowser.prototype = {
} }
this.internallyTabMovingCount--; this.internallyTabMovingCount--;
}, },
tabViewTreeIsMoving : false,
subtreeFollowParentAcrossTabGroups : function TSTBrowser_subtreeFollowParentAcrossTabGroups(aParent)
{
if (this.tabViewTreeIsMoving) return;
let item = aParent._tabViewTabItem;
if (!item) return;
let group = item.parent;
if (!group) return;
this.tabViewTreeIsMoving = true;
this.internallyTabMovingCount++;
let w = this.window;
let b = this.mTabBrowser;
let lastCount = this.getAllTabs(b).snapshotLength - 1;
w.setTimeout(function(aSelf) {
aSelf.partTab(aParent);
b.moveTabTo(aParent, lastCount);
let descendantTabs = aSelf.getDescendantTabs(aParent);
descendantTabs.forEach(function(aTab) {
w.TabView.moveTabTo(aTab, group.id);
b.moveTabTo(aTab, lastCount);
});
aSelf.internallyTabMovingCount--;
aSelf.tabViewTreeIsMoving = false;
}, 0, this);
},
onTabRestoring : function TSTBrowser_onTabRestoring(aEvent) onTabRestoring : function TSTBrowser_onTabRestoring(aEvent)
{ {