Restore tree structure on the startup correctly, with Firefox 29 and later

This commit is contained in:
YUKI Hiroshi 2014-03-31 14:54:14 +09:00
parent f58cd7a994
commit 0a0a4003b5
3 changed files with 56 additions and 1 deletions

View File

@ -1098,6 +1098,19 @@ var TreeStyleTabBase = {
).booleanValue;
},
getTabFromBrowser : function TSTBase_getTabFromBrowser(aBrowser, aTabBrowser)
{
var b = aTabBrowser || this.browser;
var tabs = this.getAllTabs(b);
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{
let tab = tabs[i];
if (tab.linkedBrowser == aBrowser)
return tab;
}
return null;
},
getTabFromFrame : function TSTBase_getTabFromFrame(aFrame, aTabBrowser)
{
var b = aTabBrowser || this.browser;

View File

@ -244,7 +244,23 @@ let TreeStyleTabUtils = {
},
isTabNotRestoredYet: function(aTab)
get shouldUseMessageManager()
{
if (this._shouldUseMessageManager !== null)
return this._shouldUseMessageManager;
try { // detect Firefox 29 and later
Cu.import('resource:///modules/sessionstore/ContentRestore.jsm', {});
this._shouldUseMessageManager = true;
}
catch(e) {
this._shouldUseMessageManager = false;
}
return this._shouldUseMessageManager;
},
_shouldUseMessageManager: undefined,
isTabNotRestoredYet : function utils_isTabNotRestoredYet(aTab)
{
var browser = aTab.linkedBrowser;
// Firefox 25 and later. See: https://bugzilla.mozilla.org/show_bug.cgi?id=867142

View File

@ -365,6 +365,10 @@ TreeStyleTabWindow.prototype = {
w.addEventListener('beforecustomization', this, true);
w.addEventListener('aftercustomization', this, false);
// for Firefox 29 and later, after https://bugzilla.mozilla.org/show_bug.cgi?id=942374
if (w.messageManager && utils.shouldUseMessageManager)
w.messageManager.addMessageListener('SessionStore:restoreTabContentStarted', this);
this.fullscreenObserver = new FullscreenObserver(this.window);
this.initUIShowHideObserver();
@ -495,6 +499,10 @@ TreeStyleTabWindow.prototype = {
w.removeEventListener('beforecustomization', this, true);
w.removeEventListener('aftercustomization', this, false);
// for Firefox 29 and later, after https://bugzilla.mozilla.org/show_bug.cgi?id=942374
if (w.messageManager && utils.shouldUseMessageManager)
w.messageManager.removeMessageListener('SessionStore:restoreTabContentStarted', this);
this.fullscreenObserver.destroy();
delete this.fullscreenObserver;
@ -851,6 +859,24 @@ TreeStyleTabWindow.prototype = {
prefs.getPref('browser.ctrlTab.previews');
},
// for Firefox 29 and later, after https://bugzilla.mozilla.org/show_bug.cgi?id=942374
receiveMessage : function TSTWindow_receiveMessage(aMessage)
{
var browser = aMessage.target;
var tabbrowser = this.getTabBrowserFromChild(browser);
if (!tabbrowser)
return;
var tab = tabbrowser.treeStyleTab.getTabFromBrowser(browser);
if (!tab)
return;
switch (aMessage.name)
{
case 'SessionStore:restoreTabContentStarted':
return tabbrowser.treeStyleTab.onRestoreTabContentStarted(tab);
}
},
onTabbarResizeStart : function TSTWindow_onTabbarResizeStart(aEvent)
{
if (aEvent.button != 0)