feat: Fixed folders on new windows not expanding at startup, b=no-bug, c=common, folders, tabs, workspaces

This commit is contained in:
mr. m
2025-12-24 17:34:29 +01:00
parent b3ea7f0e8d
commit 4c2cb60412
9 changed files with 124 additions and 110 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..4a229300d837ffead46a966ea23b37cd1ef01db2 100644
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..33f630dea72da70352e131144c87549060ccd78d 100644
--- a/browser/components/sessionstore/SessionStore.sys.mjs
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
@@ -127,6 +127,8 @@ const TAB_EVENTS = [
@@ -221,8 +221,8 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..4a229300d837ffead46a966ea23b37cd
+ if (tabData.zenIsEmpty) {
+ tab.setAttribute("zen-empty-tab", "true");
+ }
+ if (tabData.zenHasStaticLabel) {
+ tab.setAttribute("zen-has-static-label", "true");
+ if (tabData.zenStaticLabel) {
+ tab.zenStaticLabel = tabData.zenStaticLabel;
+ }
+ if (tabData.zenHasStaticIcon) {
+ tab.setAttribute("zen-has-static-icon", "true");

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/sessionstore/TabState.sys.mjs b/browser/components/sessionstore/TabState.sys.mjs
index 82721356d191055bec0d4b0ca49e481221988801..7b3ba1b3a6df2b5031d3d96579e564d9de38ba9c 100644
index 82721356d191055bec0d4b0ca49e481221988801..e0fde4fc475471d170ce46c1207e6e7b67fcaf1d 100644
--- a/browser/components/sessionstore/TabState.sys.mjs
+++ b/browser/components/sessionstore/TabState.sys.mjs
@@ -85,7 +85,25 @@ class _TabState {
@@ -14,7 +14,7 @@ index 82721356d191055bec0d4b0ca49e481221988801..7b3ba1b3a6df2b5031d3d96579e564d9
+ tabData.zenPinnedEntry = tab.getAttribute("zen-pinned-entry");
+ tabData.zenPinnedIcon = tab.getAttribute("zen-pinned-icon");
+ tabData.zenIsEmpty = tab.hasAttribute("zen-empty-tab");
+ tabData.zenHasStaticLabel = tab.hasAttribute("zen-has-static-label");
+ tabData.zenStaticLabel = tab.zenStaticLabel;
+ tabData.zenHasStaticIcon = tab.hasAttribute("zen-has-static-icon");
+ tabData.zenGlanceId = tab.getAttribute("glance-id");
+ tabData.zenIsGlance = tab.hasAttribute("zen-glance-tab");

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44c9fe0117 100644
index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..a87bcaf4e9b92a9f63e025409efabca90aa52900 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -386,6 +386,7 @@
@@ -171,20 +171,19 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
// If focus is on the old tab, move it to the new tab.
if (activeEl == oldTab) {
newTab.focus();
@@ -1945,7 +2017,11 @@
@@ -1945,6 +2017,11 @@
}
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
- if (!aLabel || aLabel.includes("about:reader?")) {
+ if (!aTab._zenContentsVisible && !aTab._zenChangeLabelFlag && !aTab._labelIsInitialTitle && !gZenWorkspaces.privateWindowOrDisabled) {
+ return false;
+ }
+ aLabel = aTab.zenStaticLabel || aLabel;
+ gZenPinnedTabManager.onTabLabelChanged(aTab);
+ if (!aLabel || aLabel.includes("about:reader?") || (aTab.hasAttribute("zen-has-static-label") && !aTab._zenChangeLabelFlag)) {
if (!aLabel || aLabel.includes("about:reader?")) {
return false;
}
@@ -2053,7 +2129,7 @@
@@ -2053,7 +2130,7 @@
newIndex = this.selectedTab._tPos + 1;
}
@@ -193,7 +192,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (this.isTabGroupLabel(targetTab)) {
throw new Error(
"Replacing a tab group label with a tab is not supported"
@@ -2328,6 +2404,7 @@
@@ -2328,6 +2405,7 @@
uriIsAboutBlank,
userContextId,
skipLoad,
@@ -201,7 +200,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
} = {}) {
let b = document.createXULElement("browser");
// Use the JSM global to create the permanentKey, so that if the
@@ -2401,8 +2478,7 @@
@@ -2401,8 +2479,7 @@
// we use a different attribute name for this?
b.setAttribute("name", name);
}
@@ -211,7 +210,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
b.setAttribute("transparent", "true");
}
@@ -2567,7 +2643,7 @@
@@ -2567,7 +2644,7 @@
let panel = this.getPanel(browser);
let uniqueId = this._generateUniquePanelID();
@@ -220,7 +219,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
aTab.linkedPanel = uniqueId;
// Inject the <browser> into the DOM if necessary.
@@ -2626,8 +2702,8 @@
@@ -2626,8 +2703,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) {
@@ -231,7 +230,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
} else {
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
}
@@ -2814,7 +2890,6 @@
@@ -2814,7 +2891,6 @@
this.selectedTab = this.addTrustedTab(BROWSER_NEW_TAB_URL, {
tabIndex: tab._tPos + 1,
userContextId: tab.userContextId,
@@ -239,7 +238,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
focusUrlBar: true,
});
resolve(this.selectedBrowser);
@@ -2923,6 +2998,9 @@
@@ -2923,6 +2999,9 @@
schemelessInput,
hasValidUserGestureActivation = false,
textDirectiveUserActivation = false,
@@ -249,7 +248,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
} = {}
) {
// all callers of addTab that pass a params object need to pass
@@ -2933,10 +3011,17 @@
@@ -2933,10 +3012,17 @@
);
}
@@ -267,7 +266,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
// If we're opening a foreground tab, set the owner by default.
ownerTab ??= inBackground ? null : this.selectedTab;
@@ -2944,6 +3029,7 @@
@@ -2944,6 +3030,7 @@
if (this.selectedTab.owner) {
this.selectedTab.owner = null;
}
@@ -275,7 +274,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
// Find the tab that opened this one, if any. This is used for
// determining positioning, and inherited attributes such as the
@@ -2996,6 +3082,21 @@
@@ -2996,6 +3083,21 @@
noInitialLabel,
skipBackgroundNotify,
});
@@ -297,7 +296,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (insertTab) {
// Insert the tab into the tab container in the correct position.
this.#insertTabAtIndex(t, {
@@ -3004,6 +3105,7 @@
@@ -3004,6 +3106,7 @@
ownerTab,
openerTab,
pinned,
@@ -305,7 +304,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
bulkOrderedOpen,
tabGroup: tabGroup ?? openerTab?.group,
});
@@ -3022,6 +3124,7 @@
@@ -3022,6 +3125,7 @@
openWindowInfo,
skipLoad,
triggeringRemoteType,
@@ -313,7 +312,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
}));
if (focusUrlBar) {
@@ -3146,6 +3249,12 @@
@@ -3146,6 +3250,12 @@
}
}
@@ -326,7 +325,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
// Additionally send pinned tab events
if (pinned) {
this.#notifyPinnedStatus(t);
@@ -3349,10 +3458,10 @@
@@ -3349,10 +3459,10 @@
isAdoptingGroup = false,
isUserTriggered = false,
telemetryUserCreateSource = "unknown",
@@ -338,7 +337,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
}
if (!color) {
@@ -3373,9 +3482,14 @@
@@ -3373,9 +3483,14 @@
label,
isAdoptingGroup
);
@@ -355,7 +354,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
);
group.addTabs(tabs);
@@ -3496,7 +3610,7 @@
@@ -3496,7 +3611,7 @@
}
this.#handleTabMove(tab, () =>
@@ -364,7 +363,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
);
}
@@ -3698,6 +3812,7 @@
@@ -3698,6 +3813,7 @@
openWindowInfo,
skipLoad,
triggeringRemoteType,
@@ -372,7 +371,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
}
) {
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
@@ -3767,6 +3882,7 @@
@@ -3767,6 +3883,7 @@
openWindowInfo,
name,
skipLoad,
@@ -380,7 +379,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
});
}
@@ -3955,7 +4071,7 @@
@@ -3955,7 +4072,7 @@
// Add a new tab if needed.
if (!tab) {
let createLazyBrowser =
@@ -389,7 +388,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
let url = "about:blank";
if (tabData.entries?.length) {
@@ -3992,8 +4108,10 @@
@@ -3992,8 +4109,10 @@
insertTab: false,
skipLoad: true,
preferredRemoteType,
@@ -401,7 +400,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (select) {
tabToSelect = tab;
}
@@ -4005,7 +4123,8 @@
@@ -4005,7 +4124,8 @@
this.pinTab(tab);
// Then ensure all the tab open/pinning information is sent.
this._fireTabOpen(tab, {});
@@ -411,7 +410,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
let { groupId } = tabData;
const tabGroup = tabGroupWorkingData.get(groupId);
// if a tab refers to a tab group we don't know, skip any group
@@ -4019,7 +4138,10 @@
@@ -4019,7 +4139,10 @@
tabGroup.stateData.id,
tabGroup.stateData.color,
tabGroup.stateData.collapsed,
@@ -423,7 +422,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
);
tabsFragment.appendChild(tabGroup.node);
}
@@ -4064,9 +4186,23 @@
@@ -4064,9 +4187,23 @@
// to remove the old selected tab.
if (tabToSelect) {
let leftoverTab = this.selectedTab;
@@ -447,7 +446,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (tabs.length > 1 || !tabs[0].selected) {
this._updateTabsAfterInsert();
@@ -4257,11 +4393,14 @@
@@ -4257,11 +4394,14 @@
if (ownerTab) {
tab.owner = ownerTab;
}
@@ -463,7 +462,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (
!bulkOrderedOpen &&
((openerTab &&
@@ -4273,7 +4412,7 @@
@@ -4273,7 +4413,7 @@
let lastRelatedTab =
openerTab && this._lastRelatedTabMap.get(openerTab);
let previousTab = lastRelatedTab || openerTab || this.selectedTab;
@@ -472,7 +471,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
tabGroup = previousTab.group;
}
if (
@@ -4284,7 +4423,7 @@
@@ -4284,7 +4424,7 @@
) {
elementIndex = Infinity;
} else if (previousTab.visible) {
@@ -481,7 +480,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
} else if (previousTab == FirefoxViewHandler.tab) {
elementIndex = 0;
}
@@ -4312,14 +4451,14 @@
@@ -4312,14 +4452,14 @@
}
// Ensure index is within bounds.
if (tab.pinned) {
@@ -500,7 +499,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (pinned && !itemAfter?.pinned) {
itemAfter = null;
@@ -4330,7 +4469,7 @@
@@ -4330,7 +4470,7 @@
this.tabContainer._invalidateCachedTabs();
@@ -509,7 +508,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
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);
@@ -4358,7 +4497,11 @@
@@ -4358,7 +4498,11 @@
const tabContainer = pinned
? this.tabContainer.pinnedTabsContainer
: this.tabContainer;
@@ -521,7 +520,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
}
this._updateTabsAfterInsert();
@@ -4366,6 +4509,7 @@
@@ -4366,6 +4510,7 @@
if (pinned) {
this._updateTabBarForPinnedTabs();
}
@@ -529,7 +528,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
TabBarVisibility.update();
}
@@ -4916,6 +5060,7 @@
@@ -4916,6 +5061,7 @@
telemetrySource,
} = {}
) {
@@ -537,7 +536,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
// can be considered equivalent to closing the window.
if (
@@ -5005,6 +5150,7 @@
@@ -5005,6 +5151,7 @@
if (lastToClose) {
this.removeTab(lastToClose, aParams);
}
@@ -545,7 +544,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
} catch (e) {
console.error(e);
}
@@ -5043,6 +5189,12 @@
@@ -5043,6 +5190,12 @@
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
}
@@ -558,7 +557,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
// Handle requests for synchronously removing an already
// asynchronously closing tab.
if (!animate && aTab.closing) {
@@ -5057,6 +5209,9 @@
@@ -5057,6 +5210,9 @@
// state).
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
let isLastTab = this.#isLastTabInWindow(aTab);
@@ -568,7 +567,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (
!this._beginRemoveTab(aTab, {
closeWindowFastpath: true,
@@ -5105,7 +5260,13 @@
@@ -5105,7 +5261,13 @@
// We're not animating, so we can cancel the animation stopwatch.
Glean.browserTabclose.timeAnim.cancel(aTab._closeTimeAnimTimerId);
aTab._closeTimeAnimTimerId = null;
@@ -583,7 +582,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
return;
}
@@ -5239,7 +5400,7 @@
@@ -5239,7 +5401,7 @@
closeWindowWithLastTab != null
? closeWindowWithLastTab
: !window.toolbar.visible ||
@@ -592,7 +591,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (closeWindow) {
// We've already called beforeunload on all the relevant tabs if we get here,
@@ -5263,6 +5424,7 @@
@@ -5263,6 +5425,7 @@
newTab = true;
}
@@ -600,7 +599,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
aTab._endRemoveArgs = [closeWindow, newTab];
// swapBrowsersAndCloseOther will take care of closing the window without animation.
@@ -5303,13 +5465,7 @@
@@ -5303,13 +5466,7 @@
aTab._mouseleave();
if (newTab) {
@@ -615,7 +614,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
} else {
TabBarVisibility.update();
}
@@ -5442,6 +5598,7 @@
@@ -5442,6 +5599,7 @@
this.tabs[i]._tPos = i;
}
@@ -623,7 +622,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (!this._windowIsClosing) {
// update tab close buttons state
this.tabContainer._updateCloseButtons();
@@ -5663,6 +5820,7 @@
@@ -5663,6 +5821,7 @@
}
let excludeTabs = new Set(aExcludeTabs);
@@ -631,7 +630,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
// If this tab has a successor, it should be selectable, since
// hiding or closing a tab removes that tab as a successor.
@@ -5675,13 +5833,13 @@
@@ -5675,13 +5834,13 @@
!excludeTabs.has(aTab.owner) &&
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
) {
@@ -647,7 +646,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
);
let tab = this.tabContainer.findNextTab(aTab, {
@@ -5697,7 +5855,7 @@
@@ -5697,7 +5856,7 @@
}
if (tab) {
@@ -656,7 +655,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
}
// If no qualifying visible tab was found, see if there is a tab in
@@ -5718,7 +5876,7 @@
@@ -5718,7 +5877,7 @@
});
}
@@ -665,7 +664,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
}
_blurTab(aTab) {
@@ -5729,7 +5887,7 @@
@@ -5729,7 +5888,7 @@
* @returns {boolean}
* False if swapping isn't permitted, true otherwise.
*/
@@ -674,7 +673,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
// Do not allow transfering a private tab to a non-private window
// and vice versa.
if (
@@ -5783,6 +5941,7 @@
@@ -5783,6 +5942,7 @@
// fire the beforeunload event in the process. Close the other
// window if this was its last tab.
if (
@@ -682,7 +681,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
!remoteBrowser._beginRemoveTab(aOtherTab, {
adoptedByTab: aOurTab,
closeWindowWithLastTab: true,
@@ -5794,7 +5953,7 @@
@@ -5794,7 +5954,7 @@
// If this is the last tab of the window, hide the window
// immediately without animation before the docshell swap, to avoid
// about:blank being painted.
@@ -691,7 +690,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (closeWindow) {
let win = aOtherTab.ownerGlobal;
win.windowUtils.suppressAnimation(true);
@@ -5918,11 +6077,13 @@
@@ -5918,11 +6078,13 @@
}
// Finish tearing down the tab that's going away.
@@ -705,7 +704,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
this.setTabTitle(aOurTab);
@@ -6124,10 +6285,10 @@
@@ -6124,10 +6286,10 @@
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
}
@@ -718,7 +717,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
aTab.selected ||
aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -6185,7 +6346,8 @@
@@ -6185,7 +6347,8 @@
*
* @param {MozTabbrowserTab|MozTabbrowserTabGroup|MozTabbrowserTabGroup.labelElement} aTab
*/
@@ -728,7 +727,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (this.tabs.length == 1) {
return null;
}
@@ -6209,12 +6371,14 @@
@@ -6209,12 +6372,14 @@
}
// tell a new window to take the "dropped" tab
@@ -744,7 +743,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
}
/**
@@ -6319,7 +6483,7 @@
@@ -6319,7 +6484,7 @@
* `true` if element is a `<tab-group>`
*/
isTabGroup(element) {
@@ -753,7 +752,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
}
/**
@@ -6404,8 +6568,8 @@
@@ -6404,8 +6569,8 @@
}
// Don't allow mixing pinned and unpinned tabs.
@@ -764,7 +763,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
} else {
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
}
@@ -6431,10 +6595,16 @@
@@ -6431,10 +6596,16 @@
this.#handleTabMove(
element,
() => {
@@ -783,7 +782,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
neighbor.after(element);
} else {
@@ -6492,23 +6662,28 @@
@@ -6492,23 +6663,28 @@
#moveTabNextTo(element, targetElement, moveBefore = false, metricsContext) {
if (this.isTabGroupLabel(targetElement)) {
targetElement = targetElement.group;
@@ -818,7 +817,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
} 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
@@ -6521,14 +6696,34 @@
@@ -6521,14 +6697,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.
@@ -854,7 +853,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
element.pinned
? this.tabContainer.pinnedTabsContainer
: this.tabContainer;
@@ -6537,7 +6732,7 @@
@@ -6537,7 +6733,7 @@
element,
() => {
if (moveBefore) {
@@ -863,7 +862,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
} else if (targetElement) {
targetElement.after(element);
} else {
@@ -6607,10 +6802,10 @@
@@ -6607,10 +6803,10 @@
* @param {TabMetricsContext} [metricsContext]
*/
moveTabToGroup(aTab, aGroup, metricsContext) {
@@ -876,7 +875,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
return;
}
if (aTab.group && aTab.group.id === aGroup.id) {
@@ -6656,6 +6851,7 @@
@@ -6656,6 +6852,7 @@
let state = {
tabIndex: tab._tPos,
@@ -884,7 +883,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
};
if (tab.visible) {
state.elementIndex = tab.elementIndex;
@@ -6682,7 +6878,7 @@
@@ -6682,7 +6879,7 @@
let changedTabGroup =
previousTabState.tabGroupId != currentTabState.tabGroupId;
@@ -893,7 +892,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
tab.dispatchEvent(
new CustomEvent("TabMove", {
bubbles: true,
@@ -6723,6 +6919,10 @@
@@ -6723,6 +6920,10 @@
moveActionCallback();
@@ -904,15 +903,16 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
// Clear tabs cache after moving nodes because the order of tabs may have
// changed.
this.tabContainer._invalidateCachedTabs();
@@ -6815,6 +7015,7 @@
@@ -6815,6 +7016,8 @@
params.userContextId = aTab.getAttribute("usercontextid");
}
let newTab = this.addWebTab("about:blank", params);
+ newTab._zenContentsVisible = true;
+ newTab.zenStaticLabel = aTab.zenStaticLabel;
let newBrowser = this.getBrowserForTab(newTab);
aTab.container.tabDragAndDrop.finishAnimateTabMove();
@@ -7623,7 +7824,7 @@
@@ -7623,7 +7826,7 @@
// preventDefault(). It will still raise the window if appropriate.
break;
}
@@ -921,7 +921,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
window.focus();
aEvent.preventDefault();
break;
@@ -7640,7 +7841,6 @@
@@ -7640,7 +7843,6 @@
}
case "TabGroupCollapse":
aEvent.target.tabs.forEach(tab => {
@@ -929,7 +929,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
});
break;
case "TabGroupCreateByUser":
@@ -8589,6 +8789,7 @@
@@ -8589,6 +8791,7 @@
aWebProgress.isTopLevel
) {
this.mTab.setAttribute("busy", "true");
@@ -937,7 +937,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected;
}
@@ -8670,6 +8871,7 @@
@@ -8670,6 +8873,7 @@
// known defaults. Note we use the original URL since about:newtab
// redirects to a prerendered page.
const shouldRemoveFavicon =
@@ -945,7 +945,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..8916896fae6807fb4c033022f1f50e44
!this.mBrowser.mIconURL &&
!ignoreBlank &&
!(originalLocation.spec in FAVICON_DEFAULTS);
@@ -9623,7 +9825,7 @@ var TabContextMenu = {
@@ -9623,7 +9827,7 @@ var TabContextMenu = {
);
contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !this.multiselected;

View File

@@ -21,8 +21,8 @@ class ZenSessionStore extends nsZenPreloadedFeature {
if (tabData.zenSyncId || tabData.zenPinnedId) {
tab.setAttribute('id', tabData.zenSyncId || tabData.zenPinnedId);
}
if (tabData.zenHasStaticLabel) {
tab.setAttribute('zen-has-static-label', 'true');
if (tabData.zenStaticLabel) {
tab.zenStaticLabel = tabData.zenStaticLabel;
}
if (tabData.zenHasStaticIcon) {
tab.setAttribute('zen-has-static-icon', 'true');

View File

@@ -1306,12 +1306,12 @@ window.gZenVerticalTabsManager = {
// Check if name is blank, reset if so
// Always remove, so we can always rename and if it's empty,
// it will reset to the original name anyway
this._tabEdited.removeAttribute('zen-has-static-label');
if (hasChanged) {
this._tabEdited.zenStaticLabel = newName;
gBrowser._setTabLabel(this._tabEdited, newName);
this._tabEdited.setAttribute('zen-has-static-label', 'true');
gZenUIManager.showToast('zen-tabs-renamed');
} else {
delete this._tabEdited.zenStaticLabel;
gBrowser.setTabTitle(this._tabEdited);
}

View File

@@ -544,9 +544,7 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
// that we want it to initially be collapsed.
setTimeout(
(folder) => {
gZenPinnedTabManager.promiseInitializedPinned.then(() => {
folder.collapsed = !!options.collapsed;
});
folder.collapsed = !!options.collapsed;
},
0,
folder

View File

@@ -109,6 +109,9 @@ class nsZenWindowSync {
for (let topic of OBSERVING) {
Services.obs.addObserver(this, topic);
}
lazy.SessionStore.promiseAllWindowsRestored.then(() => {
this.#onSessionStoreInitialized();
});
}
uninit() {
@@ -162,6 +165,27 @@ class nsZenWindowSync {
}
}
/**
* Called when the session store has finished initializing for a window.
*
* @param {Window} aWindow - The browser window that has initialized session store.
*/
#onSessionStoreInitialized() {
// For every tab we have in where there's no sync ID, we need to
// assign one and sync it to other windows.
// This should only happen really when updating from an older version
// that didn't have this feature.
this.#runOnAllWindows(null, (aWindow) => {
const { gBrowser } = aWindow;
for (let tab of gBrowser.tabs) {
if (!tab.id) {
tab.id = this.#newTabSyncId;
lazy.TabStateFlusher.flush(tab.linkedBrowser);
}
}
});
}
/**
* @returns {string} A unique tab ID.
*/
@@ -279,6 +303,9 @@ class nsZenWindowSync {
* @returns {MozTabbrowserTab|MozTabbrowserTabGroup|null} The item element if found, otherwise null.
*/
#getItemFromWindow(aWindow, aItemId) {
if (!aItemId) {
return null;
}
return aWindow.document.getElementById(aItemId);
}
@@ -325,9 +352,9 @@ class nsZenWindowSync {
if (flags & SYNC_FLAG_LABEL) {
if (gBrowser.isTab(aOriginalItem)) {
aTargetItem._zenChangeLabelFlag = true;
aTargetItem.zenStaticLabel = aOriginalItem.zenStaticLabel;
gBrowser._setTabLabel(aTargetItem, aOriginalItem.label);
delete aTargetItem._zenChangeLabelFlag;
this.#maybeSyncAttributeChange(aOriginalItem, aTargetItem, 'zen-has-static-label');
} else if (gBrowser.isTabGroup(aOriginalItem)) {
aTargetItem.label = aOriginalItem.label;
}
@@ -493,7 +520,7 @@ class nsZenWindowSync {
}
// Restore the listeners for the swapped in tab.
if (!onClose) {
if (!onClose && filter) {
tabListener = new otherTabBrowser.zenTabProgressListener(aTab, otherBrowser, true, false);
otherTabBrowser._tabListeners.set(aTab, tabListener);
@@ -753,18 +780,21 @@ class nsZenWindowSync {
* Sets the initial pinned state for a tab across all windows.
*
* @param {Object} aTab - The tab to set the pinned state for.
* @returns {Promise} A promise that resolves when the operation is complete.
*/
setPinnedTabState(aTab) {
const state = this.#getTabState(aTab);
const initialState = {
entry: state.entries[state.index - 1],
image: state.image,
};
this.#runOnAllWindows(null, (win) => {
const targetTab = this.#getItemFromWindow(win, aTab.id);
if (targetTab) {
targetTab._zenPinnedInitialState = initialState;
}
return lazy.TabStateFlusher.flush(aTab.linkedBrowser).finally(() => {
const state = this.#getTabState(aTab);
const initialState = {
entry: state.entries[state.index - 1],
image: state.image,
};
this.#runOnAllWindows(null, (win) => {
const targetTab = this.#getItemFromWindow(win, aTab.id);
if (targetTab) {
targetTab._zenPinnedInitialState = initialState;
}
});
});
}

View File

@@ -61,10 +61,6 @@ class ZenPinnedTabsObserver {
}
class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
promiseInitializedPinned = new Promise((resolve) => {
this._resolvePinnedInitializedInternal = resolve;
});
init() {
if (!this.enabled) {
return;
@@ -797,16 +793,6 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
return document.documentElement.getAttribute('zen-sidebar-expanded') === 'true';
}
async updatePinTitle(tab, newTitle, isEdited = true) {
tab.removeAttribute('zen-has-static-label');
if (isEdited) {
gBrowser._setTabLabel(tab, newTitle);
tab.setAttribute('zen-has-static-label', 'true');
} else {
gBrowser.setTabTitle(tab);
}
}
canEssentialBeAdded(tab) {
return (
!(

View File

@@ -1248,7 +1248,7 @@ class nsZenWorkspaces {
if (this.privateWindowOrDisabled) {
return;
}
const workspacesData = this.getWorkspaces();
const workspacesData = this._workspaceCache;
const index = workspacesData.findIndex((ws) => ws.uuid === workspaceData.uuid);
if (index !== -1) {
workspacesData[index] = workspaceData;