diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs index 8c6047e1ada5a22e57e1e665965237c9e22641d7..d3472a36fc99c488f0fd0fa8cb9c6927c24bdc6d 100644 --- a/browser/components/sessionstore/SessionStore.sys.mjs +++ b/browser/components/sessionstore/SessionStore.sys.mjs @@ -2088,7 +2088,6 @@ var SessionStoreInternal = { if (closedWindowState) { let newWindowState; if ( - AppConstants.platform == "macosx" || !lazy.SessionStartup.willRestore() ) { // We want to split the window up into pinned tabs and unpinned tabs. @@ -2303,11 +2302,9 @@ var SessionStoreInternal = { tabbrowser.selectedTab.label; } - if (AppConstants.platform != "macosx") { // Until we decide otherwise elsewhere, this window is part of a series // of closing windows to quit. winData._shouldRestore = true; - } // Store the window's close date to figure out when each individual tab // was closed. This timestamp should allow re-arranging data based on how @@ -3216,7 +3213,7 @@ var SessionStoreInternal = { if (!isPrivateWindow && tabState.isPrivate) { return; } - if (aTab == aWindow.FirefoxViewHandler.tab) { + if (aTab == aWindow.FirefoxViewHandler.tab || aTab.hasAttribute("zen-empty-tab")) { return; } @@ -3925,6 +3922,11 @@ var SessionStoreInternal = { Math.min(tabState.index, tabState.entries.length) ); tabState.pinned = false; + tabState.zenEssential = false; + tabState.zenPinnedId = null; + tabState.zenIsGlance = false; + tabState.zenGlanceId = null; + tabState.zenHasStaticLabel = false; if (inBackground === false) { aWindow.gBrowser.selectedTab = newTab; @@ -4361,6 +4363,7 @@ var SessionStoreInternal = { // Append the tab if we're opening into a different window, index: aSource == aTargetWindow ? pos : Infinity, pinned: state.pinned, + essential: state.zenEssential, userContextId: state.userContextId, skipLoad: true, preferredRemoteType, @@ -5179,7 +5182,7 @@ var SessionStoreInternal = { for (let i = tabbrowser.pinnedTabCount; i < tabbrowser.tabs.length; i++) { let tab = tabbrowser.tabs[i]; - if (homePages.includes(tab.linkedBrowser.currentURI.spec)) { + if (homePages.includes(tab.linkedBrowser.currentURI.spec) && !tab.hasAttribute("zen-empty-tab")) { removableTabs.push(tab); } } @@ -5239,7 +5242,7 @@ var SessionStoreInternal = { } let workspaceID = aWindow.getWorkspaceID(); - if (workspaceID) { + if (workspaceID && !(this.isLastRestorableWindow() && AppConstants.platform == "macosx")) { winData.workspaceID = workspaceID; } }, @@ -5430,14 +5433,15 @@ var SessionStoreInternal = { } let tabbrowser = aWindow.gBrowser; - let tabs = tabbrowser.tabs; + let tabs = aWindow.gZenWorkspaces.allStoredTabs; /** @type {WindowStateData} */ let winData = this._windows[aWindow.__SSi]; let tabsData = (winData.tabs = []); + winData.splitViewData = aWindow.gZenViewSplitter?.storeDataForSessionStore(); // update the internal state data for this window for (let tab of tabs) { - if (tab == aWindow.FirefoxViewHandler.tab) { + if (tab == aWindow.FirefoxViewHandler.tab || tab.hasAttribute("zen-empty-tab")) { continue; } let tabData = lazy.TabState.collect(tab, TAB_CUSTOM_VALUES.get(tab)); @@ -5456,8 +5460,8 @@ var SessionStoreInternal = { // We don't store the Firefox View tab in Session Store, so if it was the last selected "tab" when // a window is closed, point to the first item in the tab strip instead (it will never be the Firefox View tab, // since it's only inserted into the tab strip after it's selected). - if (aWindow.FirefoxViewHandler.tab?.selected) { - selectedIndex = 1; + if (aWindow.FirefoxViewHandler.tab?.selected || tabbrowser.selectedTab.hasAttribute("zen-empty-tab")) { + selectedIndex = 0; winData.title = tabbrowser.tabs[0].label; } winData.selected = selectedIndex; @@ -5569,8 +5573,8 @@ var SessionStoreInternal = { // selectTab represents. let selectTab = 0; if (overwriteTabs) { - selectTab = parseInt(winData.selected || 1, 10); - selectTab = Math.max(selectTab, 1); + selectTab = parseInt(winData.selected || 0, 10); + selectTab = Math.max(selectTab, 0); selectTab = Math.min(selectTab, winData.tabs.length); } @@ -5613,6 +5617,7 @@ var SessionStoreInternal = { winData.tabs, winData.groups ?? [] ); + aWindow.gZenViewSplitter?.restoreDataFromSessionStore(winData.splitViewData); this._log.debug( `restoreWindow, createTabsForSessionRestore returned ${tabs.length} tabs` ); @@ -6162,6 +6167,22 @@ var SessionStoreInternal = { // Most of tabData has been restored, now continue with restoring // attributes that may trigger external events. + if (tabData.zenEssential) { + tab.setAttribute("zen-essential", "true"); + tabData.pinned = true; // Essential tabs are always pinned. + } + if (tabData.zenIsEmpty) { + tab.setAttribute("zen-empty-tab", "true"); + } + if (tabData.zenHasStaticLabel) { + tab.setAttribute("zen-has-static-label", "true"); + } + if (tabData.zenPinnedId) { + tab.setAttribute("zen-pin-id", tabData.zenPinnedId); + } + if (tabData.zenDefaultUserContextId) { + tab.setAttribute("zenDefaultUserContextId", true); + } if (tabData.pinned) { tabbrowser.pinTab(tab);