Fixed session restore identifying the empty tab as a normal one

This commit is contained in:
mr. m
2025-03-07 11:54:57 +01:00
parent 00533fb956
commit 3325dc0d9f
6 changed files with 60 additions and 32 deletions

View File

@@ -86,8 +86,9 @@
width: 100%;
height: 100%;
opacity: 0;
color: var(--zen-primary-color);
fill: var(--zen-primary-color);
color: currentColor;
fill: currentColor;
-moz-context-properties: fill, fill-opacity;
background-image: url(chrome://browser/skin/zen-icons/essential-add.svg);
background-size: 15%;
background-repeat: no-repeat;

View File

@@ -454,9 +454,7 @@
async fadeOut() {
gZenThemePicker.panel.removeAttribute('noautohide');
gZenThemePicker.panel.removeAttribute('consumeoutsideclicks');
if (AppConstants.platform != 'macosx') {
await animate(gZenThemePicker.panel, { opacity: [1, 0] });
}
await animate(gZenThemePicker.panel, { opacity: [1, 0] });
gZenThemePicker.panel.hidePopup();
gZenThemePicker.panel.removeAttribute('style');
},

View File

@@ -626,7 +626,8 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
if (
(currentTab.isEmpty &&
(currentTab.getAttribute('image') === gPageIcons[currentTabURL] || !currentTab.hasAttribute('image'))) ||
currentTab.hasAttribute('zen-empty-tab')
currentTab.hasAttribute('zen-empty-tab') ||
currentTab._possibleEmptyTab
) {
this.selectEmptyTab();
this._removedByStartupPage = true;

View File

@@ -1,7 +1,16 @@
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
index f814772114948f87cbb3c3a7231c95ea1f68d776..296cce151690b31a6e136dd5046a2697fb46fe45 100644
index f814772114948f87cbb3c3a7231c95ea1f68d776..f7d1f1f05f33b42be6856fad52ee323751af56ee 100644
--- a/browser/components/sessionstore/SessionStore.sys.mjs
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
@@ -3171,7 +3171,7 @@ var SessionStoreInternal = {
if (!isPrivateWindow && tabState.isPrivate) {
return;
}
- if (aTab == aWindow.FirefoxViewHandler.tab) {
+ if (aTab == aWindow.FirefoxViewHandler.tab || aTab.hasAttribute("zen-empty-tab")) {
return;
}
@@ -3881,6 +3881,7 @@ var SessionStoreInternal = {
aWindow.gBrowser.selectedTab = newTab;
}
@@ -27,6 +36,15 @@ index f814772114948f87cbb3c3a7231c95ea1f68d776..296cce151690b31a6e136dd5046a2697
continue;
}
let tabData = lazy.TabState.collect(tab, TAB_CUSTOM_VALUES.get(tab));
@@ -5381,7 +5382,7 @@ 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) {
+ if (aWindow.FirefoxViewHandler.tab?.selected || tabbrowser.selectedTab.hasAttribute("zen-empty-tab")) {
selectedIndex = 1;
winData.title = tabbrowser.tabs[0].label;
}
@@ -6086,6 +6087,18 @@ var SessionStoreInternal = {
// Most of tabData has been restored, now continue with restoring

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867792a2220 100644
index 628aa6596627c85efe361fc1ece8fd58f7ee653e..10960c3fb00a00dcdcc2e2658ebff24f25d2514c 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -412,11 +412,50 @@
@@ -352,7 +352,17 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
tab.toggleAttribute("pinned", true);
this.tabContainer._invalidateCachedTabs();
// Then ensure all the tab open/pinning information is sent.
@@ -3693,7 +3815,7 @@
@@ -3503,6 +3625,9 @@
let leftoverTab = this.selectedTab;
this.selectedTab = tabToSelect;
this.removeTab(leftoverTab);
+ }
+ else {
+ this.selectedTab._possibleEmptyTab = true;
}
if (tabs.length > 1 || !tabs[0].selected) {
@@ -3693,7 +3818,7 @@
// Ensure we have an index if one was not provided.
if (typeof index != "number") {
// Move the new tab after another tab if needed, to the end otherwise.
@@ -361,7 +371,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
if (
!bulkOrderedOpen &&
((openerTab &&
@@ -3736,18 +3858,18 @@
@@ -3736,18 +3861,18 @@
// Ensure index is within bounds.
if (tab.pinned) {
@@ -384,7 +394,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
if (tabAfter && tabAfter.group == tabGroup) {
// Place at the front of, or between tabs in, the same tab group
this.tabContainer.insertBefore(tab, tabAfter);
@@ -4059,6 +4181,9 @@
@@ -4059,6 +4184,9 @@
return;
}
@@ -394,7 +404,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
this.removeTabs(selectedTabs);
}
@@ -4391,6 +4516,7 @@
@@ -4391,6 +4519,7 @@
skipSessionStore,
} = {}
) {
@@ -402,7 +412,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
if (UserInteraction.running("browser.tabs.opening", window)) {
UserInteraction.finish("browser.tabs.opening", window);
}
@@ -4407,6 +4533,12 @@
@@ -4407,6 +4536,12 @@
TelemetryStopwatch.start("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
}
@@ -415,7 +425,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
// Handle requests for synchronously removing an already
// asynchronously closing tab.
if (!animate && aTab.closing) {
@@ -4421,7 +4553,9 @@
@@ -4421,7 +4556,9 @@
// frame created for it (for example, by updating the visually selected
// state).
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
@@ -426,7 +436,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
if (
!this._beginRemoveTab(aTab, {
closeWindowFastpath: true,
@@ -4435,7 +4569,6 @@
@@ -4435,7 +4572,6 @@
TelemetryStopwatch.cancel("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
return;
}
@@ -434,7 +444,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
let lockTabSizing =
!this.tabContainer.verticalMode &&
!aTab.pinned &&
@@ -4574,14 +4707,14 @@
@@ -4574,14 +4710,14 @@
!!this.tabsInCollapsedTabGroups.length;
if (
aTab.visible &&
@@ -451,7 +461,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
if (closeWindow) {
// We've already called beforeunload on all the relevant tabs if we get here,
@@ -4605,6 +4738,7 @@
@@ -4605,6 +4741,7 @@
newTab = true;
}
@@ -459,7 +469,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
aTab._endRemoveArgs = [closeWindow, newTab];
// swapBrowsersAndCloseOther will take care of closing the window without animation.
@@ -4645,9 +4779,7 @@
@@ -4645,9 +4782,7 @@
aTab._mouseleave();
if (newTab) {
@@ -470,7 +480,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
} else {
TabBarVisibility.update();
}
@@ -4776,6 +4908,8 @@
@@ -4776,6 +4911,8 @@
this.tabs[i]._tPos = i;
}
@@ -479,7 +489,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
if (!this._windowIsClosing) {
if (wasPinned) {
this.tabContainer._positionPinnedTabs();
@@ -4994,7 +5128,7 @@
@@ -4994,7 +5131,7 @@
!excludeTabs.has(aTab.owner) &&
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
) {
@@ -488,7 +498,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
}
// Try to find a remaining tab that comes after the given tab
@@ -5016,7 +5150,7 @@
@@ -5016,7 +5153,7 @@
}
if (tab) {
@@ -497,7 +507,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
}
// If no qualifying visible tab was found, see if there is a tab in
@@ -5434,10 +5568,10 @@
@@ -5434,10 +5571,10 @@
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
}
@@ -510,7 +520,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
aTab.selected ||
aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -5675,7 +5809,7 @@
@@ -5675,7 +5812,7 @@
// Don't allow mixing pinned and unpinned tabs.
if (aTab.pinned) {
@@ -519,7 +529,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
} else {
aIndex = Math.max(aIndex, this.pinnedTabCount);
}
@@ -5684,11 +5818,18 @@
@@ -5684,11 +5821,18 @@
}
this._handleTabMove(aTab, () => {
@@ -541,7 +551,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
neighbor.after(aTab);
} else {
this.tabContainer.insertBefore(aTab, neighbor);
@@ -5697,7 +5838,7 @@
@@ -5697,7 +5841,7 @@
}
moveTabToGroup(aTab, aGroup) {
@@ -550,7 +560,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
return;
}
if (aTab.group && aTab.group.id === aGroup.id) {
@@ -5721,6 +5862,10 @@
@@ -5721,6 +5865,10 @@
moveActionCallback();
@@ -561,7 +571,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
// Clear tabs cache after moving nodes because the order of tabs may have
// changed.
this.tabContainer._invalidateCachedTabs();
@@ -5771,7 +5916,7 @@
@@ -5771,7 +5919,7 @@
createLazyBrowser,
};
@@ -570,7 +580,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
if (aIndex < numPinned || (aTab.pinned && aIndex == numPinned)) {
params.pinned = true;
}
@@ -7415,6 +7560,7 @@
@@ -7415,6 +7563,7 @@
aWebProgress.isTopLevel
) {
this.mTab.setAttribute("busy", "true");
@@ -578,7 +588,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected;
}
@@ -8381,7 +8527,7 @@ var TabContextMenu = {
@@ -8381,7 +8530,7 @@ var TabContextMenu = {
);
contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !multiselectionContext;
@@ -587,7 +597,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
// Move Tab items
let contextMoveTabOptions = document.getElementById(
"context_moveTabOptions"
@@ -8414,7 +8560,7 @@ var TabContextMenu = {
@@ -8414,7 +8563,7 @@ var TabContextMenu = {
let contextMoveTabToStart = document.getElementById("context_moveToStart");
let isFirstTab =
tabsToMove[0] == visibleTabs[0] ||
@@ -596,7 +606,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867
contextMoveTabToStart.disabled = isFirstTab && allSelectedTabsAdjacent;
document.getElementById("context_openTabInWindow").disabled =
@@ -8647,6 +8793,7 @@ var TabContextMenu = {
@@ -8647,6 +8796,7 @@ var TabContextMenu = {
if (this.contextTab.multiselected) {
gBrowser.removeMultiSelectedTabs();
} else {

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="18" width="18" viewBox="0 0 18 18"><g stroke-linecap="round" stroke-width="1.5" fill="none" stroke="context-fill" stroke-opacity="context-fill-opacity" stroke-linejoin="round" class="nc-icon-wrapper"><path d="M8.743,7.769l-.946-.315-.316-.947c-.102-.306-.609-.306-.711,0l-.316,.947-.946,.315c-.153,.051-.257,.194-.257,.356s.104,.305,.257,.356l.946,.315,.316,.947c.051,.153,.194,.256,.355,.256s.305-.104,.355-.256l.316-.947,.946-.315c.153-.051,.257-.194,.257-.356s-.104-.305-.257-.356Z" fill="currentColor" data-color="color-2" data-stroke="none" stroke="none"></path><path d="M15.144,9.976c.52-.995,.856-2.117,.856-3.367,.008-2.12-1.704-3.846-3.826-3.859-1.277,.016-2.464,.66-3.174,1.72-.709-1.061-1.896-1.704-3.173-1.72-2.123,.013-3.834,1.739-3.826,3.859,0,4.826,4.959,7.794,6.529,8.613,.297,.155,.644,.155,.941,0,.114-.059,.249-.133,.395-.214"></path><path d="M15.658,12.99l-1.263-.421-.421-1.263c-.137-.408-.812-.408-.949,0l-.421,1.263-1.263,.421c-.204,.068-.342,.259-.342,.474s.138,.406,.342,.474l1.263,.421,.421,1.263c.068,.204,.26,.342,.475,.342s.406-.138,.475-.342l.421-1.263,1.263-.421c.204-.068,.342-.259,.342-.474s-.138-.406-.342-.474Z" fill="currentColor" data-color="color-2" data-stroke="none" stroke="none"></path><circle cx="12.25" cy="6.25" r=".75" fill="currentColor" data-color="color-2" data-stroke="none" stroke="none"></circle></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" height="18" width="18" viewBox="0 0 18 18"><g stroke-linecap="round" stroke-width="1.5" fill="none" stroke="context-fill" stroke-opacity="context-fill-opacity" stroke-linejoin="round" class="nc-icon-wrapper"><path d="M8.743,7.769l-.946-.315-.316-.947c-.102-.306-.609-.306-.711,0l-.316,.947-.946,.315c-.153,.051-.257,.194-.257,.356s.104,.305,.257,.356l.946,.315,.316,.947c.051,.153,.194,.256,.355,.256s.305-.104,.355-.256l.316-.947,.946-.315c.153-.051,.257-.194,.257-.356s-.104-.305-.257-.356Z" fill="context-fill" data-color="color-2" data-stroke="none" stroke="none"></path><path d="M15.144,9.976c.52-.995,.856-2.117,.856-3.367,.008-2.12-1.704-3.846-3.826-3.859-1.277,.016-2.464,.66-3.174,1.72-.709-1.061-1.896-1.704-3.173-1.72-2.123,.013-3.834,1.739-3.826,3.859,0,4.826,4.959,7.794,6.529,8.613,.297,.155,.644,.155,.941,0,.114-.059,.249-.133,.395-.214"></path><path d="M15.658,12.99l-1.263-.421-.421-1.263c-.137-.408-.812-.408-.949,0l-.421,1.263-1.263,.421c-.204,.068-.342,.259-.342,.474s.138,.406,.342,.474l1.263,.421,.421,1.263c.068,.204,.26,.342,.475,.342s.406-.138,.475-.342l.421-1.263,1.263-.421c.204-.068,.342-.259,.342-.474s-.138-.406-.342-.474Z" fill="context-fill" data-color="color-2" data-stroke="none" stroke="none"></path><circle cx="12.25" cy="6.25" r=".75" fill="context-fill" data-color="color-2" data-stroke="none" stroke="none"></circle></g></svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB