tabs were unexpectedly rearranged after you exited from Panorama.
This commit is contained in:
parent
5d9c5f3a74
commit
726a4ae03f
@ -2428,9 +2428,14 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
return this.updateCustomizedTabsToolbar();
|
return this.updateCustomizedTabsToolbar();
|
||||||
|
|
||||||
case 'tabviewhidden':
|
case 'tabviewhidden':
|
||||||
|
// step 1, now we are exitting from Panorama mode.
|
||||||
this.tabViewHiding = true;
|
this.tabViewHiding = true;
|
||||||
this._addedCountClearTimer = this.window.setTimeout(function(aSelf) {
|
this.window.setTimeout(function(aSelf) {
|
||||||
|
// step 2, this is better time to handle TabShown and TabHidden events.
|
||||||
|
this.window.setTimeout(function(aSelf) {
|
||||||
|
// step 3, we are now in the normal mode.
|
||||||
aSelf.tabViewHiding = false;
|
aSelf.tabViewHiding = false;
|
||||||
|
}, 0, aSelf);
|
||||||
}, 0, this);
|
}, 0, this);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -3034,25 +3039,60 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
// for TabView (Panorama aka Tab Candy)
|
// for TabView (Panorama aka Tab Candy)
|
||||||
onTabVisibilityChanged : function TSTBrowser_onTabVisibilityChanged(aEvent)
|
onTabVisibilityChanged : function TSTBrowser_onTabVisibilityChanged(aEvent)
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Note: On this timing, we cannot know that which is the reason of this
|
||||||
|
* event, by exitting from Panorama or the "Move to Group" command in the
|
||||||
|
* context menu on tabs. So, we have to do operations with a delay to use
|
||||||
|
* "tabViewHiding" flag which is initialized in the next event loop.
|
||||||
|
*/
|
||||||
|
|
||||||
var tab = aEvent.originalTarget;
|
var tab = aEvent.originalTarget;
|
||||||
if (this.tabViewHiding) {
|
this.updateInvertedTabContentsOrder(tab);
|
||||||
this.updateInvertedTabContentsOrder(aEvent.originalTarget);
|
this.tabVisibilityChangedTabs.push({
|
||||||
|
tab : tab,
|
||||||
|
type : aEvent.type
|
||||||
|
});
|
||||||
|
|
||||||
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(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;
|
||||||
|
if (!tabs.length)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (aSelf.tabViewHiding) {
|
||||||
|
// We should clear it first, because updateTreeByTabVisibility() never change visibility of tabs.
|
||||||
aSelf.tabVisibilityChangedTabs = [];
|
aSelf.tabVisibilityChangedTabs = [];
|
||||||
aSelf.updateTreeByTabVisibility(tabs);
|
aSelf.updateTreeByTabVisibility(tabs.map(function(aChanged) { return aChanged.tab; }));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// For tabs moved by "Move to Group" command in the context menu on tabs
|
||||||
|
var processedTabs = {};
|
||||||
|
/**
|
||||||
|
* subtreeFollowParentAcrossTabGroups() can change visibility of child tabs, so,
|
||||||
|
* we must not clear tabVisibilityChangedTabs here, and we have to use
|
||||||
|
* simple "for" loop instead of Array.prototype.forEach.
|
||||||
|
*/
|
||||||
|
for (let i = 0; i < aSelf.tabVisibilityChangedTabs.length; i++)
|
||||||
|
{
|
||||||
|
let changed = aSelf.tabVisibilityChangedTabs[i];
|
||||||
|
let tab = changed.tab;
|
||||||
|
if (aSelf.getAncestorTabs(tab).some(function(aTab) {
|
||||||
|
return processedTabs[aTab.getAttribute(aSelf.kID)];
|
||||||
|
}))
|
||||||
|
continue;
|
||||||
|
aSelf.subtreeFollowParentAcrossTabGroups(tab);
|
||||||
|
processedTabs[tab.getAttribute(aSelf.kID)] = true;
|
||||||
|
}
|
||||||
|
// now we can clear it!
|
||||||
|
aSelf.tabVisibilityChangedTabs = [];
|
||||||
|
}
|
||||||
}, 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)
|
||||||
@ -3130,27 +3170,28 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
subtreeFollowParentAcrossTabGroups : function TSTBrowser_subtreeFollowParentAcrossTabGroups(aParent)
|
subtreeFollowParentAcrossTabGroups : function TSTBrowser_subtreeFollowParentAcrossTabGroups(aParent)
|
||||||
{
|
{
|
||||||
if (this.tabViewTreeIsMoving) return;
|
if (this.tabViewTreeIsMoving) return;
|
||||||
let item = aParent._tabViewTabItem;
|
|
||||||
|
var item = aParent._tabViewTabItem;
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
let group = item.parent;
|
|
||||||
|
var group = item.parent;
|
||||||
if (!group) return;
|
if (!group) return;
|
||||||
|
|
||||||
this.tabViewTreeIsMoving = true;
|
this.tabViewTreeIsMoving = true;
|
||||||
this.internallyTabMovingCount++;
|
this.internallyTabMovingCount++;
|
||||||
let w = this.window;
|
var w = this.window;
|
||||||
let b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
let lastCount = this.getAllTabs(b).snapshotLength - 1;
|
var lastCount = this.getAllTabs(b).snapshotLength - 1;
|
||||||
w.setTimeout(function(aSelf) {
|
|
||||||
aSelf.detachTab(aParent);
|
this.detachTab(aParent);
|
||||||
b.moveTabTo(aParent, lastCount);
|
b.moveTabTo(aParent, lastCount);
|
||||||
let descendantTabs = aSelf.getDescendantTabs(aParent);
|
var descendantTabs = this.getDescendantTabs(aParent);
|
||||||
descendantTabs.forEach(function(aTab) {
|
descendantTabs.forEach(function(aTab) {
|
||||||
w.TabView.moveTabTo(aTab, group.id);
|
w.TabView.moveTabTo(aTab, group.id);
|
||||||
b.moveTabTo(aTab, lastCount);
|
b.moveTabTo(aTab, lastCount);
|
||||||
});
|
});
|
||||||
aSelf.internallyTabMovingCount--;
|
this.internallyTabMovingCount--;
|
||||||
aSelf.tabViewTreeIsMoving = false;
|
this.tabViewTreeIsMoving = false;
|
||||||
}, 0, this);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onTabRestoring : function TSTBrowser_onTabRestoring(aEvent)
|
onTabRestoring : function TSTBrowser_onTabRestoring(aEvent)
|
||||||
|
Loading…
Reference in New Issue
Block a user