feat: Start making use of IDs instead of sync identifiers, b=no-bug, c=folders

This commit is contained in:
Mr. M
2025-11-21 14:29:58 +01:00
parent a765d3642f
commit c6cd912262
4 changed files with 135 additions and 127 deletions

View File

@@ -1,11 +1,11 @@
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb90e3f1092 100644
index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..9ef1996a0e8a3ebe55dc25921b8fc8cc0ac8a303 100644
--- a/browser/components/sessionstore/SessionStore.sys.mjs
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
@@ -126,6 +126,8 @@ const TAB_EVENTS = [
"TabUngrouped",
@@ -127,6 +127,8 @@ const TAB_EVENTS = [
"TabGroupCollapse",
"TabGroupExpand",
"TabSplitViewActivate",
+ "TabAddedToEssentials",
+ "TabRemovedFromEssentials",
];
@@ -67,7 +67,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
return;
}
@@ -4089,6 +4094,11 @@ var SessionStoreInternal = {
@@ -4089,6 +4094,12 @@ var SessionStoreInternal = {
Math.min(tabState.index, tabState.entries.length)
);
tabState.pinned = false;
@@ -80,7 +80,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
if (inBackground === false) {
aWindow.gBrowser.selectedTab = newTab;
@@ -4525,6 +4535,7 @@ var SessionStoreInternal = {
@@ -4525,6 +4536,7 @@ var SessionStoreInternal = {
// Append the tab if we're opening into a different window,
tabIndex: aSource == aTargetWindow ? pos : Infinity,
pinned: state.pinned,
@@ -88,7 +88,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
userContextId: state.userContextId,
skipLoad: true,
preferredRemoteType,
@@ -5374,7 +5385,7 @@ var SessionStoreInternal = {
@@ -5374,7 +5386,7 @@ var SessionStoreInternal = {
for (let i = tabbrowser.pinnedTabCount; i < tabbrowser.tabs.length; i++) {
let tab = tabbrowser.tabs[i];
@@ -97,7 +97,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
removableTabs.push(tab);
}
}
@@ -5434,7 +5445,7 @@ var SessionStoreInternal = {
@@ -5434,7 +5446,7 @@ var SessionStoreInternal = {
}
let workspaceID = aWindow.getWorkspaceID();
@@ -106,7 +106,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
winData.workspaceID = workspaceID;
}
},
@@ -5625,11 +5636,12 @@ var SessionStoreInternal = {
@@ -5625,11 +5637,12 @@ var SessionStoreInternal = {
}
let tabbrowser = aWindow.gBrowser;
@@ -120,7 +120,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
// update the internal state data for this window
for (let tab of tabs) {
if (tab == aWindow.FirefoxViewHandler.tab) {
@@ -5640,6 +5652,7 @@ var SessionStoreInternal = {
@@ -5640,6 +5653,7 @@ var SessionStoreInternal = {
tabsData.push(tabData);
}
@@ -128,7 +128,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
// update tab group state for this window
winData.groups = [];
for (let tabGroup of aWindow.gBrowser.tabGroups) {
@@ -5652,7 +5665,7 @@ var SessionStoreInternal = {
@@ -5652,7 +5666,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) {
@@ -137,7 +137,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
winData.title = tabbrowser.tabs[0].label;
}
winData.selected = selectedIndex;
@@ -5764,8 +5777,8 @@ var SessionStoreInternal = {
@@ -5764,8 +5778,8 @@ var SessionStoreInternal = {
// selectTab represents.
let selectTab = 0;
if (overwriteTabs) {
@@ -148,7 +148,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
selectTab = Math.min(selectTab, winData.tabs.length);
}
@@ -5808,6 +5821,8 @@ var SessionStoreInternal = {
@@ -5808,6 +5822,8 @@ var SessionStoreInternal = {
winData.tabs,
winData.groups ?? []
);
@@ -157,7 +157,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
this._log.debug(
`restoreWindow, createTabsForSessionRestore returned ${tabs.length} tabs`
);
@@ -6371,6 +6386,25 @@ var SessionStoreInternal = {
@@ -6371,6 +6387,25 @@ var SessionStoreInternal = {
// Most of tabData has been restored, now continue with restoring
// attributes that may trigger external events.
@@ -172,7 +172,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
+ tab.setAttribute("zen-has-static-label", "true");
+ }
+ if (tabData.zenSyncId) {
+ tab.setAttribute("zen-sync-id", tabData.zenSyncId);
+ tab.setAttribute("id", tabData.zenPinnedId);
+ }
+ if (tabData.zenDefaultUserContextId) {
+ tab.setAttribute("zenDefaultUserContextId", true);
@@ -183,7 +183,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..ad80ed937f696ba2800e62dfc11fcfb9
if (tabData.pinned) {
tabbrowser.pinTab(tab);
@@ -7289,7 +7323,7 @@ var SessionStoreInternal = {
@@ -7289,7 +7324,7 @@ var SessionStoreInternal = {
let groupsToSave = new Map();
for (let tIndex = 0; tIndex < window.tabs.length; ) {

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/sessionstore/TabState.sys.mjs b/browser/components/sessionstore/TabState.sys.mjs
index 82721356d191055bec0d4b0ca49e481221988801..d1323fe17c995611ebdfe2869b0ccd2d45bcfa11 100644
index 82721356d191055bec0d4b0ca49e481221988801..2d05ba4812e9a73bd896c1aeb007180bbc531a3c 100644
--- a/browser/components/sessionstore/TabState.sys.mjs
+++ b/browser/components/sessionstore/TabState.sys.mjs
@@ -85,7 +85,22 @@ class _TabState {
@@ -7,7 +7,7 @@ index 82721356d191055bec0d4b0ca49e481221988801..d1323fe17c995611ebdfe2869b0ccd2d
}
+ tabData.zenWorkspace = tab.getAttribute("zen-workspace-id");
+ tabData.zenSyncId = tab.getAttribute("zen-sync-id");
+ tabData.zenSyncId = tab.getAttribute("id");
+ tabData.zenEssential = tab.getAttribute("zen-essential");
+ tabData.pinned = tabData.pinned || tabData.zenEssential;
+ tabData.zenDefaultUserContextId = tab.getAttribute("zenDefaultUserContextId");

View File

@@ -1,9 +1,16 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4cd44d980e 100644
index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4cd44d980e 100644
index c0eafd4faf8d57b8486c5bf8917375850ec8147e..d1c089ba66defc74dbf06b283bc6ddca08b55b76 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -432,15 +432,64 @@
@@ -386,6 +386,7 @@
* @type {MozBrowser[]}
*/
get splitViewBrowsers() {
+ return gZenViewSplitter.splitViewBrowsers;
const browsers = [];
if (this.#activeSplitView) {
for (const tab of this.#activeSplitView.tabs) {
@@ -450,15 +451,64 @@
return this.tabContainer.visibleTabs;
}
@@ -70,7 +77,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
set selectedTab(val) {
if (
gSharedTabWarning.willShowSharedTabWarning(val) ||
@@ -588,6 +637,7 @@
@@ -613,6 +663,7 @@
this.tabpanels.appendChild(panel);
let tab = this.tabs[0];
@@ -78,7 +85,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
tab.linkedPanel = uniqueId;
this._selectedTab = tab;
this._selectedBrowser = browser;
@@ -873,13 +923,17 @@
@@ -898,13 +949,17 @@
}
this.showTab(aTab);
@@ -97,7 +104,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
aTab.setAttribute("pinned", "true");
this._updateTabBarForPinnedTabs();
@@ -892,11 +946,15 @@
@@ -917,11 +972,15 @@
}
this.#handleTabMove(aTab, () => {
@@ -114,7 +121,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
});
aTab.style.marginInlineStart = "";
@@ -1073,6 +1131,8 @@
@@ -1098,6 +1157,8 @@
let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"];
@@ -123,7 +130,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (
aIconURL &&
!LOCAL_PROTOCOLS.some(protocol => aIconURL.startsWith(protocol))
@@ -1082,6 +1142,9 @@
@@ -1107,6 +1168,9 @@
);
return;
}
@@ -133,7 +140,15 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
let browser = this.getBrowserForTab(aTab);
browser.mIconURL = aIconURL;
@@ -1445,6 +1508,7 @@
@@ -1379,7 +1443,6 @@
// Preview mode should not reset the owner
if (!this._previewMode && !oldTab.selected) {
- oldTab.owner = null;
}
let lastRelatedTab = this._lastRelatedTabMap.get(oldTab);
@@ -1470,6 +1533,7 @@
if (!this._previewMode) {
newTab.recordTimeFromUnloadToReload();
newTab.updateLastAccessed();
@@ -141,7 +156,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
oldTab.updateLastAccessed();
// if this is the foreground window, update the last-seen timestamps.
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
@@ -1597,6 +1661,9 @@
@@ -1622,6 +1686,9 @@
}
let activeEl = document.activeElement;
@@ -151,7 +166,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
// If focus is on the old tab, move it to the new tab.
if (activeEl == oldTab) {
newTab.focus();
@@ -1920,7 +1987,8 @@
@@ -1945,7 +2012,8 @@
}
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
@@ -161,7 +176,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
return false;
}
@@ -2028,7 +2096,7 @@
@@ -2053,7 +2121,7 @@
newIndex = this.selectedTab._tPos + 1;
}
@@ -170,7 +185,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (this.isTabGroupLabel(targetTab)) {
throw new Error(
"Replacing a tab group label with a tab is not supported"
@@ -2303,6 +2371,7 @@
@@ -2328,6 +2396,7 @@
uriIsAboutBlank,
userContextId,
skipLoad,
@@ -178,7 +193,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
} = {}) {
let b = document.createXULElement("browser");
// Use the JSM global to create the permanentKey, so that if the
@@ -2376,8 +2445,7 @@
@@ -2401,8 +2470,7 @@
// we use a different attribute name for this?
b.setAttribute("name", name);
}
@@ -188,7 +203,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
b.setAttribute("transparent", "true");
}
@@ -2542,7 +2610,7 @@
@@ -2567,7 +2635,7 @@
let panel = this.getPanel(browser);
let uniqueId = this._generateUniquePanelID();
@@ -197,7 +212,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
aTab.linkedPanel = uniqueId;
// Inject the <browser> into the DOM if necessary.
@@ -2601,8 +2669,8 @@
@@ -2626,8 +2694,8 @@
// If we transitioned from one browser to two browsers, we need to set
// hasSiblings=false on both the existing browser and the new browser.
if (this.tabs.length == 2) {
@@ -208,7 +223,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
} else {
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
}
@@ -2779,7 +2847,6 @@
@@ -2814,7 +2882,6 @@
this.selectedTab = this.addTrustedTab(BROWSER_NEW_TAB_URL, {
tabIndex: tab._tPos + 1,
userContextId: tab.userContextId,
@@ -216,7 +231,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
focusUrlBar: true,
});
resolve(this.selectedBrowser);
@@ -2859,6 +2926,8 @@
@@ -2923,6 +2990,8 @@
schemelessInput,
hasValidUserGestureActivation = false,
textDirectiveUserActivation = false,
@@ -225,7 +240,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
} = {}
) {
// all callers of addTab that pass a params object need to pass
@@ -2869,6 +2938,12 @@
@@ -2933,10 +3002,17 @@
);
}
@@ -238,7 +253,20 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (!UserInteraction.running("browser.tabs.opening", window)) {
UserInteraction.start("browser.tabs.opening", "initting", window);
}
@@ -2932,6 +3007,19 @@
+ if (!gURLBar.hasAttribute("zen-newtab")) {
// If we're opening a foreground tab, set the owner by default.
ownerTab ??= inBackground ? null : this.selectedTab;
@@ -2944,6 +3020,7 @@
if (this.selectedTab.owner) {
this.selectedTab.owner = null;
}
+ }
// Find the tab that opened this one, if any. This is used for
// determining positioning, and inherited attributes such as the
@@ -2996,6 +3073,19 @@
noInitialLabel,
skipBackgroundNotify,
});
@@ -258,7 +286,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (insertTab) {
// Insert the tab into the tab container in the correct position.
this.#insertTabAtIndex(t, {
@@ -2940,6 +3028,7 @@
@@ -3004,6 +3094,7 @@
ownerTab,
openerTab,
pinned,
@@ -266,7 +294,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
bulkOrderedOpen,
tabGroup: tabGroup ?? openerTab?.group,
});
@@ -2958,6 +3047,7 @@
@@ -3022,6 +3113,7 @@
openWindowInfo,
skipLoad,
triggeringRemoteType,
@@ -274,7 +302,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
}));
if (focusUrlBar) {
@@ -3078,6 +3168,12 @@
@@ -3146,6 +3238,12 @@
}
}
@@ -287,7 +315,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
// Additionally send pinned tab events
if (pinned) {
this.#notifyPinnedStatus(t);
@@ -3248,10 +3344,10 @@
@@ -3330,10 +3428,10 @@
isAdoptingGroup = false,
isUserTriggered = false,
telemetryUserCreateSource = "unknown",
@@ -299,7 +327,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
}
if (!color) {
@@ -3272,9 +3368,14 @@
@@ -3354,9 +3452,14 @@
label,
isAdoptingGroup
);
@@ -316,7 +344,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
);
group.addTabs(tabs);
@@ -3395,7 +3496,7 @@
@@ -3477,7 +3580,7 @@
}
this.#handleTabMove(tab, () =>
@@ -325,7 +353,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
);
}
@@ -3597,6 +3698,7 @@
@@ -3679,6 +3782,7 @@
openWindowInfo,
skipLoad,
triggeringRemoteType,
@@ -333,7 +361,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
}
) {
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
@@ -3666,6 +3768,7 @@
@@ -3748,6 +3852,7 @@
openWindowInfo,
name,
skipLoad,
@@ -341,7 +369,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
});
}
@@ -3853,7 +3956,7 @@
@@ -3935,7 +4040,7 @@
// Add a new tab if needed.
if (!tab) {
let createLazyBrowser =
@@ -350,7 +378,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
let url = "about:blank";
if (tabData.entries?.length) {
@@ -3890,8 +3993,10 @@
@@ -3972,8 +4077,10 @@
insertTab: false,
skipLoad: true,
preferredRemoteType,
@@ -362,7 +390,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (select) {
tabToSelect = tab;
}
@@ -3903,7 +4008,8 @@
@@ -3985,7 +4092,8 @@
this.pinTab(tab);
// Then ensure all the tab open/pinning information is sent.
this._fireTabOpen(tab, {});
@@ -372,7 +400,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
let { groupId } = tabData;
const tabGroup = tabGroupWorkingData.get(groupId);
// if a tab refers to a tab group we don't know, skip any group
@@ -3917,7 +4023,10 @@
@@ -3999,7 +4107,10 @@
tabGroup.stateData.id,
tabGroup.stateData.color,
tabGroup.stateData.collapsed,
@@ -384,7 +412,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
);
tabsFragment.appendChild(tabGroup.node);
}
@@ -3962,9 +4071,23 @@
@@ -4044,9 +4155,23 @@
// to remove the old selected tab.
if (tabToSelect) {
let leftoverTab = this.selectedTab;
@@ -400,17 +428,15 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
+ gZenWorkspaces._initialTab._shouldRemove = true;
+ }
+ }
+ }
+ }
}
+ else {
+ gZenWorkspaces._tabToRemoveForEmpty = this.selectedTab;
}
}
+ }
+ this._hasAlreadyInitializedZenSessionStore = true;
if (tabs.length > 1 || !tabs[0].selected) {
this._updateTabsAfterInsert();
@@ -4155,11 +4278,14 @@
@@ -4237,11 +4362,14 @@
if (ownerTab) {
tab.owner = ownerTab;
}
@@ -426,7 +452,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (
!bulkOrderedOpen &&
((openerTab &&
@@ -4171,7 +4297,7 @@
@@ -4253,7 +4381,7 @@
let lastRelatedTab =
openerTab && this._lastRelatedTabMap.get(openerTab);
let previousTab = lastRelatedTab || openerTab || this.selectedTab;
@@ -435,7 +461,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
tabGroup = previousTab.group;
}
if (
@@ -4182,7 +4308,7 @@
@@ -4264,7 +4392,7 @@
) {
elementIndex = Infinity;
} else if (previousTab.visible) {
@@ -444,7 +470,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
} else if (previousTab == FirefoxViewHandler.tab) {
elementIndex = 0;
}
@@ -4210,14 +4336,14 @@
@@ -4292,14 +4420,14 @@
}
// Ensure index is within bounds.
if (tab.pinned) {
@@ -463,7 +489,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (pinned && !itemAfter?.pinned) {
itemAfter = null;
@@ -4228,7 +4354,7 @@
@@ -4310,7 +4438,7 @@
this.tabContainer._invalidateCachedTabs();
@@ -472,7 +498,19 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (this.isTab(itemAfter) && itemAfter.group == tabGroup) {
// Place at the front of, or between tabs in, the same tab group
this.tabContainer.insertBefore(tab, itemAfter);
@@ -4264,6 +4390,7 @@
@@ -4338,7 +4466,11 @@
const tabContainer = pinned
? this.tabContainer.pinnedTabsContainer
: this.tabContainer;
+ if (itemAfter) {
+ itemAfter.before(tab);
+ } else {
tabContainer.insertBefore(tab, itemAfter);
+ }
}
this._updateTabsAfterInsert();
@@ -4346,6 +4478,7 @@
if (pinned) {
this._updateTabBarForPinnedTabs();
}
@@ -480,8 +518,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
TabBarVisibility.update();
}
@@ -4896,6 +5024,7 @@
@@ -4896,6 +5024,7 @@
@@ -4896,6 +5029,7 @@
telemetrySource,
} = {}
) {
@@ -489,8 +526,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
// can be considered equivalent to closing the window.
if (
@@ -4985,6 +5114,7 @@
@@ -4985,6 +5114,7 @@
@@ -4985,6 +5119,7 @@
if (lastToClose) {
this.removeTab(lastToClose, aParams);
}
@@ -498,8 +534,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
} catch (e) {
console.error(e);
}
@@ -5023,6 +5153,12 @@
@@ -5023,6 +5153,12 @@
@@ -5023,6 +5158,12 @@
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
}
@@ -512,8 +547,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
// Handle requests for synchronously removing an already
// asynchronously closing tab.
if (!animate && aTab.closing) {
@@ -5037,6 +5173,9 @@
@@ -5037,6 +5173,9 @@
@@ -5037,6 +5178,9 @@
// state).
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
let isLastTab = this.#isLastTabInWindow(aTab);
@@ -523,8 +557,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (
!this._beginRemoveTab(aTab, {
closeWindowFastpath: true,
@@ -5085,7 +5224,13 @@
@@ -5085,7 +5224,13 @@
@@ -5085,7 +5229,13 @@
// We're not animating, so we can cancel the animation stopwatch.
Glean.browserTabclose.timeAnim.cancel(aTab._closeTimeAnimTimerId);
aTab._closeTimeAnimTimerId = null;
@@ -539,8 +572,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
return;
}
@@ -5219,7 +5364,7 @@
@@ -5219,7 +5364,7 @@
@@ -5219,7 +5369,7 @@
closeWindowWithLastTab != null
? closeWindowWithLastTab
: !window.toolbar.visible ||
@@ -549,8 +581,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (closeWindow) {
// We've already called beforeunload on all the relevant tabs if we get here,
@@ -5243,6 +5388,7 @@
@@ -5243,6 +5388,7 @@
@@ -5243,6 +5393,7 @@
newTab = true;
}
@@ -558,8 +589,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
aTab._endRemoveArgs = [closeWindow, newTab];
// swapBrowsersAndCloseOther will take care of closing the window without animation.
@@ -5283,13 +5429,7 @@
@@ -5283,13 +5429,7 @@
@@ -5283,13 +5434,7 @@
aTab._mouseleave();
if (newTab) {
@@ -574,8 +604,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
} else {
TabBarVisibility.update();
}
@@ -5422,6 +5562,7 @@
@@ -5422,6 +5562,7 @@
@@ -5422,6 +5567,7 @@
this.tabs[i]._tPos = i;
}
@@ -583,8 +612,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (!this._windowIsClosing) {
// update tab close buttons state
this.tabContainer._updateCloseButtons();
@@ -5643,6 +5784,7 @@
@@ -5643,6 +5784,7 @@
@@ -5643,6 +5789,7 @@
}
let excludeTabs = new Set(aExcludeTabs);
@@ -592,8 +620,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
// If this tab has a successor, it should be selectable, since
// hiding or closing a tab removes that tab as a successor.
@@ -5655,13 +5797,13 @@
@@ -5655,13 +5797,13 @@
@@ -5655,13 +5802,13 @@
!excludeTabs.has(aTab.owner) &&
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
) {
@@ -609,8 +636,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
);
let tab = this.tabContainer.findNextTab(aTab, {
@@ -5677,7 +5819,7 @@
@@ -5677,7 +5819,7 @@
@@ -5677,7 +5824,7 @@
}
if (tab) {
@@ -619,8 +645,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
}
// If no qualifying visible tab was found, see if there is a tab in
@@ -5698,7 +5840,7 @@
@@ -5698,7 +5840,7 @@
@@ -5698,7 +5845,7 @@
});
}
@@ -629,8 +654,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
}
_blurTab(aTab) {
@@ -6104,10 +6246,10 @@
@@ -6104,10 +6246,10 @@
@@ -6104,10 +6251,10 @@
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
}
@@ -643,8 +667,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
aTab.selected ||
aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -6166,6 +6308,7 @@
@@ -6166,6 +6308,7 @@
@@ -6166,6 +6313,7 @@
* @param {MozTabbrowserTab|MozTabbrowserTabGroup|MozTabbrowserTabGroup.labelElement} aTab
*/
replaceTabWithWindow(aTab, aOptions) {
@@ -652,8 +675,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (this.tabs.length == 1) {
return null;
}
@@ -6299,7 +6442,7 @@
@@ -6299,7 +6442,7 @@
@@ -6299,7 +6447,7 @@
* `true` if element is a `<tab-group>`
*/
isTabGroup(element) {
@@ -662,8 +684,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
}
/**
@@ -6375,8 +6518,8 @@
@@ -6375,8 +6518,8 @@
@@ -6375,8 +6523,8 @@
}
// Don't allow mixing pinned and unpinned tabs.
@@ -674,8 +695,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
} else {
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
}
@@ -6402,10 +6545,16 @@
@@ -6402,10 +6545,16 @@
@@ -6402,10 +6550,16 @@
this.#handleTabMove(
element,
() => {
@@ -694,8 +714,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
neighbor.after(element);
} else {
@@ -6463,23 +6612,28 @@
@@ -6463,23 +6612,28 @@
@@ -6463,23 +6617,28 @@
#moveTabNextTo(element, targetElement, moveBefore = false, metricsContext) {
if (this.isTabGroupLabel(targetElement)) {
targetElement = targetElement.group;
@@ -730,8 +749,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
} else if (!element.pinned && targetElement && targetElement.pinned) {
// If the caller asks to move an unpinned element next to a pinned
// tab, move the unpinned element to be the first unpinned element
@@ -6492,14 +6646,34 @@
@@ -6492,14 +6646,34 @@
@@ -6492,14 +6651,34 @@
// move the tab group right before the first unpinned tab.
// 4. Moving a tab group and the first unpinned tab is grouped:
// move the tab group right before the first unpinned tab's tab group.
@@ -767,8 +785,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
element.pinned
? this.tabContainer.pinnedTabsContainer
: this.tabContainer;
@@ -6508,7 +6682,7 @@
@@ -6508,7 +6682,7 @@
@@ -6508,7 +6687,7 @@
element,
() => {
if (moveBefore) {
@@ -777,8 +794,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
} else if (targetElement) {
targetElement.after(element);
} else {
@@ -6580,10 +6754,10 @@
@@ -6580,10 +6754,10 @@
@@ -6580,10 +6759,10 @@
* @param {TabMetricsContext} [metricsContext]
*/
moveTabToGroup(aTab, aGroup, metricsContext) {
@@ -791,8 +807,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
return;
}
if (aTab.group && aTab.group.id === aGroup.id) {
@@ -6613,6 +6787,7 @@
@@ -6613,6 +6787,7 @@
@@ -6613,6 +6792,7 @@
let state = {
tabIndex: tab._tPos,
@@ -800,8 +815,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
};
if (tab.visible) {
state.elementIndex = tab.elementIndex;
@@ -6639,7 +6814,7 @@
@@ -6639,7 +6814,7 @@
@@ -6639,7 +6819,7 @@
let changedTabGroup =
previousTabState.tabGroupId != currentTabState.tabGroupId;
@@ -810,8 +824,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
tab.dispatchEvent(
new CustomEvent("TabMove", {
bubbles: true,
@@ -6676,6 +6851,10 @@
@@ -6676,6 +6851,10 @@
@@ -6676,6 +6856,10 @@
moveActionCallback();
@@ -822,8 +835,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
// Clear tabs cache after moving nodes because the order of tabs may have
// changed.
this.tabContainer._invalidateCachedTabs();
@@ -7576,7 +7755,7 @@
@@ -7576,7 +7755,7 @@
@@ -7576,7 +7760,7 @@
// preventDefault(). It will still raise the window if appropriate.
break;
}
@@ -832,8 +844,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
window.focus();
aEvent.preventDefault();
break;
@@ -7593,7 +7772,6 @@
@@ -7593,7 +7772,6 @@
@@ -7593,7 +7777,6 @@
}
case "TabGroupCollapse":
aEvent.target.tabs.forEach(tab => {
@@ -841,8 +852,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
});
break;
case "TabGroupCreateByUser":
@@ -8542,6 +8720,7 @@
@@ -8542,6 +8720,7 @@
@@ -8542,6 +8725,7 @@
aWebProgress.isTopLevel
) {
this.mTab.setAttribute("busy", "true");
@@ -850,8 +860,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..30c8fd7e978eb3036f35b17ae3f6ea4c
gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected;
}
@@ -9543,7 +9722,7 @@ var TabContextMenu = {
@@ -9543,7 +9722,7 @@ var TabContextMenu = {
@@ -9543,7 +9727,7 @@ var TabContextMenu = {
);
contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !this.multiselected;

View File

@@ -935,7 +935,7 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
if (!parentFolder && folder.hasAttribute('split-view-group')) continue;
const emptyFolderTabs = folder.tabs
.filter((tab) => tab.hasAttribute('zen-empty-tab'))
.map((tab) => tab.getAttribute('zen-sync-id'));
.map((tab) => tab.getAttribute('id'));
let prevSiblingInfo = null;
const prevSibling = folder.previousElementSibling;
@@ -944,8 +944,8 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
if (prevSibling) {
if (gBrowser.isTabGroup(prevSibling)) {
prevSiblingInfo = { type: 'group', id: prevSibling.id };
} else if (gBrowser.isTab(prevSibling) && prevSibling.hasAttribute('zen-sync-id')) {
const zenPinId = prevSibling.getAttribute('zen-sync-id');
} else if (gBrowser.isTab(prevSibling) && prevSibling.hasAttribute('id')) {
const zenPinId = prevSibling.getAttribute('id');
prevSiblingInfo = { type: 'tab', id: zenPinId };
} else {
prevSiblingInfo = { type: 'start', id: null };
@@ -964,7 +964,6 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
prevSiblingInfo: prevSiblingInfo,
emptyTabIds: emptyFolderTabs,
userIcon: userIcon?.getAttribute('href'),
syncId: folder.getAttribute('zen-sync-id'),
// note: We shouldn't be using the workspace-id anywhere, we are just
// remembering it for the pinned tabs manager to use it later.
workspaceId: folder.getAttribute('zen-workspace-id'),
@@ -991,9 +990,9 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
tabFolderWorkingData.set(folderData.id, workingData);
const oldGroup = document.getElementById(folderData.id);
folderData.emptyTabIds.forEach((zenSyncId) => {
folderData.emptyTabIds.forEach((id) => {
oldGroup
?.querySelector(`tab[zen-sync-id="${zenSyncId}"]`)
?.querySelector(`tab[id="${id}"]`)
?.setAttribute('zen-empty-tab', true);
});
if (oldGroup) {
@@ -1006,7 +1005,7 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
saveOnWindowClose: folderData.saveOnWindowClose,
workspaceId: folderData.workspaceId,
});
folder.setAttribute('zen-sync-id', folderData.syncId);
folder.setAttribute('id', folderData.id);
workingData.node = folder;
oldGroup.before(folder);
} else {
@@ -1038,8 +1037,8 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
if (parentWorkingData && parentWorkingData.node) {
switch (stateData?.prevSiblingInfo?.type) {
case 'tab': {
const tab = parentWorkingData.node.querySelector(
`[zen-sync-id="${stateData.prevSiblingInfo.id}"]`
const tab = document.getElementById(
stateData.prevSiblingInfo.id
);
tab.after(node);
break;