author | Tim Taubert <ttaubert@mozilla.com> |
Tue, 09 Jun 2015 22:10:50 +0200 | |
changeset 248077 | 0b0b75e8dd0b5996638bf44aa6f8c3afd58bf3b1 |
parent 248076 | a7bc5772c79cde84c4a8e3d8606d3bf6bd763a32 |
child 248078 | d3de3ab56658c3571acf02bf500c7afa3090cbdb |
push id | 60888 |
push user | kwierso@gmail.com |
push date | Thu, 11 Jun 2015 01:38:38 +0000 |
treeherder | mozilla-inbound@39e638ed06bf [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | billm |
bugs | 1167508 |
milestone | 41.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
browser/base/content/browser.js | file | annotate | diff | comparison | revisions | |
browser/components/sessionstore/SessionStore.jsm | file | annotate | diff | comparison | revisions |
--- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -217,19 +217,16 @@ XPCOMUtils.defineLazyModuleGetter(this, "resource:///modules/translation/Translation.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "SitePermissions", "resource:///modules/SitePermissions.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "SessionStore", "resource:///modules/sessionstore/SessionStore.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "TabState", - "resource:///modules/sessionstore/TabState.jsm"); - XPCOMUtils.defineLazyModuleGetter(this, "fxAccounts", "resource://gre/modules/FxAccounts.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "gWebRTCUI", "resource:///modules/webrtcUI.jsm", "webrtcUI"); #ifdef MOZ_CRASHREPORTER XPCOMUtils.defineLazyModuleGetter(this, "TabCrashReporter", @@ -918,32 +915,17 @@ function _loadURIWithFlags(browser, uri, } } } // Starts a new load in the browser first switching the browser to the correct // process function LoadInOtherProcess(browser, loadOptions, historyIndex = -1) { let tab = gBrowser.getTabForBrowser(browser); - // Flush the tab state before getting it - TabState.flush(browser); - let tabState = JSON.parse(SessionStore.getTabState(tab)); - - if (historyIndex < 0) { - tabState.userTypedValue = null; - // Tell session history the new page to load - SessionStore._restoreTabAndLoad(tab, JSON.stringify(tabState), loadOptions); - } - else { - // Update the history state to point to the requested index - tabState.index = historyIndex + 1; - // SessionStore takes care of setting the browser remoteness before restoring - // history into it. - SessionStore.setTabState(tab, JSON.stringify(tabState)); - } + SessionStore.navigateAndRestore(tab, loadOptions, historyIndex); } // Called when a docshell has attempted to load a page in an incorrect process. // This function is responsible for loading the page in the correct process. function RedirectLoad({ target: browser, data }) { // We should only start the redirection if the browser window has finished // starting up. Otherwise, we should wait until the startup is done. if (gBrowserInit.delayedStartupFinished) {
--- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -209,26 +209,16 @@ this.SessionStore = { getTabState: function ss_getTabState(aTab) { return SessionStoreInternal.getTabState(aTab); }, setTabState: function ss_setTabState(aTab, aState) { SessionStoreInternal.setTabState(aTab, aState); }, - // This should not be used by external code, the intention is to remove it - // once a better fix is in place for process switching in e10s. - // See bug 1075658 for context. - _restoreTabAndLoad: function ss_restoreTabAndLoad(aTab, aState, aLoadArguments) { - SessionStoreInternal.setTabState(aTab, aState, { - restoreImmediately: true, - loadArguments: aLoadArguments - }); - }, - duplicateTab: function ss_duplicateTab(aWindow, aTab, aDelta = 0) { return SessionStoreInternal.duplicateTab(aWindow, aTab, aDelta); }, getClosedTabCount: function ss_getClosedTabCount(aWindow) { return SessionStoreInternal.getClosedTabCount(aWindow); }, @@ -305,16 +295,20 @@ this.SessionStore = { }, getCurrentState: function (aUpdateAll) { return SessionStoreInternal.getCurrentState(aUpdateAll); }, reviveCrashedTab(aTab) { return SessionStoreInternal.reviveCrashedTab(aTab); + }, + + navigateAndRestore(tab, loadArguments, historyIndex) { + return SessionStoreInternal.navigateAndRestore(tab, loadArguments, historyIndex); } }; // Freeze the SessionStore object. We don't want anyone to modify it. Object.freeze(SessionStore); let SessionStoreInternal = { QueryInterface: XPCOMUtils.generateQI([ @@ -2159,16 +2153,60 @@ let SessionStoreInternal = { "Somehow a crashed browser is still remote.") } let data = TabState.collect(aTab); this.restoreTab(aTab, data); }, /** + * Navigate the given |tab| by first collecting its current state and then + * either changing only the index of the currently shown shistory entry, + * or restoring the exact same state again and passing the new URL to load + * in |loadArguments|. Use this method to seamlessly switch between pages + * loaded in the parent and pages loaded in the child process. + */ + navigateAndRestore(tab, loadArguments, historyIndex) { + let window = tab.ownerDocument.defaultView; + let browser = tab.linkedBrowser; + + // Set tab title to "Connecting..." and start the throbber to pretend we're + // doing something while actually waiting for data from the frame script. + window.gBrowser.setTabTitleLoading(tab); + tab.setAttribute("busy", "true"); + + // Flush to get the latest tab state. + TabStateFlusher.flush(browser).then(() => { + // The tab might have been closed/gone in the meantime. + if (tab.closing || !tab.linkedBrowser || !tab.ownerDocument.defaultView) { + return; + } + + let tabState = TabState.clone(tab); + let options = {restoreImmediately: true}; + + if (historyIndex >= 0) { + tabState.index = historyIndex + 1; + tabState.index = Math.max(1, Math.min(tabState.index, tabState.entries.length)); + } else { + tabState.userTypedValue = null; + options.loadArguments = loadArguments; + } + + // Need to reset restoring tabs. + if (tab.linkedBrowser.__SS_restoreState) { + this._resetLocalTabRestoringState(tab); + } + + // Restore the state into the tab. + this.restoreTab(tab, tabState, options); + }); + }, + + /** * See if aWindow is usable for use when restoring a previous session via * restoreLastSession. If usable, prepare it for use. * * @param aWindow * the window to inspect & prepare * @returns [canUseWindow, canOverwriteTabs] * canUseWindow: can the window be used to restore into * canOverwriteTabs: all of the current tabs are home pages and we