diff --git a/modules/base.js b/modules/base.js index 51a76493..ba4115d4 100644 --- a/modules/base.js +++ b/modules/base.js @@ -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; diff --git a/modules/utils.js b/modules/utils.js index f6c0de03..19c2f2d8 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -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 diff --git a/modules/window.js b/modules/window.js index 5ca9818c..89c218f5 100644 --- a/modules/window.js +++ b/modules/window.js @@ -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)