Store the original state of the "Tabs on Top" for user's expectation correctly
This commit is contained in:
parent
b1b029686d
commit
7c6b3475ba
@ -585,7 +585,6 @@ pref("browser.link.open_newwindow.restriction.override", 0);
|
|||||||
pref("browser.tabs.loadFolderAndReplace.override", false);
|
pref("browser.tabs.loadFolderAndReplace.override", false);
|
||||||
pref("browser.tabs.insertRelatedAfterCurrent.override", false);
|
pref("browser.tabs.insertRelatedAfterCurrent.override", false);
|
||||||
pref("browser.tabs.insertRelatedAfterCurrent.override.force", true);
|
pref("browser.tabs.insertRelatedAfterCurrent.override.force", true);
|
||||||
pref("extensions.treestyletab.tabsOnTopShouldBeRestored", false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extra commands for selected tabs (Multiple Tab Handler)
|
* Extra commands for selected tabs (Multiple Tab Handler)
|
||||||
|
@ -1498,15 +1498,22 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
// remove ordinal for "tabs on top" https://bugzilla.mozilla.org/show_bug.cgi?id=544815
|
// remove ordinal for "tabs on top" https://bugzilla.mozilla.org/show_bug.cgi?id=544815
|
||||||
if (this.position == 'top') {
|
if (this.position == 'top') {
|
||||||
this.removeTabStripAttribute('ordinal');
|
this.removeTabStripAttribute('ordinal');
|
||||||
// Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=555987
|
|
||||||
// This should be done when the value of the "ordinal" attribute
|
|
||||||
// is modified dynamically. So, we don' have to do it before
|
|
||||||
// the browser window is completely initialized.
|
|
||||||
if (TabsOnTop && !this.windowService.isPopupWindow &&
|
if (TabsOnTop && !this.windowService.isPopupWindow &&
|
||||||
this.windowService.initialized) {
|
this.windowService.initialized) {
|
||||||
TabsOnTop.enabled = !TabsOnTop.enabled;
|
let currentState = TabsOnTop.enabled;
|
||||||
|
let originalState = this.getTreePref('tabsOnTop.originalState');
|
||||||
|
if (originalState !== null &&
|
||||||
|
currentState != originalState &&
|
||||||
|
this.windowService.tabsOnTopChangingByUI &&
|
||||||
|
!this.windowService.changingTabsOnTop)
|
||||||
|
this.setTreePref('tabsOnTop.originalState', currentState);
|
||||||
|
// Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=555987
|
||||||
|
// This should be done when the value of the "ordinal" attribute
|
||||||
|
// is modified dynamically. So, we don' have to do it before
|
||||||
|
// the browser window is completely initialized.
|
||||||
|
TabsOnTop.enabled = !currentState;
|
||||||
this.Deferred.next(function() {
|
this.Deferred.next(function() {
|
||||||
TabsOnTop.enabled = !TabsOnTop.enabled;
|
TabsOnTop.enabled = currentState;
|
||||||
}).error(this.defaultDeferredErrorHandler);
|
}).error(this.defaultDeferredErrorHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1525,10 +1532,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
if (TabsOnTop && !this.windowService.isPopupWindow) {
|
if (TabsOnTop && !this.windowService.isPopupWindow) {
|
||||||
let updateTabsOnTop = function() {
|
let updateTabsOnTop = function() {
|
||||||
let tabsWasOnTop = TabsOnTop.enabled;
|
self.windowService.updateTabsOnTop();
|
||||||
TabsOnTop.enabled = TabsOnTop.enabled && self.position == 'top' && self.fixed;
|
|
||||||
if (tabsWasOnTop && !TabsOnTop.enabled)
|
|
||||||
self.setTreePref('tabsOnTopShouldBeRestored', true);
|
|
||||||
};
|
};
|
||||||
// TabsOnTop.enabled is always "false" before the browser window is
|
// TabsOnTop.enabled is always "false" before the browser window is
|
||||||
// completely initialized. So, we have to check it with delay only
|
// completely initialized. So, we have to check it with delay only
|
||||||
@ -4467,24 +4471,27 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
onTabsOnTopSyncCommand : function TSTBrowser_onTabsOnTopSyncCommand(aEnabled)
|
onTabsOnTopSyncCommand : function TSTBrowser_onTabsOnTopSyncCommand(aEnabled)
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
|
this.windowService.tabsOnTopChangingByUI ||
|
||||||
!aEnabled ||
|
!aEnabled ||
|
||||||
this.position != 'top' ||
|
this.position != 'top' ||
|
||||||
this.fixed ||
|
this.fixed ||
|
||||||
!this.windowService.isPopupWindow
|
this.windowService.isPopupWindow
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
this.windowService.tabsOnTopChangingByUI = true;
|
||||||
var self = this;
|
var self = this;
|
||||||
this.Deferred
|
this.Deferred
|
||||||
.next(function() {
|
.next(function() {
|
||||||
self.windowService.toggleFixed(self.mTabBrowser);
|
self.windowService.toggleFixed(self.mTabBrowser);
|
||||||
})
|
})
|
||||||
.next(function() {
|
.next(function() {
|
||||||
if (self.window.TabsOnTop.enabled != aEnabled) {
|
if (self.window.TabsOnTop.enabled != aEnabled)
|
||||||
dump('onTabsOnTopSyncCommand, set to '+aEnabled+'\n');
|
|
||||||
self.window.TabsOnTop.enabled = aEnabled;
|
self.window.TabsOnTop.enabled = aEnabled;
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.error(this.defaultDeferredErrorHandler);
|
.error(this.defaultDeferredErrorHandler)
|
||||||
|
.next(function() {
|
||||||
|
self.windowService.tabsOnTopChangingByUI = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onTreeStyleTabPrintPreviewEntered : function TSTBrowser_onTreeStyleTabPrintPreviewEntered(aEvent)
|
onTreeStyleTabPrintPreviewEntered : function TSTBrowser_onTreeStyleTabPrintPreviewEntered(aEvent)
|
||||||
|
@ -387,8 +387,8 @@ TreeStyleTabWindow.prototype = {
|
|||||||
namespace = void(0);
|
namespace = void(0);
|
||||||
var self = this;
|
var self = this;
|
||||||
var restorePrefs = function() {
|
var restorePrefs = function() {
|
||||||
if (prefs.getPref('extensions.treestyletab.tabsOnTopShouldBeRestored')) {
|
if (prefs.getPref('extensions.treestyletab.tabsOnTop.originalState')) {
|
||||||
prefs.clearPref('extensions.treestyletab.tabsOnTopShouldBeRestored');
|
prefs.clearPref('extensions.treestyletab.tabsOnTop.originalState');
|
||||||
try {
|
try {
|
||||||
self.browser.treeStyleTab.position = 'top';
|
self.browser.treeStyleTab.position = 'top';
|
||||||
}
|
}
|
||||||
@ -980,25 +980,40 @@ TreeStyleTabWindow.prototype = {
|
|||||||
updateTabsOnTop : function TSTWindow_updateTabsOnTop()
|
updateTabsOnTop : function TSTWindow_updateTabsOnTop()
|
||||||
{
|
{
|
||||||
var w = this.window;
|
var w = this.window;
|
||||||
if (this.isPopupWindow || !('TabsOnTop' in w) || !('enabled' in w.TabsOnTop))
|
if (
|
||||||
|
this.isPopupWindow ||
|
||||||
|
this.tabsOnTopChangingByUI ||
|
||||||
|
this.tabsOnTopChangingByTST ||
|
||||||
|
!('TabsOnTop' in w) ||
|
||||||
|
!('enabled' in w.TabsOnTop)
|
||||||
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var TabsOnTop = w.TabsOnTop;
|
this.tabsOnTopChangingByTST = true;
|
||||||
if (!('_tabsOnTopDefaultState' in this))
|
|
||||||
this._tabsOnTopDefaultState = TabsOnTop.enabled;
|
|
||||||
|
|
||||||
if (this.browser.treeStyleTab.position != 'top' ||
|
try {
|
||||||
!this.browser.treeStyleTab.fixed) {
|
var TabsOnTop = w.TabsOnTop;
|
||||||
if (TabsOnTop.enabled) {
|
var originalState = this.getTreePref('tabsOnTop.originalState');
|
||||||
TabsOnTop.enabled = false;
|
if (originalState === null) {
|
||||||
this.setTreePref('tabsOnTopShouldBeRestored', true);
|
let current = this.getDefaultPref('browser.tabs.onTop') === null ?
|
||||||
|
TabsOnTop.enabled :
|
||||||
|
this.getPref('browser.tabs.onTop') ;
|
||||||
|
this.setTreePref('tabsOnTop.originalState', originalState = current);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.browser.treeStyleTab.position != 'top' ||
|
||||||
|
!this.browser.treeStyleTab.fixed) {
|
||||||
|
if (TabsOnTop.enabled)
|
||||||
|
TabsOnTop.enabled = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (TabsOnTop.enabled != originalState)
|
||||||
|
TabsOnTop.enabled = originalState;
|
||||||
|
this.clearTreePref('tabsOnTop.originalState');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ('_tabsOnTopDefaultState' in this) {
|
finally {
|
||||||
if (TabsOnTop.enabled!= this._tabsOnTopDefaultState)
|
this.tabsOnTopChangingByTST = false;
|
||||||
TabsOnTop.enabled = this._tabsOnTopDefaultState;
|
|
||||||
delete this._tabsOnTopDefaultState;
|
|
||||||
this.setTreePref('tabsOnTopShouldBeRestored', false);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user