mirror of
https://github.com/zen-browser/desktop.git
synced 2026-01-08 06:13:22 +00:00
feat: Make workspace initialization an async process for better performance, b=no-bug, c=common, kbs, workspaces
This commit is contained in:
@@ -353,3 +353,4 @@ zen-devtools-toggle-storage-shortcut = Toggle Storage
|
||||
zen-devtools-toggle-dom-shortcut = Toggle DOM
|
||||
zen-devtools-toggle-accessibility-shortcut = Toggle Accessibility
|
||||
zen-close-all-unpinned-tabs-shortcut = Close All Unpinned Tabs
|
||||
zen-new-unsynced-window-shortcut = New Unsynced Window
|
||||
|
||||
@@ -7,3 +7,6 @@
|
||||
|
||||
- name: zen.session-store.log
|
||||
value: '@IS_TWILIGHT@'
|
||||
|
||||
- name: zen.session-store.restore-unsynced-windows
|
||||
value: true
|
||||
|
||||
@@ -7,3 +7,6 @@
|
||||
|
||||
- name: zen.window-sync.log
|
||||
value: false
|
||||
|
||||
- name: zen.window-sync.prefer-unsynced-windows
|
||||
value: false
|
||||
|
||||
@@ -61,4 +61,6 @@
|
||||
|
||||
<command id="cmd_zenTogglePinTab" />
|
||||
<command id="cmd_zenCloseUnpinnedTabs" />
|
||||
|
||||
<command id="cmd_zenNewNavigatorUnsynced" />
|
||||
</commandset>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
||||
index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa1562a1acc3b 100644
|
||||
index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..d69787a3a57dcccce8616457d7eca078ef3b1fca 100644
|
||||
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
||||
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
||||
@@ -386,6 +386,7 @@
|
||||
@@ -79,7 +79,18 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
set selectedTab(val) {
|
||||
if (
|
||||
gSharedTabWarning.willShowSharedTabWarning(val) ||
|
||||
@@ -613,6 +665,7 @@
|
||||
@@ -534,6 +586,10 @@
|
||||
userContextId = parseInt(tabArgument.getAttribute("usercontextid"), 10);
|
||||
}
|
||||
|
||||
+ if (typeof window._zenStartupUnsyncedUserContextId == 'number') {
|
||||
+ userContextId = window._zenStartupUnsyncedUserContextId;
|
||||
+ }
|
||||
+
|
||||
if (tabArgument && tabArgument.linkedBrowser) {
|
||||
remoteType = tabArgument.linkedBrowser.remoteType;
|
||||
initialBrowsingContextGroupId =
|
||||
@@ -613,6 +669,7 @@
|
||||
this.tabpanels.appendChild(panel);
|
||||
|
||||
let tab = this.tabs[0];
|
||||
@@ -87,7 +98,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
tab.linkedPanel = uniqueId;
|
||||
this._selectedTab = tab;
|
||||
this._selectedBrowser = browser;
|
||||
@@ -898,13 +951,18 @@
|
||||
@@ -898,13 +955,18 @@
|
||||
}
|
||||
|
||||
this.showTab(aTab);
|
||||
@@ -107,7 +118,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
|
||||
aTab.setAttribute("pinned", "true");
|
||||
this._updateTabBarForPinnedTabs();
|
||||
@@ -917,11 +975,18 @@
|
||||
@@ -917,11 +979,18 @@
|
||||
}
|
||||
|
||||
this.#handleTabMove(aTab, () => {
|
||||
@@ -127,7 +138,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
});
|
||||
|
||||
aTab.style.marginInlineStart = "";
|
||||
@@ -1098,6 +1163,9 @@
|
||||
@@ -1098,6 +1167,9 @@
|
||||
|
||||
let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"];
|
||||
|
||||
@@ -137,7 +148,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
if (
|
||||
aIconURL &&
|
||||
!LOCAL_PROTOCOLS.some(protocol => aIconURL.startsWith(protocol))
|
||||
@@ -1107,6 +1175,9 @@
|
||||
@@ -1107,6 +1179,9 @@
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -147,7 +158,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
|
||||
let browser = this.getBrowserForTab(aTab);
|
||||
browser.mIconURL = aIconURL;
|
||||
@@ -1379,7 +1450,6 @@
|
||||
@@ -1379,7 +1454,6 @@
|
||||
|
||||
// Preview mode should not reset the owner
|
||||
if (!this._previewMode && !oldTab.selected) {
|
||||
@@ -155,7 +166,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
}
|
||||
|
||||
let lastRelatedTab = this._lastRelatedTabMap.get(oldTab);
|
||||
@@ -1470,6 +1540,7 @@
|
||||
@@ -1470,6 +1544,7 @@
|
||||
if (!this._previewMode) {
|
||||
newTab.recordTimeFromUnloadToReload();
|
||||
newTab.updateLastAccessed();
|
||||
@@ -163,7 +174,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
oldTab.updateLastAccessed();
|
||||
// if this is the foreground window, update the last-seen timestamps.
|
||||
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
|
||||
@@ -1622,6 +1693,9 @@
|
||||
@@ -1622,6 +1697,9 @@
|
||||
}
|
||||
|
||||
let activeEl = document.activeElement;
|
||||
@@ -173,7 +184,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
// If focus is on the old tab, move it to the new tab.
|
||||
if (activeEl == oldTab) {
|
||||
newTab.focus();
|
||||
@@ -1945,6 +2019,11 @@
|
||||
@@ -1945,6 +2023,11 @@
|
||||
}
|
||||
|
||||
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
|
||||
@@ -185,7 +196,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
if (!aLabel || aLabel.includes("about:reader?")) {
|
||||
return false;
|
||||
}
|
||||
@@ -2053,7 +2132,7 @@
|
||||
@@ -2053,7 +2136,7 @@
|
||||
newIndex = this.selectedTab._tPos + 1;
|
||||
}
|
||||
|
||||
@@ -194,7 +205,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
if (this.isTabGroupLabel(targetTab)) {
|
||||
throw new Error(
|
||||
"Replacing a tab group label with a tab is not supported"
|
||||
@@ -2328,6 +2407,7 @@
|
||||
@@ -2328,6 +2411,7 @@
|
||||
uriIsAboutBlank,
|
||||
userContextId,
|
||||
skipLoad,
|
||||
@@ -202,7 +213,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
} = {}) {
|
||||
let b = document.createXULElement("browser");
|
||||
// Use the JSM global to create the permanentKey, so that if the
|
||||
@@ -2401,8 +2481,7 @@
|
||||
@@ -2401,8 +2485,7 @@
|
||||
// we use a different attribute name for this?
|
||||
b.setAttribute("name", name);
|
||||
}
|
||||
@@ -212,7 +223,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
b.setAttribute("transparent", "true");
|
||||
}
|
||||
|
||||
@@ -2567,7 +2646,7 @@
|
||||
@@ -2567,7 +2650,7 @@
|
||||
|
||||
let panel = this.getPanel(browser);
|
||||
let uniqueId = this._generateUniquePanelID();
|
||||
@@ -221,7 +232,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
aTab.linkedPanel = uniqueId;
|
||||
|
||||
// Inject the <browser> into the DOM if necessary.
|
||||
@@ -2626,8 +2705,8 @@
|
||||
@@ -2626,8 +2709,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) {
|
||||
@@ -232,7 +243,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
} else {
|
||||
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
|
||||
}
|
||||
@@ -2814,7 +2893,6 @@
|
||||
@@ -2814,7 +2897,6 @@
|
||||
this.selectedTab = this.addTrustedTab(BROWSER_NEW_TAB_URL, {
|
||||
tabIndex: tab._tPos + 1,
|
||||
userContextId: tab.userContextId,
|
||||
@@ -240,7 +251,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
focusUrlBar: true,
|
||||
});
|
||||
resolve(this.selectedBrowser);
|
||||
@@ -2923,6 +3001,9 @@
|
||||
@@ -2923,6 +3005,9 @@
|
||||
schemelessInput,
|
||||
hasValidUserGestureActivation = false,
|
||||
textDirectiveUserActivation = false,
|
||||
@@ -250,7 +261,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
} = {}
|
||||
) {
|
||||
// all callers of addTab that pass a params object need to pass
|
||||
@@ -2933,10 +3014,17 @@
|
||||
@@ -2933,10 +3018,17 @@
|
||||
);
|
||||
}
|
||||
|
||||
@@ -268,7 +279,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
// If we're opening a foreground tab, set the owner by default.
|
||||
ownerTab ??= inBackground ? null : this.selectedTab;
|
||||
|
||||
@@ -2944,6 +3032,7 @@
|
||||
@@ -2944,6 +3036,7 @@
|
||||
if (this.selectedTab.owner) {
|
||||
this.selectedTab.owner = null;
|
||||
}
|
||||
@@ -276,7 +287,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
|
||||
// Find the tab that opened this one, if any. This is used for
|
||||
// determining positioning, and inherited attributes such as the
|
||||
@@ -2996,6 +3085,21 @@
|
||||
@@ -2996,6 +3089,21 @@
|
||||
noInitialLabel,
|
||||
skipBackgroundNotify,
|
||||
});
|
||||
@@ -298,7 +309,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
if (insertTab) {
|
||||
// Insert the tab into the tab container in the correct position.
|
||||
this.#insertTabAtIndex(t, {
|
||||
@@ -3004,6 +3108,7 @@
|
||||
@@ -3004,6 +3112,7 @@
|
||||
ownerTab,
|
||||
openerTab,
|
||||
pinned,
|
||||
@@ -306,7 +317,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
bulkOrderedOpen,
|
||||
tabGroup: tabGroup ?? openerTab?.group,
|
||||
});
|
||||
@@ -3022,6 +3127,7 @@
|
||||
@@ -3022,6 +3131,7 @@
|
||||
openWindowInfo,
|
||||
skipLoad,
|
||||
triggeringRemoteType,
|
||||
@@ -314,7 +325,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
}));
|
||||
|
||||
if (focusUrlBar) {
|
||||
@@ -3146,6 +3252,12 @@
|
||||
@@ -3146,6 +3256,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,7 +338,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
// Additionally send pinned tab events
|
||||
if (pinned) {
|
||||
this.#notifyPinnedStatus(t);
|
||||
@@ -3349,10 +3461,10 @@
|
||||
@@ -3349,10 +3465,10 @@
|
||||
isAdoptingGroup = false,
|
||||
isUserTriggered = false,
|
||||
telemetryUserCreateSource = "unknown",
|
||||
@@ -339,7 +350,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
}
|
||||
|
||||
if (!color) {
|
||||
@@ -3373,9 +3485,14 @@
|
||||
@@ -3373,9 +3489,14 @@
|
||||
label,
|
||||
isAdoptingGroup
|
||||
);
|
||||
@@ -356,7 +367,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
);
|
||||
group.addTabs(tabs);
|
||||
|
||||
@@ -3496,7 +3613,7 @@
|
||||
@@ -3496,7 +3617,7 @@
|
||||
}
|
||||
|
||||
this.#handleTabMove(tab, () =>
|
||||
@@ -365,7 +376,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3698,6 +3815,7 @@
|
||||
@@ -3698,6 +3819,7 @@
|
||||
openWindowInfo,
|
||||
skipLoad,
|
||||
triggeringRemoteType,
|
||||
@@ -373,7 +384,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
}
|
||||
) {
|
||||
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
|
||||
@@ -3767,6 +3885,7 @@
|
||||
@@ -3767,6 +3889,7 @@
|
||||
openWindowInfo,
|
||||
name,
|
||||
skipLoad,
|
||||
@@ -381,7 +392,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3955,7 +4074,7 @@
|
||||
@@ -3955,7 +4078,7 @@
|
||||
// Add a new tab if needed.
|
||||
if (!tab) {
|
||||
let createLazyBrowser =
|
||||
@@ -390,7 +401,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
|
||||
let url = "about:blank";
|
||||
if (tabData.entries?.length) {
|
||||
@@ -3992,8 +4111,10 @@
|
||||
@@ -3992,8 +4115,10 @@
|
||||
insertTab: false,
|
||||
skipLoad: true,
|
||||
preferredRemoteType,
|
||||
@@ -402,7 +413,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
if (select) {
|
||||
tabToSelect = tab;
|
||||
}
|
||||
@@ -4005,7 +4126,8 @@
|
||||
@@ -4005,7 +4130,8 @@
|
||||
this.pinTab(tab);
|
||||
// Then ensure all the tab open/pinning information is sent.
|
||||
this._fireTabOpen(tab, {});
|
||||
@@ -412,7 +423,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
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 +4141,10 @@
|
||||
@@ -4019,7 +4145,10 @@
|
||||
tabGroup.stateData.id,
|
||||
tabGroup.stateData.color,
|
||||
tabGroup.stateData.collapsed,
|
||||
@@ -424,7 +435,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
);
|
||||
tabsFragment.appendChild(tabGroup.node);
|
||||
}
|
||||
@@ -4064,9 +4189,23 @@
|
||||
@@ -4064,9 +4193,23 @@
|
||||
// to remove the old selected tab.
|
||||
if (tabToSelect) {
|
||||
let leftoverTab = this.selectedTab;
|
||||
@@ -440,15 +451,15 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
+ gZenWorkspaces._initialTab._shouldRemove = true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+ else {
|
||||
+ gZenWorkspaces._tabToRemoveForEmpty = this.selectedTab;
|
||||
}
|
||||
+ }
|
||||
+ this._hasAlreadyInitializedZenSessionStore = true;
|
||||
|
||||
if (tabs.length > 1 || !tabs[0].selected) {
|
||||
this._updateTabsAfterInsert();
|
||||
@@ -4257,11 +4396,14 @@
|
||||
@@ -4257,11 +4400,14 @@
|
||||
if (ownerTab) {
|
||||
tab.owner = ownerTab;
|
||||
}
|
||||
@@ -464,7 +475,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
if (
|
||||
!bulkOrderedOpen &&
|
||||
((openerTab &&
|
||||
@@ -4273,7 +4415,7 @@
|
||||
@@ -4273,7 +4419,7 @@
|
||||
let lastRelatedTab =
|
||||
openerTab && this._lastRelatedTabMap.get(openerTab);
|
||||
let previousTab = lastRelatedTab || openerTab || this.selectedTab;
|
||||
@@ -473,7 +484,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
tabGroup = previousTab.group;
|
||||
}
|
||||
if (
|
||||
@@ -4284,7 +4426,7 @@
|
||||
@@ -4284,7 +4430,7 @@
|
||||
) {
|
||||
elementIndex = Infinity;
|
||||
} else if (previousTab.visible) {
|
||||
@@ -482,7 +493,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
} else if (previousTab == FirefoxViewHandler.tab) {
|
||||
elementIndex = 0;
|
||||
}
|
||||
@@ -4312,14 +4454,14 @@
|
||||
@@ -4312,14 +4458,14 @@
|
||||
}
|
||||
// Ensure index is within bounds.
|
||||
if (tab.pinned) {
|
||||
@@ -501,7 +512,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
|
||||
if (pinned && !itemAfter?.pinned) {
|
||||
itemAfter = null;
|
||||
@@ -4330,7 +4472,7 @@
|
||||
@@ -4330,7 +4476,7 @@
|
||||
|
||||
this.tabContainer._invalidateCachedTabs();
|
||||
|
||||
@@ -510,7 +521,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
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 +4500,11 @@
|
||||
@@ -4358,7 +4504,11 @@
|
||||
const tabContainer = pinned
|
||||
? this.tabContainer.pinnedTabsContainer
|
||||
: this.tabContainer;
|
||||
@@ -522,7 +533,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
}
|
||||
|
||||
this._updateTabsAfterInsert();
|
||||
@@ -4366,6 +4512,7 @@
|
||||
@@ -4366,6 +4516,7 @@
|
||||
if (pinned) {
|
||||
this._updateTabBarForPinnedTabs();
|
||||
}
|
||||
@@ -530,7 +541,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
|
||||
TabBarVisibility.update();
|
||||
}
|
||||
@@ -4916,6 +5063,7 @@
|
||||
@@ -4916,6 +5067,7 @@
|
||||
telemetrySource,
|
||||
} = {}
|
||||
) {
|
||||
@@ -538,7 +549,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
|
||||
// can be considered equivalent to closing the window.
|
||||
if (
|
||||
@@ -5005,6 +5153,7 @@
|
||||
@@ -5005,6 +5157,7 @@
|
||||
if (lastToClose) {
|
||||
this.removeTab(lastToClose, aParams);
|
||||
}
|
||||
@@ -546,7 +557,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
@@ -5043,6 +5192,12 @@
|
||||
@@ -5043,6 +5196,12 @@
|
||||
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
|
||||
}
|
||||
|
||||
@@ -559,7 +570,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
// Handle requests for synchronously removing an already
|
||||
// asynchronously closing tab.
|
||||
if (!animate && aTab.closing) {
|
||||
@@ -5057,6 +5212,9 @@
|
||||
@@ -5057,6 +5216,9 @@
|
||||
// state).
|
||||
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
|
||||
let isLastTab = this.#isLastTabInWindow(aTab);
|
||||
@@ -569,7 +580,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
if (
|
||||
!this._beginRemoveTab(aTab, {
|
||||
closeWindowFastpath: true,
|
||||
@@ -5105,7 +5263,13 @@
|
||||
@@ -5105,7 +5267,13 @@
|
||||
// We're not animating, so we can cancel the animation stopwatch.
|
||||
Glean.browserTabclose.timeAnim.cancel(aTab._closeTimeAnimTimerId);
|
||||
aTab._closeTimeAnimTimerId = null;
|
||||
@@ -584,7 +595,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5239,7 +5403,7 @@
|
||||
@@ -5239,7 +5407,7 @@
|
||||
closeWindowWithLastTab != null
|
||||
? closeWindowWithLastTab
|
||||
: !window.toolbar.visible ||
|
||||
@@ -593,7 +604,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
|
||||
if (closeWindow) {
|
||||
// We've already called beforeunload on all the relevant tabs if we get here,
|
||||
@@ -5263,6 +5427,7 @@
|
||||
@@ -5263,6 +5431,7 @@
|
||||
|
||||
newTab = true;
|
||||
}
|
||||
@@ -601,7 +612,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
aTab._endRemoveArgs = [closeWindow, newTab];
|
||||
|
||||
// swapBrowsersAndCloseOther will take care of closing the window without animation.
|
||||
@@ -5303,13 +5468,7 @@
|
||||
@@ -5303,13 +5472,7 @@
|
||||
aTab._mouseleave();
|
||||
|
||||
if (newTab) {
|
||||
@@ -616,7 +627,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
} else {
|
||||
TabBarVisibility.update();
|
||||
}
|
||||
@@ -5442,6 +5601,7 @@
|
||||
@@ -5442,6 +5605,7 @@
|
||||
this.tabs[i]._tPos = i;
|
||||
}
|
||||
|
||||
@@ -624,7 +635,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
if (!this._windowIsClosing) {
|
||||
// update tab close buttons state
|
||||
this.tabContainer._updateCloseButtons();
|
||||
@@ -5663,6 +5823,7 @@
|
||||
@@ -5663,6 +5827,7 @@
|
||||
}
|
||||
|
||||
let excludeTabs = new Set(aExcludeTabs);
|
||||
@@ -632,7 +643,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
|
||||
// If this tab has a successor, it should be selectable, since
|
||||
// hiding or closing a tab removes that tab as a successor.
|
||||
@@ -5675,13 +5836,13 @@
|
||||
@@ -5675,13 +5840,13 @@
|
||||
!excludeTabs.has(aTab.owner) &&
|
||||
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
|
||||
) {
|
||||
@@ -648,7 +659,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
);
|
||||
|
||||
let tab = this.tabContainer.findNextTab(aTab, {
|
||||
@@ -5697,7 +5858,7 @@
|
||||
@@ -5697,7 +5862,7 @@
|
||||
}
|
||||
|
||||
if (tab) {
|
||||
@@ -657,7 +668,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
}
|
||||
|
||||
// If no qualifying visible tab was found, see if there is a tab in
|
||||
@@ -5718,7 +5879,7 @@
|
||||
@@ -5718,7 +5883,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
@@ -666,7 +677,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
}
|
||||
|
||||
_blurTab(aTab) {
|
||||
@@ -5729,7 +5890,7 @@
|
||||
@@ -5729,7 +5894,7 @@
|
||||
* @returns {boolean}
|
||||
* False if swapping isn't permitted, true otherwise.
|
||||
*/
|
||||
@@ -675,7 +686,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
// Do not allow transfering a private tab to a non-private window
|
||||
// and vice versa.
|
||||
if (
|
||||
@@ -5783,6 +5944,7 @@
|
||||
@@ -5783,6 +5948,7 @@
|
||||
// fire the beforeunload event in the process. Close the other
|
||||
// window if this was its last tab.
|
||||
if (
|
||||
@@ -683,7 +694,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
!remoteBrowser._beginRemoveTab(aOtherTab, {
|
||||
adoptedByTab: aOurTab,
|
||||
closeWindowWithLastTab: true,
|
||||
@@ -5794,7 +5956,7 @@
|
||||
@@ -5794,7 +5960,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.
|
||||
@@ -692,7 +703,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
if (closeWindow) {
|
||||
let win = aOtherTab.ownerGlobal;
|
||||
win.windowUtils.suppressAnimation(true);
|
||||
@@ -5918,11 +6080,13 @@
|
||||
@@ -5918,11 +6084,13 @@
|
||||
}
|
||||
|
||||
// Finish tearing down the tab that's going away.
|
||||
@@ -706,7 +717,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
|
||||
this.setTabTitle(aOurTab);
|
||||
|
||||
@@ -6124,10 +6288,10 @@
|
||||
@@ -6124,10 +6292,10 @@
|
||||
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
|
||||
}
|
||||
|
||||
@@ -719,7 +730,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
aTab.selected ||
|
||||
aTab.closing ||
|
||||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
|
||||
@@ -6185,7 +6349,8 @@
|
||||
@@ -6185,7 +6353,8 @@
|
||||
*
|
||||
* @param {MozTabbrowserTab|MozTabbrowserTabGroup|MozTabbrowserTabGroup.labelElement} aTab
|
||||
*/
|
||||
@@ -729,7 +740,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
if (this.tabs.length == 1) {
|
||||
return null;
|
||||
}
|
||||
@@ -6209,12 +6374,14 @@
|
||||
@@ -6209,12 +6378,14 @@
|
||||
}
|
||||
|
||||
// tell a new window to take the "dropped" tab
|
||||
@@ -745,7 +756,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6319,7 +6486,7 @@
|
||||
@@ -6319,7 +6490,7 @@
|
||||
* `true` if element is a `<tab-group>`
|
||||
*/
|
||||
isTabGroup(element) {
|
||||
@@ -754,7 +765,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6404,8 +6571,8 @@
|
||||
@@ -6404,8 +6575,8 @@
|
||||
}
|
||||
|
||||
// Don't allow mixing pinned and unpinned tabs.
|
||||
@@ -765,7 +776,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
} else {
|
||||
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
|
||||
}
|
||||
@@ -6431,10 +6598,16 @@
|
||||
@@ -6431,10 +6602,16 @@
|
||||
this.#handleTabMove(
|
||||
element,
|
||||
() => {
|
||||
@@ -784,7 +795,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
|
||||
neighbor.after(element);
|
||||
} else {
|
||||
@@ -6492,23 +6665,31 @@
|
||||
@@ -6492,23 +6669,31 @@
|
||||
#moveTabNextTo(element, targetElement, moveBefore = false, metricsContext) {
|
||||
if (this.isTabGroupLabel(targetElement)) {
|
||||
targetElement = targetElement.group;
|
||||
@@ -822,7 +833,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
} 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 +6702,34 @@
|
||||
@@ -6521,14 +6706,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.
|
||||
@@ -858,7 +869,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
element.pinned
|
||||
? this.tabContainer.pinnedTabsContainer
|
||||
: this.tabContainer;
|
||||
@@ -6537,7 +6738,7 @@
|
||||
@@ -6537,7 +6742,7 @@
|
||||
element,
|
||||
() => {
|
||||
if (moveBefore) {
|
||||
@@ -867,7 +878,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
} else if (targetElement) {
|
||||
targetElement.after(element);
|
||||
} else {
|
||||
@@ -6607,10 +6808,10 @@
|
||||
@@ -6607,10 +6812,10 @@
|
||||
* @param {TabMetricsContext} [metricsContext]
|
||||
*/
|
||||
moveTabToGroup(aTab, aGroup, metricsContext) {
|
||||
@@ -880,7 +891,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
return;
|
||||
}
|
||||
if (aTab.group && aTab.group.id === aGroup.id) {
|
||||
@@ -6656,6 +6857,7 @@
|
||||
@@ -6656,6 +6861,7 @@
|
||||
|
||||
let state = {
|
||||
tabIndex: tab._tPos,
|
||||
@@ -888,7 +899,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
};
|
||||
if (tab.visible) {
|
||||
state.elementIndex = tab.elementIndex;
|
||||
@@ -6682,7 +6884,7 @@
|
||||
@@ -6682,7 +6888,7 @@
|
||||
let changedTabGroup =
|
||||
previousTabState.tabGroupId != currentTabState.tabGroupId;
|
||||
|
||||
@@ -897,7 +908,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
tab.dispatchEvent(
|
||||
new CustomEvent("TabMove", {
|
||||
bubbles: true,
|
||||
@@ -6723,6 +6925,10 @@
|
||||
@@ -6723,6 +6929,10 @@
|
||||
|
||||
moveActionCallback();
|
||||
|
||||
@@ -908,7 +919,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
// Clear tabs cache after moving nodes because the order of tabs may have
|
||||
// changed.
|
||||
this.tabContainer._invalidateCachedTabs();
|
||||
@@ -6815,6 +7021,8 @@
|
||||
@@ -6815,6 +7025,8 @@
|
||||
params.userContextId = aTab.getAttribute("usercontextid");
|
||||
}
|
||||
let newTab = this.addWebTab("about:blank", params);
|
||||
@@ -917,7 +928,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
let newBrowser = this.getBrowserForTab(newTab);
|
||||
|
||||
aTab.container.tabDragAndDrop.finishAnimateTabMove();
|
||||
@@ -7623,7 +7831,7 @@
|
||||
@@ -7623,7 +7835,7 @@
|
||||
// preventDefault(). It will still raise the window if appropriate.
|
||||
break;
|
||||
}
|
||||
@@ -926,7 +937,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
window.focus();
|
||||
aEvent.preventDefault();
|
||||
break;
|
||||
@@ -7640,7 +7848,6 @@
|
||||
@@ -7640,7 +7852,6 @@
|
||||
}
|
||||
case "TabGroupCollapse":
|
||||
aEvent.target.tabs.forEach(tab => {
|
||||
@@ -934,7 +945,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
});
|
||||
break;
|
||||
case "TabGroupCreateByUser":
|
||||
@@ -7800,7 +8007,9 @@
|
||||
@@ -7800,7 +8011,9 @@
|
||||
|
||||
let filter = this._tabFilters.get(tab);
|
||||
if (filter) {
|
||||
@@ -944,7 +955,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
|
||||
let listener = this._tabListeners.get(tab);
|
||||
if (listener) {
|
||||
@@ -8589,6 +8798,7 @@
|
||||
@@ -8589,6 +8802,7 @@
|
||||
aWebProgress.isTopLevel
|
||||
) {
|
||||
this.mTab.setAttribute("busy", "true");
|
||||
@@ -952,7 +963,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
gBrowser._tabAttrModified(this.mTab, ["busy"]);
|
||||
this.mTab._notselectedsinceload = !this.mTab.selected;
|
||||
}
|
||||
@@ -8670,6 +8880,7 @@
|
||||
@@ -8670,6 +8884,7 @@
|
||||
// known defaults. Note we use the original URL since about:newtab
|
||||
// redirects to a prerendered page.
|
||||
const shouldRemoveFavicon =
|
||||
@@ -960,7 +971,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..0b22d01a9f75c08da43edc40100fa156
|
||||
!this.mBrowser.mIconURL &&
|
||||
!ignoreBlank &&
|
||||
!(originalLocation.spec in FAVICON_DEFAULTS);
|
||||
@@ -9623,7 +9834,7 @@ var TabContextMenu = {
|
||||
@@ -9623,7 +9838,7 @@ var TabContextMenu = {
|
||||
);
|
||||
contextUnpinSelectedTabs.hidden =
|
||||
!this.contextTab.pinned || !this.multiselected;
|
||||
|
||||
25
src/browser/modules/BrowserWindowTracker-sys-mjs.patch
Normal file
25
src/browser/modules/BrowserWindowTracker-sys-mjs.patch
Normal file
@@ -0,0 +1,25 @@
|
||||
diff --git a/browser/modules/BrowserWindowTracker.sys.mjs b/browser/modules/BrowserWindowTracker.sys.mjs
|
||||
index f2b64cfbdf579c67496b785c8efafc69bf20372a..f3d8755aa7d122d9ee5c449a02cceb629aa6aa00 100644
|
||||
--- a/browser/modules/BrowserWindowTracker.sys.mjs
|
||||
+++ b/browser/modules/BrowserWindowTracker.sys.mjs
|
||||
@@ -325,6 +325,7 @@ export const BrowserWindowTracker = {
|
||||
args = null,
|
||||
remote = undefined,
|
||||
fission = undefined,
|
||||
+ zenSyncedWindow = true,
|
||||
} = {}) {
|
||||
let windowFeatures = "chrome,dialog=no";
|
||||
if (all) {
|
||||
@@ -378,6 +379,12 @@ export const BrowserWindowTracker = {
|
||||
windowFeatures,
|
||||
args
|
||||
);
|
||||
+ win._zenStartupSyncFlag = Services.prefs.getBoolPref("zen.window-sync.prefer-unsynced-windows")
|
||||
+ ? (zenSyncedWindow ? 'unsynced' : 'synced')
|
||||
+ : (zenSyncedWindow ? 'synced' : 'unsynced');
|
||||
+ if (win._zenStartupSyncFlag === 'unsynced' && openerWindow) {
|
||||
+ win._zenStartupUnsyncedUserContextId = openerWindow.gZenWorkspaces.getCurrentSpaceContainerId();
|
||||
+ }
|
||||
this.registerOpeningWindow(win, isPrivate);
|
||||
|
||||
win.addEventListener(
|
||||
@@ -51,6 +51,17 @@ export class nsZenMultiWindowFeature {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forEachWindowSync(callback) {
|
||||
for (const browser of nsZenMultiWindowFeature.browsers) {
|
||||
try {
|
||||
if (browser.closed) continue;
|
||||
callback(browser);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class nsZenDOMOperatedFeature {
|
||||
|
||||
@@ -235,14 +235,14 @@
|
||||
);
|
||||
--zen-main-browser-background-toolbar: var(--zen-main-browser-background);
|
||||
--zen-primary-color: light-dark(rgb(93, 42, 107), rgb(110, 48, 125)) !important;
|
||||
--toolbox-textcolor: currentColor !important;
|
||||
--toolbox-textcolor: color-mix(in srgb, currentColor 95%, transparent) !important;
|
||||
}
|
||||
|
||||
&[zen-unsynced-window='true'] {
|
||||
--zen-main-browser-background: color-mix(in srgb, light-dark(rgb(196, 202, 229), rgb(8, 9, 40)) 60%, var(--zen-themed-toolbar-bg-transparent));
|
||||
--zen-main-browser-background-toolbar: var(--zen-main-browser-background);
|
||||
--zen-primary-color: light-dark(rgb(100, 115, 255), rgb(80, 90, 200)) !important;
|
||||
--toolbox-textcolor: currentColor !important;
|
||||
--toolbox-textcolor: color-mix(in srgb, currentColor 95%, transparent) !important;
|
||||
--zen-workspace-indicator-height: 42px;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,9 @@ document.addEventListener(
|
||||
gZenWorkspaces.unloadWorkspace();
|
||||
break;
|
||||
}
|
||||
case 'cmd_zenNewNavigatorUnsynced':
|
||||
OpenBrowserWindow({ zenSyncedWindow: false });
|
||||
break;
|
||||
default:
|
||||
gZenGlanceManager.handleMainCommandSet(event);
|
||||
if (event.target.id.startsWith('cmd_zenWorkspaceSwitch')) {
|
||||
|
||||
@@ -47,6 +47,7 @@ const KEYCODE_MAP = {
|
||||
const defaultKeyboardGroups = {
|
||||
windowAndTabManagement: [
|
||||
'zen-window-new-shortcut',
|
||||
'zen-new-unsynced-window-shortcut',
|
||||
'zen-tab-new-shortcut',
|
||||
'zen-key-enter-full-screen',
|
||||
'zen-key-exit-full-screen',
|
||||
@@ -71,7 +72,6 @@ const defaultKeyboardGroups = {
|
||||
'zen-nav-reload-shortcut-skip-cache',
|
||||
'zen-nav-reload-shortcut',
|
||||
'zen-key-stop',
|
||||
'zen-window-new-shortcut',
|
||||
'zen-private-browsing-shortcut',
|
||||
'id:goHome',
|
||||
'id:key_gotoHistory',
|
||||
@@ -804,7 +804,7 @@ class nsZenKeyboardShortcutsLoader {
|
||||
}
|
||||
|
||||
class nsZenKeyboardShortcutsVersioner {
|
||||
static LATEST_KBS_VERSION = 13;
|
||||
static LATEST_KBS_VERSION = 14;
|
||||
|
||||
constructor() {}
|
||||
|
||||
@@ -1087,6 +1087,8 @@ class nsZenKeyboardShortcutsVersioner {
|
||||
}
|
||||
|
||||
if (version < 13) {
|
||||
// Migrate from version 12 to 13
|
||||
// Add shortcut to close all unpinned tabs: Default Accel+Shift+K
|
||||
data.push(
|
||||
new KeyShortcut(
|
||||
'zen-close-all-unpinned-tabs',
|
||||
@@ -1100,6 +1102,22 @@ class nsZenKeyboardShortcutsVersioner {
|
||||
);
|
||||
}
|
||||
|
||||
if (version < 14) {
|
||||
// Migrate from version 13 to 14
|
||||
// Add shortcut to open a new unsynced window: Default accelt+option+N (Ctrl+Alt+N on non-macOS)
|
||||
data.push(
|
||||
new KeyShortcut(
|
||||
'zen-new-unsynced-window',
|
||||
'N',
|
||||
'',
|
||||
ZEN_OTHER_SHORTCUTS_GROUP,
|
||||
nsKeyShortcutModifiers.fromObject({ accel: true, alt: true }),
|
||||
'cmd_zenNewNavigatorUnsynced',
|
||||
'zen-new-unsynced-window-shortcut'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,13 +200,19 @@ export class nsZenSessionManager {
|
||||
// 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.
|
||||
const allowRestoreUnsynced = Services.prefs.getBoolPref(
|
||||
'zen.session-store.restore-unsynced-windows',
|
||||
true
|
||||
);
|
||||
this.log(`Restoring Zen session data into ${initialState.windows?.length || 0} windows`);
|
||||
for (let i = 0; i < initialState.windows.length; i++) {
|
||||
let winData = initialState.windows[i];
|
||||
if (winData.isZenUnsynced) {
|
||||
// We don't wan't to restore any unsynced windows with the sidebar data.
|
||||
this.log('Skipping restore of unsynced window');
|
||||
delete initialState.windows[i];
|
||||
if (!allowRestoreUnsynced) {
|
||||
// We don't wan't to restore any unsynced windows with the sidebar data.
|
||||
this.log('Skipping restore of unsynced window');
|
||||
delete initialState.windows[i];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
this.#restoreWindowData(winData);
|
||||
|
||||
@@ -593,7 +593,7 @@ export class nsZenThemePicker extends nsZenMultiWindowFeature {
|
||||
this.panel.querySelector('#PanelUI-zen-gradient-generator-custom-list').prepend(dot);
|
||||
this.customColorInput.value = '';
|
||||
document.getElementById('PanelUI-zen-gradient-generator-custom-opacity').value = 1;
|
||||
await this.updateCurrentWorkspace();
|
||||
this.updateCurrentWorkspace();
|
||||
}
|
||||
|
||||
handlePanelCommand(event) {
|
||||
@@ -1313,17 +1313,17 @@ export class nsZenThemePicker extends nsZenMultiWindowFeature {
|
||||
return isDarkMode ? [255, 255, 255, 0.6] : [0, 0, 0, 0.6]; // Default toolbar
|
||||
}
|
||||
|
||||
async onWorkspaceChange(workspace, skipUpdate = false, theme = null) {
|
||||
onWorkspaceChange(workspace, skipUpdate = false, theme = null) {
|
||||
const uuid = workspace.uuid;
|
||||
// Use theme from workspace object or passed theme
|
||||
let workspaceTheme = theme || workspace.theme;
|
||||
|
||||
await this.forEachWindow(async (browser) => {
|
||||
this.forEachWindowSync((browser) => {
|
||||
if (!browser.gZenThemePicker?.promiseInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (browser.closing || (await browser.gZenThemePicker?.promiseInitialized)) {
|
||||
if (browser.closing) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1602,7 +1602,7 @@ export class nsZenThemePicker extends nsZenMultiWindowFeature {
|
||||
}
|
||||
}
|
||||
|
||||
async updateCurrentWorkspace(skipSave = true) {
|
||||
updateCurrentWorkspace(skipSave = true) {
|
||||
this.updated = skipSave;
|
||||
const dots = this.panel.querySelectorAll('.zen-theme-picker-dot');
|
||||
const colors = Array.from(dots)
|
||||
@@ -1637,12 +1637,12 @@ export class nsZenThemePicker extends nsZenMultiWindowFeature {
|
||||
gZenWorkspaces.saveWorkspace(currentWorkspace);
|
||||
}
|
||||
|
||||
await this.onWorkspaceChange(currentWorkspace, skipSave, skipSave ? gradient : null);
|
||||
this.onWorkspaceChange(currentWorkspace, skipSave, skipSave ? gradient : null);
|
||||
}
|
||||
|
||||
async handlePanelClose() {
|
||||
handlePanelClose() {
|
||||
if (this.updated) {
|
||||
await this.updateCurrentWorkspace(false);
|
||||
this.updateCurrentWorkspace(false);
|
||||
}
|
||||
this.uninitThemePicker();
|
||||
}
|
||||
|
||||
@@ -256,14 +256,6 @@ export class nsZenWorkspace extends MozXULElement {
|
||||
tabPinCallback();
|
||||
}
|
||||
});
|
||||
|
||||
this.dispatchEvent(
|
||||
new CustomEvent('ZenWorkspaceAttached', {
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
detail: { workspace: this },
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
|
||||
@@ -306,7 +306,7 @@ class nsZenWorkspaces {
|
||||
}
|
||||
|
||||
registerPinnedResizeObserver() {
|
||||
if (!this._hasInitializedTabsStrip) {
|
||||
if (!this._hasInitializedTabsStrip || !this._pinnedTabsResizeObserver) {
|
||||
return;
|
||||
}
|
||||
this._pinnedTabsResizeObserver.disconnect();
|
||||
@@ -369,15 +369,13 @@ class nsZenWorkspaces {
|
||||
return document.getElementById(workspaceId);
|
||||
}
|
||||
|
||||
async #initializeTabsStripSections() {
|
||||
await SessionStore.promiseInitialized;
|
||||
await SessionStore.promiseAllWindowsRestored;
|
||||
#initializeTabsStripSections() {
|
||||
const perifery = document.getElementById('tabbrowser-arrowscrollbox-periphery');
|
||||
perifery.setAttribute('hidden', 'true');
|
||||
const tabs = gBrowser.tabContainer.allTabs;
|
||||
const workspaces = this.getWorkspaces();
|
||||
for (const workspace of workspaces) {
|
||||
await this.#createWorkspaceTabsSection(workspace, tabs);
|
||||
this.#createWorkspaceTabsSection(workspace, tabs);
|
||||
}
|
||||
if (tabs.length) {
|
||||
const defaultSelectedContainer = this.workspaceElement(this.activeWorkspace)?.querySelector(
|
||||
@@ -438,12 +436,16 @@ class nsZenWorkspaces {
|
||||
return essentialsContainer;
|
||||
}
|
||||
|
||||
getCurrentEssentialsContainer() {
|
||||
getCurrentSpaceContainerId() {
|
||||
const currentWorkspace = this.getActiveWorkspaceFromCache();
|
||||
return this.getEssentialsSection(currentWorkspace?.containerTabId);
|
||||
return currentWorkspace?.containerTabId || 0;
|
||||
}
|
||||
|
||||
async #createWorkspaceTabsSection(workspace, tabs = []) {
|
||||
getCurrentEssentialsContainer() {
|
||||
return this.getEssentialsSection(this.getCurrentSpaceContainerId());
|
||||
}
|
||||
|
||||
#createWorkspaceTabsSection(workspace, tabs = []) {
|
||||
const workspaceWrapper = document.createXULElement('zen-workspace');
|
||||
const container = document.getElementById('tabbrowser-arrowscrollbox');
|
||||
workspaceWrapper.id = workspace.uuid;
|
||||
@@ -454,24 +456,14 @@ class nsZenWorkspaces {
|
||||
if (document.documentElement.hasAttribute('zen-creating-workspace')) {
|
||||
workspaceWrapper.hidden = true; // Hide workspace while creating it
|
||||
}
|
||||
|
||||
await new Promise((resolve) => {
|
||||
workspaceWrapper.addEventListener(
|
||||
'ZenWorkspaceAttached',
|
||||
() => {
|
||||
this.#organizeTabsToWorkspaceSections(
|
||||
workspace,
|
||||
workspaceWrapper.tabsContainer,
|
||||
workspaceWrapper.pinnedTabsContainer,
|
||||
tabs
|
||||
);
|
||||
workspaceWrapper.checkPinsExistence();
|
||||
resolve();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
container.appendChild(workspaceWrapper);
|
||||
});
|
||||
container.appendChild(workspaceWrapper);
|
||||
this.#organizeTabsToWorkspaceSections(
|
||||
workspace,
|
||||
workspaceWrapper.tabsContainer,
|
||||
workspaceWrapper.pinnedTabsContainer,
|
||||
tabs
|
||||
);
|
||||
workspaceWrapper.checkPinsExistence();
|
||||
}
|
||||
|
||||
#organizeTabsToWorkspaceSections(workspace, section, pinnedSection, tabs) {
|
||||
@@ -864,16 +856,16 @@ class nsZenWorkspaces {
|
||||
return this._workspaceCache;
|
||||
}
|
||||
|
||||
async restoreWorkspacesFromSessionStore(aWinData = {}) {
|
||||
restoreWorkspacesFromSessionStore(aWinData = {}) {
|
||||
if (this.#hasInitialized || !this.workspaceEnabled) {
|
||||
return;
|
||||
}
|
||||
const spacesFromStore = aWinData.spaces || [];
|
||||
this._workspaceCache = spacesFromStore.length
|
||||
? [...spacesFromStore]
|
||||
: [await this.createAndSaveWorkspace('Space', undefined, true)];
|
||||
: [this.#createWorkspaceData('Space', undefined, true)];
|
||||
this.activeWorkspace = aWinData.activeZenSpace || this._workspaceCache[0].uuid;
|
||||
await this.initializeWorkspaces();
|
||||
let promise = this.#initializeWorkspaces();
|
||||
for (const workspace of spacesFromStore) {
|
||||
const element = this.workspaceElement(workspace.uuid);
|
||||
if (element) {
|
||||
@@ -885,42 +877,44 @@ class nsZenWorkspaces {
|
||||
delete workspace.hasCollapsedPinnedTabs;
|
||||
}
|
||||
this.#hasInitialized = true;
|
||||
return promise;
|
||||
}
|
||||
|
||||
async initializeWorkspaces() {
|
||||
#initializeWorkspaces() {
|
||||
let activeWorkspace = this.getActiveWorkspace();
|
||||
this.activeWorkspace = activeWorkspace?.uuid;
|
||||
await gZenSessionStore.promiseInitialized;
|
||||
try {
|
||||
if (activeWorkspace) {
|
||||
window.gZenThemePicker = new nsZenThemePicker();
|
||||
await gZenThemePicker.onWorkspaceChange(activeWorkspace);
|
||||
gZenThemePicker.onWorkspaceChange(activeWorkspace);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('gZenWorkspaces: Error initializing theme picker', e);
|
||||
}
|
||||
await this.#initializeTabsStripSections();
|
||||
this.#initializeTabsStripSections();
|
||||
this.#initializeEmptyTab();
|
||||
await this.workspaceBookmarks();
|
||||
await this.changeWorkspace(activeWorkspace, { onInit: true });
|
||||
this.#fixTabPositions();
|
||||
this.onWindowResize();
|
||||
this._resolveInitialized();
|
||||
this.#clearAnyZombieTabs(); // Dont call with await
|
||||
delete this._resolveInitialized;
|
||||
return (async () => {
|
||||
await this.workspaceBookmarks();
|
||||
await this.changeWorkspace(activeWorkspace, { onInit: true });
|
||||
this.#fixTabPositions();
|
||||
this.onWindowResize();
|
||||
this._resolveInitialized();
|
||||
this.#clearAnyZombieTabs(); // Dont call with await
|
||||
delete this._resolveInitialized;
|
||||
|
||||
const tabUpdateListener = this.updateTabsContainers.bind(this);
|
||||
window.addEventListener('TabOpen', tabUpdateListener);
|
||||
window.addEventListener('TabClose', tabUpdateListener);
|
||||
window.addEventListener('TabAddedToEssentials', tabUpdateListener);
|
||||
window.addEventListener('TabRemovedFromEssentials', tabUpdateListener);
|
||||
window.addEventListener('TabPinned', tabUpdateListener);
|
||||
window.addEventListener('TabUnpinned', tabUpdateListener);
|
||||
window.addEventListener('aftercustomization', tabUpdateListener);
|
||||
window.addEventListener('TabSelect', this.onLocationChange.bind(this));
|
||||
window.addEventListener('TabBrowserInserted', this.onTabBrowserInserted.bind(this));
|
||||
const tabUpdateListener = this.updateTabsContainers.bind(this);
|
||||
window.addEventListener('TabOpen', tabUpdateListener);
|
||||
window.addEventListener('TabClose', tabUpdateListener);
|
||||
window.addEventListener('TabAddedToEssentials', tabUpdateListener);
|
||||
window.addEventListener('TabRemovedFromEssentials', tabUpdateListener);
|
||||
window.addEventListener('TabPinned', tabUpdateListener);
|
||||
window.addEventListener('TabUnpinned', tabUpdateListener);
|
||||
window.addEventListener('aftercustomization', tabUpdateListener);
|
||||
window.addEventListener('TabSelect', this.onLocationChange.bind(this));
|
||||
window.addEventListener('TabBrowserInserted', this.onTabBrowserInserted.bind(this));
|
||||
|
||||
this.updateWorkspacesChangeContextMenu();
|
||||
this.updateWorkspacesChangeContextMenu();
|
||||
})();
|
||||
}
|
||||
|
||||
async selectStartPage() {
|
||||
@@ -1356,9 +1350,7 @@ class nsZenWorkspaces {
|
||||
// Add any new workspace elements here
|
||||
for (const workspace of aWorkspaces) {
|
||||
if (!this.workspaceElement(workspace.uuid)) {
|
||||
this.#createWorkspaceTabsSection(workspace).catch((e) => {
|
||||
console.error('Error creating workspace tabs section:', e);
|
||||
});
|
||||
this.#createWorkspaceTabsSection(workspace);
|
||||
hasChanged = true;
|
||||
}
|
||||
}
|
||||
@@ -2386,7 +2378,7 @@ class nsZenWorkspaces {
|
||||
}
|
||||
}
|
||||
|
||||
async _createWorkspaceData(name, icon, tabs, moveTabs = true, containerTabId = 0) {
|
||||
#createWorkspaceData(name, icon, containerTabId = 0) {
|
||||
let workspace = {
|
||||
uuid: gZenUIManager.generateUuidv4(),
|
||||
icon: icon,
|
||||
@@ -2394,11 +2386,6 @@ class nsZenWorkspaces {
|
||||
theme: nsZenThemePicker.getTheme([]),
|
||||
containerTabId,
|
||||
};
|
||||
if (moveTabs) {
|
||||
this.#prepareNewWorkspace(workspace);
|
||||
await this.#createWorkspaceTabsSection(workspace, tabs);
|
||||
await this._organizeWorkspaceStripLocations(workspace);
|
||||
}
|
||||
return workspace;
|
||||
}
|
||||
|
||||
@@ -2425,13 +2412,12 @@ class nsZenWorkspaces {
|
||||
!child.hasAttribute('zen-empty-tab') &&
|
||||
!child.hasAttribute('zen-essential')
|
||||
);
|
||||
let workspaceData = await this._createWorkspaceData(
|
||||
name,
|
||||
icon,
|
||||
extraTabs,
|
||||
!dontChange,
|
||||
containerTabId
|
||||
);
|
||||
let workspaceData = this.#createWorkspaceData(name, icon, containerTabId);
|
||||
if (!dontChange) {
|
||||
this.#prepareNewWorkspace(workspaceData);
|
||||
this.#createWorkspaceTabsSection(workspaceData, extraTabs);
|
||||
await this._organizeWorkspaceStripLocations(workspaceData);
|
||||
}
|
||||
if (!this.currentWindowIsSyncing) {
|
||||
this._tempWorkspace = workspaceData;
|
||||
} else {
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
&:hover,
|
||||
&[dragged='true']{
|
||||
background-color: var(--toolbarbutton-hover-background);
|
||||
background-color: var(--zen-toolbar-element-bg);
|
||||
}
|
||||
|
||||
& label {
|
||||
@@ -239,7 +239,7 @@
|
||||
|
||||
:root[zen-unsynced-window] & {
|
||||
pointer-events: none;
|
||||
background: color-mix(in srgb, currentColor 20%, transparent);
|
||||
background: var(--zen-toolbar-element-bg);
|
||||
padding: 4px 8px;
|
||||
border-radius: 99px;
|
||||
font-size: 10px;
|
||||
|
||||
Reference in New Issue
Block a user