Merge branch 'dev' into drag-and-drop-refactor

This commit is contained in:
mr. m
2025-12-25 18:28:22 +01:00
committed by GitHub
5 changed files with 99 additions and 34 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/sessionstore/SessionStartup.sys.mjs b/browser/components/sessionstore/SessionStartup.sys.mjs
index be23213ae9ec7e59358a17276c6c3764d38d9996..ca5a8ccc916ceeab5140f1278d15233cefbe5815 100644
index be23213ae9ec7e59358a17276c6c3764d38d9996..b6a4110ee50e5977125feb7bd32e84e5e527adc6 100644
--- a/browser/components/sessionstore/SessionStartup.sys.mjs
+++ b/browser/components/sessionstore/SessionStartup.sys.mjs
@@ -40,6 +40,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
@@ -19,3 +19,17 @@ index be23213ae9ec7e59358a17276c6c3764d38d9996..ca5a8ccc916ceeab5140f1278d15233c
if (this._initialState == null) {
// No valid session found.
this._sessionType = this.NO_SESSION;
@@ -335,12 +338,7 @@ export var SessionStartup = {
isAutomaticRestoreEnabled() {
if (this._resumeSessionEnabled === null) {
this._resumeSessionEnabled =
- !lazy.PrivateBrowsingUtils.permanentPrivateBrowsing &&
- (Services.prefs.getBoolPref(
- "browser.sessionstore.resume_session_once"
- ) ||
- Services.prefs.getIntPref("browser.startup.page") ==
- BROWSER_STARTUP_RESUME_SESSION);
+ !lazy.PrivateBrowsingUtils.permanentPrivateBrowsing;
}
return this._resumeSessionEnabled;

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c87549060ccd78d 100644
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..0deff2a0238fa3822387fddd44ddd21451b6e8eb 100644
--- a/browser/components/sessionstore/SessionStore.sys.mjs
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
@@ -127,6 +127,8 @@ const TAB_EVENTS = [
@@ -19,7 +19,19 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
});
ChromeUtils.defineLazyGetter(lazy, "blankURI", () => {
@@ -1911,6 +1914,8 @@ var SessionStoreInternal = {
@@ -1238,10 +1241,7 @@ var SessionStoreInternal = {
*/
get willAutoRestore() {
return (
- !PrivateBrowsingUtils.permanentPrivateBrowsing &&
- (Services.prefs.getBoolPref("browser.sessionstore.resume_session_once") ||
- Services.prefs.getIntPref("browser.startup.page") ==
- BROWSER_STARTUP_RESUME_SESSION)
+ !PrivateBrowsingUtils.permanentPrivateBrowsing
);
},
@@ -1911,6 +1911,8 @@ var SessionStoreInternal = {
case "TabPinned":
case "TabUnpinned":
case "SwapDocShells":
@@ -28,7 +40,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
this.saveStateDelayed(win);
break;
case "TabGroupCreate":
@@ -2020,6 +2025,10 @@ var SessionStoreInternal = {
@@ -2020,6 +2022,10 @@ var SessionStoreInternal = {
this._windows[aWindow.__SSi].isTaskbarTab = true;
}
@@ -39,7 +51,15 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
let tabbrowser = aWindow.gBrowser;
// add tab change listeners to all already existing tabs
@@ -2151,7 +2160,6 @@ var SessionStoreInternal = {
@@ -2107,6 +2113,7 @@ var SessionStoreInternal = {
null,
"sessionstore-one-or-no-tab-restored"
);
+ lazy.ZenSessionStore.onNewEmptySession(aWindow);
this._deferredAllWindowsRestored.resolve();
}
// this window was opened by _openWindowWithState
@@ -2151,7 +2158,6 @@ var SessionStoreInternal = {
if (closedWindowState) {
let newWindowState;
if (
@@ -47,7 +67,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
!lazy.SessionStartup.willRestore()
) {
// We want to split the window up into pinned tabs and unpinned tabs.
@@ -2215,6 +2223,15 @@ var SessionStoreInternal = {
@@ -2215,6 +2221,15 @@ var SessionStoreInternal = {
});
this._shouldRestoreLastSession = false;
}
@@ -63,7 +83,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
if (this._restoreLastWindow && aWindow.toolbar.visible) {
// always reset (if not a popup window)
@@ -2465,7 +2482,7 @@ var SessionStoreInternal = {
@@ -2465,7 +2480,7 @@ var SessionStoreInternal = {
// 2) Flush the window.
// 3) When the flush is complete, revisit our decision to store the window
// in _closedWindows, and add/remove as necessary.
@@ -72,7 +92,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
this.maybeSaveClosedWindow(winData, isLastWindow);
}
@@ -2486,7 +2503,7 @@ var SessionStoreInternal = {
@@ -2486,7 +2501,7 @@ var SessionStoreInternal = {
// Save non-private windows if they have at
// least one saveable tab or are the last window.
@@ -81,7 +101,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
this.maybeSaveClosedWindow(winData, isLastWindow);
if (!isLastWindow && winData.closedId > -1) {
@@ -2582,6 +2599,7 @@ var SessionStoreInternal = {
@@ -2582,6 +2597,7 @@ var SessionStoreInternal = {
let alreadyStored = winIndex != -1;
// If sidebar command is truthy, i.e. sidebar is open, store sidebar settings
let shouldStore = hasSaveableTabs || isLastWindow;
@@ -89,7 +109,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
if (shouldStore && !alreadyStored) {
let index = this._closedWindows.findIndex(win => {
@@ -3373,7 +3391,7 @@ var SessionStoreInternal = {
@@ -3373,7 +3389,7 @@ var SessionStoreInternal = {
if (!isPrivateWindow && tabState.isPrivate) {
return;
}
@@ -98,7 +118,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
return;
}
@@ -4089,6 +4107,12 @@ var SessionStoreInternal = {
@@ -4089,6 +4105,12 @@ var SessionStoreInternal = {
Math.min(tabState.index, tabState.entries.length)
);
tabState.pinned = false;
@@ -111,7 +131,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
if (inBackground === false) {
aWindow.gBrowser.selectedTab = newTab;
@@ -4525,6 +4549,7 @@ var SessionStoreInternal = {
@@ -4525,6 +4547,7 @@ var SessionStoreInternal = {
// Append the tab if we're opening into a different window,
tabIndex: aSource == aTargetWindow ? pos : Infinity,
pinned: state.pinned,
@@ -119,7 +139,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
userContextId: state.userContextId,
skipLoad: true,
preferredRemoteType,
@@ -5032,7 +5057,10 @@ var SessionStoreInternal = {
@@ -5032,7 +5055,10 @@ var SessionStoreInternal = {
!activePageData ||
(activePageData && activePageData.url != "about:blank")
) {
@@ -130,7 +150,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
}
lazy.TabStateCache.update(browser.permanentKey, {
image: null,
@@ -5374,7 +5402,7 @@ var SessionStoreInternal = {
@@ -5374,7 +5400,7 @@ var SessionStoreInternal = {
for (let i = tabbrowser.pinnedTabCount; i < tabbrowser.tabs.length; i++) {
let tab = tabbrowser.tabs[i];
@@ -139,7 +159,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
removableTabs.push(tab);
}
}
@@ -5483,7 +5511,7 @@ var SessionStoreInternal = {
@@ -5483,7 +5509,7 @@ var SessionStoreInternal = {
// collect the data for all windows
for (ix in this._windows) {
@@ -148,7 +168,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
// window data is still in _statesToRestore
continue;
}
@@ -5625,11 +5653,12 @@ var SessionStoreInternal = {
@@ -5625,11 +5651,12 @@ var SessionStoreInternal = {
}
let tabbrowser = aWindow.gBrowser;
@@ -162,7 +182,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
// update the internal state data for this window
for (let tab of tabs) {
if (tab == aWindow.FirefoxViewHandler.tab) {
@@ -5640,6 +5669,9 @@ var SessionStoreInternal = {
@@ -5640,6 +5667,9 @@ var SessionStoreInternal = {
tabsData.push(tabData);
}
@@ -172,7 +192,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
// update tab group state for this window
winData.groups = [];
for (let tabGroup of aWindow.gBrowser.tabGroups) {
@@ -5652,7 +5684,7 @@ var SessionStoreInternal = {
@@ -5652,7 +5682,7 @@ var SessionStoreInternal = {
// 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) {
@@ -181,7 +201,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
winData.title = tabbrowser.tabs[0].label;
}
winData.selected = selectedIndex;
@@ -5765,8 +5797,8 @@ var SessionStoreInternal = {
@@ -5765,8 +5795,8 @@ var SessionStoreInternal = {
// selectTab represents.
let selectTab = 0;
if (overwriteTabs) {
@@ -192,7 +212,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
selectTab = Math.min(selectTab, winData.tabs.length);
}
@@ -5788,6 +5820,7 @@ var SessionStoreInternal = {
@@ -5788,6 +5818,7 @@ var SessionStoreInternal = {
if (overwriteTabs) {
for (let i = tabbrowser.browsers.length - 1; i >= 0; i--) {
if (!tabbrowser.tabs[i].selected) {
@@ -200,7 +220,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
tabbrowser.removeTab(tabbrowser.tabs[i]);
}
}
@@ -5821,6 +5854,9 @@ var SessionStoreInternal = {
@@ -5821,6 +5852,9 @@ var SessionStoreInternal = {
savedTabGroup => !openTabGroupIdsInWindow.has(savedTabGroup.id)
);
}
@@ -210,7 +230,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
// Move the originally open tabs to the end.
if (initialTabs) {
@@ -6372,6 +6408,28 @@ var SessionStoreInternal = {
@@ -6372,6 +6406,25 @@ var SessionStoreInternal = {
// Most of tabData has been restored, now continue with restoring
// attributes that may trigger external events.
@@ -227,9 +247,6 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
+ if (tabData.zenHasStaticIcon) {
+ tab.setAttribute("zen-has-static-icon", "true");
+ }
+ if (tabData.zenSyncId) {
+ tab.setAttribute("id", tabData.zenSyncId);
+ }
+ if (tabData.zenDefaultUserContextId) {
+ tab.setAttribute("zenDefaultUserContextId", true);
+ }
@@ -239,7 +256,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
if (tabData.pinned) {
tabbrowser.pinTab(tab);
@@ -7290,7 +7348,7 @@ var SessionStoreInternal = {
@@ -7290,7 +7343,7 @@ var SessionStoreInternal = {
let groupsToSave = new Map();
for (let tIndex = 0; tIndex < window.tabs.length; ) {
@@ -248,7 +265,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c875490
// Adjust window.selected
if (tIndex + 1 < window.selected) {
window.selected -= 1;
@@ -7305,7 +7363,7 @@ var SessionStoreInternal = {
@@ -7305,7 +7358,7 @@ var SessionStoreInternal = {
);
// We don't want to increment tIndex here.
continue;

View File

@@ -26,6 +26,9 @@ const SHOULD_BACKUP_FILE = Services.prefs.getBoolPref('zen.session-store.backup-
const FILE_NAME = SHOULD_COMPRESS_FILE ? 'zen-sessions.jsonlz4' : 'zen-sessions.json';
const MIGRATION_PREF = 'zen.ui.migration.session-manager-restore';
// 'browser.startup.page' preference value to resume the previous session.
const BROWSER_STARTUP_RESUME_SESSION = 3;
/**
* Class representing the sidebar object stored in the session file.
* This object holds all the data related to tabs, groups, folders
@@ -68,6 +71,10 @@ export class nsZenSessionManager {
compression: SHOULD_COMPRESS_FILE ? 'lz4' : undefined,
backupFile,
});
lazy.SessionStore.promiseAllWindowsRestored.then(() => {
delete this._migrationSpaceData;
});
}
log(...args) {
@@ -149,7 +156,6 @@ export class nsZenSessionManager {
for (const winData of initialState?.windows || []) {
winData.spaces = this._migrationSpaceData || [];
}
delete this._migrationSpaceData;
return;
}
// If there's no initial state, nothing to restore. This would
@@ -165,6 +171,17 @@ export class nsZenSessionManager {
if (!initialState.windows?.length) {
initialState.windows = [{}];
}
// When we don't have browser.startup.page set to resume session,
// we only want to restore the pinned tabs into the new windows.
if (
Services.prefs.getIntPref('browser.startup.page', 1) !== BROWSER_STARTUP_RESUME_SESSION &&
this.#sidebar?.tabs
) {
this.log('Restoring only pinned tabs into windows');
const sidebar = this.#sidebar;
sidebar.tabs = (sidebar.tabs || []).filter((tab) => tab.pinned);
this.#sidebar = sidebar;
}
// Restore all windows with the same sidebar object, this will
// guarantee that all tabs, groups, folders and split view data
// are properly synced across all windows.
@@ -280,8 +297,7 @@ export class nsZenSessionManager {
* We do this in order to make sure all new window objects
* have the same sidebar data.
*
* @param aWindowData
* The window data object to restore into.
* @param aWindowData The window data object to restore into.
*/
#restoreWindowData(aWindowData) {
const sidebar = this.#sidebar;
@@ -352,6 +368,19 @@ export class nsZenSessionManager {
SessionStoreInternal.initializeWindow(aWindow, newState);
}
/**
* Called when a new empty session is created. For example,
* when creating a new profile or when the user installed it for
* the first time.
* @param {*} aWindow
* @returns
*/
onNewEmptySession(aWindow) {
aWindow.gZenWorkspaces.restoreWorkspacesFromSessionStore({
spaces: this.#sidebar.spaces || [],
});
}
/**
* Gets the cloned spaces data from the sidebar object.
* This is used during migration to restore spaces into

View File

@@ -182,6 +182,9 @@ class nsZenWindowSync {
tab.id = this.#newTabSyncId;
lazy.TabStateFlusher.flush(tab.linkedBrowser);
}
if (tab.pinned && !tab._zenPinnedInitialState) {
this.setPinnedTabState(tab);
}
}
});
}
@@ -947,7 +950,7 @@ class nsZenWindowSync {
on_focus(aEvent) {
const { ownerGlobal: window } = aEvent.target;
if (
!window.gBrowser ||
!window?.gBrowser ||
this.#lastFocusedWindow?.deref() === window ||
window.closing ||
!window.toolbar.visible

View File

@@ -141,7 +141,7 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
}
}
async resetPinnedTab(tab) {
resetPinnedTab(tab) {
if (!tab) {
tab = TabContextMenu.contextTab;
}
@@ -150,7 +150,7 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
return;
}
await this._resetTabToStoredState(tab);
this._resetTabToStoredState(tab);
}
async replacePinnedUrlWithCurrent(tab = undefined) {
@@ -326,7 +326,9 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
// Remove everything except the entry we want to keep
state.entries = [initialState.entry];
state.image = initialState.image;
state.image = tab.hasAttribute('zen-has-static-icon')
? tab.getAttribute('image')
: initialState.image;
state.index = 0;
SessionStore.setTabState(tab, state);