Apply tree structure for duplicated tabs after they are completely duplicated.
Tree strucutre of duplicated tabs is broken with a delay, because duplicateTab() applies tab's state asynchronously. The delayed restoration breaks constructed tree. Thus we have to wait all tabs are completely duplicated.
This commit is contained in:
parent
1e77f1cee6
commit
877a65e29b
@ -6519,6 +6519,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
|||||||
|
|
||||||
var tabs = this.getTabs(targetBrowser);
|
var tabs = this.getTabs(targetBrowser);
|
||||||
var lastTabIndex = tabs[tabs.length -1]._tPos;
|
var lastTabIndex = tabs[tabs.length -1]._tPos;
|
||||||
|
var promisedDuplicatedTabs = [];
|
||||||
for (let i in aTabs)
|
for (let i in aTabs)
|
||||||
{
|
{
|
||||||
let tab = aTabs[i];
|
let tab = aTabs[i];
|
||||||
@ -6532,7 +6533,15 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
|||||||
|
|
||||||
if (aOptions.duplicate) {
|
if (aOptions.duplicate) {
|
||||||
tab = this.duplicateTabAsOrphan(tab);
|
tab = this.duplicateTabAsOrphan(tab);
|
||||||
|
let promise = new Promise(function(aResolve, aReject) {
|
||||||
|
let onTabRestoring = function() {
|
||||||
|
tab.removeEventListener('SSTabRestoring', onTabRestoring, false);
|
||||||
|
aResolve(tab);
|
||||||
|
};
|
||||||
|
tab.addEventListener('SSTabRestoring', onTabRestoring, false);
|
||||||
|
});
|
||||||
newTabs.push(tab);
|
newTabs.push(tab);
|
||||||
|
promisedDuplicatedTabs.push(promise);
|
||||||
}
|
}
|
||||||
else if (sourceService != this) {
|
else if (sourceService != this) {
|
||||||
tab = this.importTab(tab);
|
tab = this.importTab(tab);
|
||||||
@ -6562,6 +6571,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
|||||||
sourceService.closeOwner(sourceBrowser);
|
sourceService.closeOwner(sourceBrowser);
|
||||||
|
|
||||||
if (newTabs.length) {
|
if (newTabs.length) {
|
||||||
|
Promise.all(promisedDuplicatedTabs).then((function() {
|
||||||
log('moveTabsInternal: applying tree structure for new ' + newTabs.length + ' tabs');
|
log('moveTabsInternal: applying tree structure for new ' + newTabs.length + ' tabs');
|
||||||
this.applyTreeStructureToTabs(
|
this.applyTreeStructureToTabs(
|
||||||
newTabs,
|
newTabs,
|
||||||
@ -6570,6 +6580,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
|||||||
return !aCollapsed
|
return !aCollapsed
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
}).bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = collapsedStates.length - 1; i > -1; i--)
|
for (let i = collapsedStates.length - 1; i > -1; i--)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user