chore: Changed ZenWorkspaces to gZenWorkspaces, b=(no-bug), c=tabs, common, folders, glance, media, tests, welcome, workspaces

This commit is contained in:
Mr. M
2025-05-16 01:17:11 +02:00
parent bac3e38318
commit 22d04ad729
33 changed files with 240 additions and 159 deletions

View File

@@ -1,8 +1,8 @@
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
index 89b8b830e8f53582dd9910b0172098d31a8d8967..51bdc847823cb95f811b7e9d2d864b9aacf0e364 100644
index eda8312b0edd34ed22c94c224167680ac6c9c459..56de47f79c553dab2676e127f5320e352b7d3a77 100644
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -3375,3 +3375,5 @@ pref("toolkit.contentRelevancy.enabled", false);
@@ -3377,3 +3377,5 @@ pref("toolkit.contentRelevancy.enabled", false);
pref("toolkit.contentRelevancy.ingestEnabled", false);
// Pref to enable extra logging for the content relevancy feature
pref("toolkit.contentRelevancy.log", false);

View File

@@ -15,7 +15,7 @@ index 3d5173315812589c0b79beec5f0419fc37cb8868..c4216db9e414fbbaead6ecd89b40366b
TelemetryTimestamps.add("delayedStartupStarted");
this._cancelDelayedStartup();
+ ZenWorkspaces.afterLoadInit();
+ gZenWorkspaces.afterLoadInit();
gBrowser.addEventListener(
"PermissionStateChange",

View File

@@ -1,5 +1,5 @@
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index ea79d296e7dd0f8fd812b0677a252af5cf7ad26e..bd95ef5d6b99399c859af1cf71d9d62477f4ac2b 100644
index ea79d296e7dd0f8fd812b0677a252af5cf7ad26e..08568d90f888cc262a23ffaa72e985e7c3463b93 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -33,6 +33,7 @@ ChromeUtils.defineESModuleGetters(this, {
@@ -15,7 +15,7 @@ index ea79d296e7dd0f8fd812b0677a252af5cf7ad26e..bd95ef5d6b99399c859af1cf71d9d624
TranslationsParent.onLocationChange(gBrowser.selectedBrowser);
+ gZenViewSplitter.onLocationChange(gBrowser.selectedBrowser);
+ ZenWorkspaces.onLocationChange(gBrowser.selectedBrowser);
+ gZenWorkspaces.onLocationChange(gBrowser.selectedBrowser);
+ gZenTabUnloader.onLocationChange(gBrowser.selectedBrowser);
+ gZenPinnedTabManager.onLocationChange(gBrowser.selectedBrowser);
+
@@ -27,7 +27,7 @@ index ea79d296e7dd0f8fd812b0677a252af5cf7ad26e..bd95ef5d6b99399c859af1cf71d9d624
ignoreFragmentWhenComparing
);
- let browsers = aWindow.gBrowser.browsers;
+ let browsers = aWindow.ZenWorkspaces.allUsedBrowsers;
+ let browsers = aWindow.gZenWorkspaces.allUsedBrowsers;
for (let i = 0; i < browsers.length; i++) {
let browser = browsers[i];
let browserCompare = cleanURL(
@@ -36,7 +36,7 @@ index ea79d296e7dd0f8fd812b0677a252af5cf7ad26e..bd95ef5d6b99399c859af1cf71d9d624
if (!doAdopt) {
- aWindow.gBrowser.tabContainer.selectedIndex = i;
+ aWindow.ZenWorkspaces.switchIfNeeded(browser, i);
+ aWindow.gZenWorkspaces.switchIfNeeded(browser, i);
}
return true;

View File

@@ -41,7 +41,7 @@
content/browser/zen-components/ZenWorkspaceIcons.mjs (../../zen/workspaces/ZenWorkspaceIcons.mjs)
content/browser/zen-components/ZenWorkspace.mjs (../../zen/workspaces/ZenWorkspace.mjs)
content/browser/zen-components/ZenWorkspaces.mjs (../../zen/workspaces/ZenWorkspaces.mjs)
content/browser/zen-components/gZenWorkspaces.mjs (../../zen/workspaces/gZenWorkspaces.mjs)
content/browser/zen-components/ZenWorkspacesStorage.mjs (../../zen/workspaces/ZenWorkspacesStorage.mjs)
content/browser/zen-components/ZenWorkspacesSync.mjs (../../zen/workspaces/ZenWorkspacesSync.mjs)
content/browser/zen-components/ZenGradientGenerator.mjs (../../zen/workspaces/ZenGradientGenerator.mjs)

View File

@@ -7,7 +7,7 @@
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenKeyboardShortcuts.mjs", this);
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenWorkspaceIcons.mjs", this);
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenWorkspace.mjs", this);
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenWorkspaces.mjs", this);
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/gZenWorkspaces.mjs", this);
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenWorkspacesSync.mjs", this);
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenActorsManager.mjs", this);
</script>

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/places/content/browserPlacesViews.js b/browser/components/places/content/browserPlacesViews.js
index ad138a38340e8e8510d395f46c30ec4121d731bb..9294f05633acbe560df003333b7ef7d9a12a2a11 100644
index ad138a38340e8e8510d395f46c30ec4121d731bb..52beaa66395e2b240a7122936cd4d2452b386724 100644
--- a/browser/components/places/content/browserPlacesViews.js
+++ b/browser/components/places/content/browserPlacesViews.js
@@ -330,12 +330,23 @@ class PlacesViewBase {
@@ -13,7 +13,7 @@ index ad138a38340e8e8510d395f46c30ec4121d731bb..9294f05633acbe560df003333b7ef7d9
+ let child = resultNode.getChild(i);
+ // Skip nodes that don't belong in current workspace
+ if (PlacesUtils.nodeIsURI(child) || PlacesUtils.containerTypes.includes(child.type)) {
+ if (typeof ZenWorkspaces !== 'undefined' && ZenWorkspaces.isBookmarkInAnotherWorkspace(child)) {
+ if (typeof gZenWorkspaces !== 'undefined' && gZenWorkspaces.isBookmarkInAnotherWorkspace(child)) {
+ continue;
+ }
+ }
@@ -52,7 +52,7 @@ index ad138a38340e8e8510d395f46c30ec4121d731bb..9294f05633acbe560df003333b7ef7d9
+ for (let i = 0; i < cc; i++) {
+ let child = this._resultNode.getChild(i);
+ if (PlacesUtils.nodeIsURI(child) || PlacesUtils.containerTypes.includes(child.type)) {
+ if (!(typeof ZenWorkspaces !== 'undefined' && ZenWorkspaces.isBookmarkInAnotherWorkspace(child))) {
+ if (!(typeof gZenWorkspaces !== 'undefined' && gZenWorkspaces.isBookmarkInAnotherWorkspace(child))) {
+ visibleNodes.push(child);
+ }
+ } else {

View File

@@ -1,8 +1,8 @@
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
index 5633e5032f5d50c70512187d27e045b579978927..6b9e56cb62a4812925ff812763ea9b0e6a478202 100644
index 11794372f8ff13387b54dabdf4111dfdb89ea998..0e51251a579cee759f25272894c82a1744d79b26 100644
--- a/browser/components/sessionstore/SessionStore.sys.mjs
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
@@ -2081,7 +2081,6 @@ var SessionStoreInternal = {
@@ -2088,7 +2088,6 @@ var SessionStoreInternal = {
if (closedWindowState) {
let newWindowState;
if (
@@ -10,7 +10,7 @@ index 5633e5032f5d50c70512187d27e045b579978927..6b9e56cb62a4812925ff812763ea9b0e
!lazy.SessionStartup.willRestore()
) {
// We want to split the window up into pinned tabs and unpinned tabs.
@@ -2296,11 +2295,9 @@ var SessionStoreInternal = {
@@ -2303,11 +2302,9 @@ var SessionStoreInternal = {
tabbrowser.selectedTab.label;
}
@@ -22,7 +22,7 @@ index 5633e5032f5d50c70512187d27e045b579978927..6b9e56cb62a4812925ff812763ea9b0e
// Store the window's close date to figure out when each individual tab
// was closed. This timestamp should allow re-arranging data based on how
@@ -3202,7 +3199,7 @@ var SessionStoreInternal = {
@@ -3209,7 +3206,7 @@ var SessionStoreInternal = {
if (!isPrivateWindow && tabState.isPrivate) {
return;
}
@@ -31,7 +31,7 @@ index 5633e5032f5d50c70512187d27e045b579978927..6b9e56cb62a4812925ff812763ea9b0e
return;
}
@@ -3911,6 +3908,9 @@ var SessionStoreInternal = {
@@ -3918,6 +3915,9 @@ var SessionStoreInternal = {
Math.min(tabState.index, tabState.entries.length)
);
tabState.pinned = false;
@@ -41,7 +41,7 @@ index 5633e5032f5d50c70512187d27e045b579978927..6b9e56cb62a4812925ff812763ea9b0e
if (inBackground === false) {
aWindow.gBrowser.selectedTab = newTab;
@@ -5225,7 +5225,7 @@ var SessionStoreInternal = {
@@ -5232,7 +5232,7 @@ var SessionStoreInternal = {
}
let workspaceID = aWindow.getWorkspaceID();
@@ -50,12 +50,12 @@ index 5633e5032f5d50c70512187d27e045b579978927..6b9e56cb62a4812925ff812763ea9b0e
winData.workspaceID = workspaceID;
}
},
@@ -5416,14 +5416,15 @@ var SessionStoreInternal = {
@@ -5423,14 +5423,15 @@ var SessionStoreInternal = {
}
let tabbrowser = aWindow.gBrowser;
- let tabs = tabbrowser.tabs;
+ let tabs = aWindow.ZenWorkspaces.allStoredTabs;
+ let tabs = aWindow.gZenWorkspaces.allStoredTabs;
/** @type {WindowStateData} */
let winData = this._windows[aWindow.__SSi];
let tabsData = (winData.tabs = []);
@@ -68,7 +68,7 @@ index 5633e5032f5d50c70512187d27e045b579978927..6b9e56cb62a4812925ff812763ea9b0e
continue;
}
let tabData = lazy.TabState.collect(tab, TAB_CUSTOM_VALUES.get(tab));
@@ -5442,7 +5443,7 @@ var SessionStoreInternal = {
@@ -5449,7 +5450,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).
@@ -77,7 +77,7 @@ index 5633e5032f5d50c70512187d27e045b579978927..6b9e56cb62a4812925ff812763ea9b0e
selectedIndex = 1;
winData.title = tabbrowser.tabs[0].label;
}
@@ -5599,6 +5600,7 @@ var SessionStoreInternal = {
@@ -5606,6 +5607,7 @@ var SessionStoreInternal = {
winData.tabs,
winData.groups ?? []
);
@@ -85,7 +85,7 @@ index 5633e5032f5d50c70512187d27e045b579978927..6b9e56cb62a4812925ff812763ea9b0e
this._log.debug(
`restoreWindow, createTabsForSessionRestore returned ${tabs.length} tabs`
);
@@ -6148,8 +6150,23 @@ var SessionStoreInternal = {
@@ -6155,8 +6157,23 @@ var SessionStoreInternal = {
// Most of tabData has been restored, now continue with restoring
// attributes that may trigger external events.

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb6c1a0cf3 100644
index dacf52070348a205a56ef42eb8320602f98e5daa..66c42501899b15e1f250880ebe9e64b2610e08ad 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -415,11 +415,45 @@
@@ -54,7 +54,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
this.tabpanels.appendChild(panel);
let tab = this.tabs[0];
+ ZenWorkspaces.handleInitialTab(tab, (!remoteType || remoteType === E10SUtils.PRIVILEGEDABOUT_REMOTE_TYPE) && !gZenUIManager.testingEnabled);
+ gZenWorkspaces.handleInitialTab(tab, (!remoteType || remoteType === E10SUtils.PRIVILEGEDABOUT_REMOTE_TYPE) && !gZenUIManager.testingEnabled);
tab.linkedPanel = uniqueId;
this._selectedTab = tab;
this._selectedBrowser = browser;
@@ -68,7 +68,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
+ if (this.tabContainer.verticalMode && !handled) {
this.#handleTabMove(aTab, () =>
- this.verticalPinnedTabsContainer.appendChild(aTab)
+ aTab.hasAttribute("zen-essential") ? ZenWorkspaces.getEssentialsSection(aTab).appendChild(aTab) : this.verticalPinnedTabsContainer.insertBefore(aTab, this.verticalPinnedTabsContainer.lastChild)
+ aTab.hasAttribute("zen-essential") ? gZenWorkspaces.getEssentialsSection(aTab).appendChild(aTab) : this.verticalPinnedTabsContainer.insertBefore(aTab, this.verticalPinnedTabsContainer.lastChild)
);
- } else {
+ } else if (!handled) {
@@ -87,7 +87,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
aTab.removeAttribute("pinned");
- this.tabContainer.arrowScrollbox.prepend(aTab);
+ if (!handled) {
+ ZenWorkspaces.activeWorkspaceStrip.prepend(aTab);
+ gZenWorkspaces.activeWorkspaceStrip.prepend(aTab);
+ }
});
} else {
@@ -200,8 +200,8 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
+ let hasZenDefaultUserContextId = false;
+ let zenForcedWorkspaceId = undefined;
+ if (typeof ZenWorkspaces !== "undefined" && !_forZenEmptyTab) {
+ [userContextId, hasZenDefaultUserContextId, zenForcedWorkspaceId] = ZenWorkspaces.getContextIdIfNeeded(userContextId, fromExternal, allowInheritPrincipal);
+ if (typeof gZenWorkspaces !== "undefined" && !_forZenEmptyTab) {
+ [userContextId, hasZenDefaultUserContextId, zenForcedWorkspaceId] = gZenWorkspaces.getContextIdIfNeeded(userContextId, fromExternal, allowInheritPrincipal);
+ }
+
if (!UserInteraction.running("browser.tabs.opening", window)) {
@@ -367,16 +367,16 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
let leftoverTab = this.selectedTab;
- this.selectedTab = tabToSelect;
- this.removeTab(leftoverTab);
+ ZenWorkspaces._tabToRemoveForEmpty = leftoverTab;
+ gZenWorkspaces._tabToRemoveForEmpty = leftoverTab;
+ if (Services.prefs.getBoolPref("zen.workspaces.continue-where-left-off")) {
+ ZenWorkspaces._tabToSelect = selectTab - 1;
+ gZenWorkspaces._tabToSelect = selectTab - 1;
+ }
+ if (ZenWorkspaces._initialTab && !gZenVerticalTabsManager._canReplaceNewTab) {
+ ZenWorkspaces._initialTab._shouldRemove = true;
+ if (gZenWorkspaces._initialTab && !gZenVerticalTabsManager._canReplaceNewTab) {
+ gZenWorkspaces._initialTab._shouldRemove = true;
+ }
+ }
+ else {
+ ZenWorkspaces._tabToRemoveForEmpty = this.selectedTab;
+ gZenWorkspaces._tabToRemoveForEmpty = this.selectedTab;
}
if (tabs.length > 1 || !tabs[0].selected) {
@@ -460,8 +460,8 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
}
+ if (ZenWorkspaces.workspaceEnabled) {
+ let newTab = ZenWorkspaces.handleTabBeforeClose(aTab, closeWindowWithLastTab);
+ if (gZenWorkspaces.workspaceEnabled) {
+ let newTab = gZenWorkspaces.handleTabBeforeClose(aTab, closeWindowWithLastTab);
+ if (newTab) {
+ this.selectedTab = newTab;
+ }
@@ -485,7 +485,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
? closeWindowWithLastTab
: !window.toolbar.visible ||
- Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab");
+ Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab") && !ZenWorkspaces._isClosingWindow && !ZenWorkspaces._removedByStartupPage;
+ Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab") && !gZenWorkspaces._isClosingWindow && !gZenWorkspaces._removedByStartupPage;
if (closeWindow) {
// We've already called beforeunload on all the relevant tabs if we get here,
@@ -493,7 +493,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
newTab = true;
}
+ ZenWorkspaces._removedByStartupPage = false;
+ gZenWorkspaces._removedByStartupPage = false;
aTab._endRemoveArgs = [closeWindow, newTab];
// swapBrowsersAndCloseOther will take care of closing the window without animation.
@@ -504,7 +504,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
- this.addTrustedTab(BROWSER_NEW_TAB_URL, {
- skipAnimation: true,
- });
+ ZenWorkspaces.selectEmptyTab(BROWSER_NEW_TAB_URL);
+ gZenWorkspaces.selectEmptyTab(BROWSER_NEW_TAB_URL);
} else {
TabBarVisibility.update();
}
@@ -512,7 +512,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
this.tabs[i]._tPos = i;
}
+ ZenWorkspaces.updateTabsContainers();
+ gZenWorkspaces.updateTabsContainers();
+
if (!this._windowIsClosing) {
if (wasPinned) {
@@ -532,7 +532,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
}
let excludeTabs = new Set(aExcludeTabs);
+ ZenWorkspaces.getTabsToExclude(aTab).forEach(tab => excludeTabs.add(tab));
+ gZenWorkspaces.getTabsToExclude(aTab).forEach(tab => excludeTabs.add(tab));
// If this tab has a successor, it should be selectable, since
// hiding or closing a tab removes that tab as a successor.
@@ -541,14 +541,14 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
) {
- return aTab.owner;
+ return ZenWorkspaces.findTabToBlur(aTab.owner);
+ return gZenWorkspaces.findTabToBlur(aTab.owner);
}
// Try to find a remaining tab that comes after the given tab
let remainingTabs = Array.prototype.filter.call(
this.visibleTabs,
- tab => !excludeTabs.has(tab)
+ tab => !excludeTabs.has(tab) && ZenWorkspaces._shouldChangeToTab(tab)
+ tab => !excludeTabs.has(tab) && gZenWorkspaces._shouldChangeToTab(tab)
);
let tab = this.tabContainer.findNextTab(aTab, {
@@ -557,7 +557,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
if (tab) {
- return tab;
+ return ZenWorkspaces.findTabToBlur(tab);
+ return gZenWorkspaces.findTabToBlur(tab);
}
// If no qualifying visible tab was found, see if there is a tab in
@@ -566,7 +566,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
}
- return tab;
+ return ZenWorkspaces.findTabToBlur(tab);
+ return gZenWorkspaces.findTabToBlur(tab);
}
_blurTab(aTab) {
@@ -583,7 +583,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
aTab.selected ||
aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -6001,7 +6136,7 @@
@@ -6002,7 +6137,7 @@
// Don't allow mixing pinned and unpinned tabs.
if (this.isTab(element) && element.pinned) {
@@ -592,7 +592,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
} else {
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
}
@@ -6028,9 +6163,16 @@
@@ -6029,9 +6164,16 @@
element,
() => {
let neighbor = this.tabs[tabIndex];
@@ -610,7 +610,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
neighbor.after(element);
} else {
@@ -6099,7 +6241,9 @@
@@ -6100,7 +6242,9 @@
targetElement = targetElement.group;
}
}
@@ -621,7 +621,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
// Don't allow mixing pinned and unpinned tabs.
if (element.pinned && !targetElement?.pinned) {
targetElement = this.tabs[this.pinnedTabCount - 1];
@@ -6109,7 +6253,13 @@
@@ -6110,7 +6254,13 @@
moveBefore = true;
}
@@ -630,12 +630,12 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
+ }
let getContainer = () => {
+ if (element.hasAttribute("zen-essential")) {
+ return ZenWorkspaces.getEssentialsSection(element);
+ return gZenWorkspaces.getEssentialsSection(element);
+ }
if (element.pinned && this.tabContainer.verticalMode) {
return this.tabContainer.verticalPinnedTabsContainer;
}
@@ -6169,7 +6319,7 @@
@@ -6170,7 +6320,7 @@
if (!this.isTab(aTab)) {
throw new Error("Can only move a tab into a tab group");
}
@@ -644,27 +644,27 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
return;
}
if (aTab.group && aTab.group.id === aGroup.id) {
@@ -6263,6 +6413,10 @@
@@ -6264,6 +6414,10 @@
moveActionCallback();
+ ZenWorkspaces._makeSureEmptyTabIsLast();
+ gZenWorkspaces._makeSureEmptyTabIsLast();
+ gZenViewSplitter._maybeRemoveFakeBrowser(false);
+ gZenViewSplitter._canDrop = false;
+
// Clear tabs cache after moving nodes because the order of tabs may have
// changed.
this.tabContainer._invalidateCachedTabs();
@@ -7080,7 +7234,7 @@
@@ -7081,7 +7235,7 @@
// preventDefault(). It will still raise the window if appropriate.
break;
}
- this.selectedTab = tab;
+ ZenWorkspaces.switchTabIfNeeded(tab);
+ gZenWorkspaces.switchTabIfNeeded(tab);
window.focus();
aEvent.preventDefault();
break;
@@ -7981,6 +8135,7 @@
@@ -7982,6 +8136,7 @@
aWebProgress.isTopLevel
) {
this.mTab.setAttribute("busy", "true");
@@ -672,7 +672,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected;
}
@@ -8954,7 +9109,7 @@ var TabContextMenu = {
@@ -8955,7 +9110,7 @@ var TabContextMenu = {
);
contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !this.multiselected;
@@ -681,7 +681,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..e54e815b04c311464ed53364007d99bb
// Move Tab items
let contextMoveTabOptions = document.getElementById(
"context_moveTabOptions"
@@ -9223,6 +9378,7 @@ var TabContextMenu = {
@@ -9224,6 +9379,7 @@ var TabContextMenu = {
telemetrySource: gBrowser.TabMetrics.METRIC_SOURCE.TAB_STRIP,
});
} else {

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..3001dd54fccfcac3b96288dd769fbaa16cb76ffb 100644
index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..97e2a505892a82084ade7d2b1c5b690444f65254 100644
--- a/browser/components/tabbrowser/content/tabs.js
+++ b/browser/components/tabbrowser/content/tabs.js
@@ -83,7 +83,7 @@
@@ -132,7 +132,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..3001dd54fccfcac3b96288dd769fbaa1
get newTabButton() {
- return this.querySelector("#tabs-newtab-button");
+ return ZenWorkspaces.activeWorkspaceStrip.querySelector("#tabs-newtab-button");
+ return gZenWorkspaces.activeWorkspaceStrip.querySelector("#tabs-newtab-button");
}
get verticalMode() {
@@ -141,7 +141,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..3001dd54fccfcac3b96288dd769fbaa1
return this.#allTabs;
}
- let children = Array.from(this.arrowScrollbox.children);
+ let children = ZenWorkspaces.tabboxChildren;
+ let children = gZenWorkspaces.tabboxChildren;
// remove arrowScrollbox periphery element
children.pop();
@@ -156,7 +156,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..3001dd54fccfcac3b96288dd769fbaa1
this.#allTabs = [
- ...this.verticalPinnedTabsContainer.children,
+ ...ZenWorkspaces.getCurrentEssentialsContainer().children, ...this.verticalPinnedTabsContainer.children,
+ ...gZenWorkspaces.getCurrentEssentialsContainer().children, ...this.verticalPinnedTabsContainer.children,
...children,
];
+ const lastPinnedTabIdx = gBrowser.pinnedTabCount;
@@ -182,7 +182,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..3001dd54fccfcac3b96288dd769fbaa1
get allGroups() {
let children = Array.from(this.arrowScrollbox.children);
- return children.filter(node => node.tagName == "tab-group");
+ return ZenWorkspaces.allTabGroups;
+ return gZenWorkspaces.allTabGroups;
}
/**
@@ -207,11 +207,11 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..3001dd54fccfcac3b96288dd769fbaa1
- }
- let children = Array.from(this.arrowScrollbox.children);
+ let verticalPinnedTabsContainer = this.verticalPinnedTabsContainer
+ let children = ZenWorkspaces.tabboxChildrenWithoutEmpty;
+ let children = gZenWorkspaces.tabboxChildrenWithoutEmpty;
let focusableItems = [];
- for (let child of children) {
+ for (let child of [...ZenWorkspaces.getCurrentEssentialsContainer().children, ...verticalPinnedTabsContainer.children, ...children]) {
+ for (let child of [...gZenWorkspaces.getCurrentEssentialsContainer().children, ...verticalPinnedTabsContainer.children, ...children]) {
if (isTab(child) && child.visible) {
child.elementIndex = elementIndex++;
focusableItems.push(child);
@@ -246,7 +246,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..3001dd54fccfcac3b96288dd769fbaa1
_invalidateCachedTabs() {
this.#allTabs = null;
this._invalidateCachedVisibleTabs();
+ ZenWorkspaces._allStoredTabs = null;
+ gZenWorkspaces._allStoredTabs = null;
}
_invalidateCachedVisibleTabs() {
@@ -266,7 +266,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..3001dd54fccfcac3b96288dd769fbaa1
if (node == null) {
// We have a container for non-tab elements at the end of the scrollbox.
- node = this.arrowScrollbox.lastChild;
+ node = ZenWorkspaces.activeWorkspaceStrip.lastChild;
+ node = gZenWorkspaces.activeWorkspaceStrip.lastChild;
}
node.before(tab);
@@ -275,7 +275,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..3001dd54fccfcac3b96288dd769fbaa1
// for when the tab strip is overflowed (which is shared by vertical and horizontal tabs);
// Attach the long click popup to all of them.
- const newTab = document.getElementById("new-tab-button");
+ const newTab = ZenWorkspaces.activeWorkspaceStrip.querySelector("#tabs-newtab-button");
+ const newTab = gZenWorkspaces.activeWorkspaceStrip.querySelector("#tabs-newtab-button");
const newTab2 = this.newTabButton;
const newTabVertical = document.getElementById(
"vertical-tabs-newtab-button"
@@ -304,14 +304,14 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..3001dd54fccfcac3b96288dd769fbaa1
-
- if (gBrowser.pinnedTabCount !== verticalTabsContainer.children.length) {
- let tabs = this.visibleTabs;
+ if (!ZenWorkspaces._hasInitializedTabsStrip) return;
+ let count = ZenWorkspaces.makeSurePinTabIsInCorrectPosition();
+ if (gBrowser.pinnedTabCount !== (verticalTabsContainer.children.length - count - 1 + ZenWorkspaces.getCurrentEssentialsContainer().children.length)) {
+ if (!gZenWorkspaces._hasInitializedTabsStrip) return;
+ let count = gZenWorkspaces.makeSurePinTabIsInCorrectPosition();
+ if (gBrowser.pinnedTabCount !== (verticalTabsContainer.children.length - count - 1 + gZenWorkspaces.getCurrentEssentialsContainer().children.length)) {
+ let tabs = this.allTabs.filter(tab => !tab.hasAttribute("zen-glance-tab"));
for (let i = 0; i < numPinned; i++) {
tabs[i].style.marginInlineStart = "";
- verticalTabsContainer.appendChild(tabs[i]);
+ tabs[i].hasAttribute("zen-essential") ? ZenWorkspaces.getCurrentEssentialsContainer().appendChild(tabs[i].group?.hasAttribute("split-view-group") ? tabs[i].group : tabs[i]) : verticalTabsContainer.insertBefore(tabs[i].group?.hasAttribute("split-view-group") ? tabs[i].group : tabs[i], verticalTabsContainer.lastChild);
+ tabs[i].hasAttribute("zen-essential") ? gZenWorkspaces.getCurrentEssentialsContainer().appendChild(tabs[i].group?.hasAttribute("split-view-group") ? tabs[i].group : tabs[i]) : verticalTabsContainer.insertBefore(tabs[i].group?.hasAttribute("split-view-group") ? tabs[i].group : tabs[i], verticalTabsContainer.lastChild);
}
}

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/urlbar/UrlbarProviderPlaces.sys.mjs b/browser/components/urlbar/UrlbarProviderPlaces.sys.mjs
index b1481a11ef..925f0dc34b 100644
index b1481a11ef38037bec13939928f72f9772e335a9..925f0dc34bf84bb9e0f143f5c1973a87e7b4f8ac 100644
--- a/browser/components/urlbar/UrlbarProviderPlaces.sys.mjs
+++ b/browser/components/urlbar/UrlbarProviderPlaces.sys.mjs
@@ -35,6 +35,8 @@ const QUERYINDEX_SWITCHTAB = 9;

View File

@@ -1,5 +1,5 @@
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
index a8ba391326f811ae80510585a3c6ab8d7579f739..5e4569032d4c62e59065262f7069663f9acadad1 100644
index c4e19fc5231c2378ddb25f462cd1584aa9eac760..eb0cec062abf0c97bf5ca33e85aeacd496c296a8 100644
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -18804,6 +18804,7 @@

View File

@@ -1,5 +1,5 @@
diff --git a/toolkit/components/pictureinpicture/PictureInPicture.sys.mjs b/toolkit/components/pictureinpicture/PictureInPicture.sys.mjs
index 5644bad94bd4741c4c807eaf5633ee18aacd633f..f89a3e24e850df04aebceb1ff70c0bed5a9db7e5 100644
index 5644bad94bd4741c4c807eaf5633ee18aacd633f..f59eb65928f74c8080a0b26394e17a6ef6cc1977 100644
--- a/toolkit/components/pictureinpicture/PictureInPicture.sys.mjs
+++ b/toolkit/components/pictureinpicture/PictureInPicture.sys.mjs
@@ -122,6 +122,9 @@ export class PictureInPictureToggleParent extends JSWindowActorParent {
@@ -17,7 +17,7 @@ index 5644bad94bd4741c4c807eaf5633ee18aacd633f..f89a3e24e850df04aebceb1ff70c0bed
tab.ownerGlobal.focus();
- gBrowser.selectedTab = tab;
+ browser?.ownerGlobal?.ZenWorkspaces.switchIfNeeded(browser);
+ browser?.ownerGlobal?.gZenWorkspaces.switchIfNeeded(browser);
await this.closeSinglePipWindow({ reason: "Unpip", actorRef: pipActor });
},

View File

@@ -1,5 +1,5 @@
diff --git a/toolkit/content/widgets/tabbox.js b/toolkit/content/widgets/tabbox.js
index 6775a7635c6cdbb276b3a912d0bba07840acb28f..fc5d3b1fab286c657c27b98d56bb616dfab3caef 100644
index 6775a7635c6cdbb276b3a912d0bba07840acb28f..4ef3eb6a7dbd741cf432668c2ff6e832f5bb97e7 100644
--- a/toolkit/content/widgets/tabbox.js
+++ b/toolkit/content/widgets/tabbox.js
@@ -213,7 +213,7 @@
@@ -16,7 +16,7 @@ index 6775a7635c6cdbb276b3a912d0bba07840acb28f..fc5d3b1fab286c657c27b98d56bb616d
return;
}
- for (let otherTab of this.allTabs) {
+ for (let otherTab of window.ZenWorkspaces?.allStoredTabs ?? this.allTabs) {
+ for (let otherTab of window.gZenWorkspaces?.allStoredTabs ?? this.allTabs) {
if (otherTab != tab && otherTab.selected) {
otherTab._selected = false;
}

View File

@@ -35,7 +35,7 @@ index 849b62c9976a7bc5fee35e074e54c8f556ed9c38..a9742c7ff30d417a18f41f9c12025919
}
}
@@ -78,6 +95,7 @@ - (NSView*)hitTest:(NSPoint)aPoint {
@@ -78,6 +95,7 @@ static NSVisualEffectBlendingMode VisualEffectBlendingModeForVibrancyType(
- (void)prefChanged {
self.blendingMode = VisualEffectBlendingModeForVibrancyType(mType);

View File

@@ -31,7 +31,7 @@
this._initSidebarScrolling();
this._hideUnusedElements();
ZenWorkspaces.init();
gZenWorkspaces.init();
gZenVerticalTabsManager.init();
gZenUIManager.init();
@@ -61,7 +61,7 @@
},
delayedStartupFinished() {
ZenWorkspaces.promiseInitialized.then(async () => {
gZenWorkspaces.promiseInitialized.then(async () => {
await delayedStartupPromise;
await SessionStore.promiseAllWindowsRestored;
setTimeout(() => {

View File

@@ -74,7 +74,7 @@ var gZenUIManager = {
setTimeout(gURLBar.formatValue.bind(gURLBar), 350);
if (!this._preventToolbarRebuild) {
setTimeout(() => {
ZenWorkspaces.updateTabsContainers();
gZenWorkspaces.updateTabsContainers();
}, 0);
}
delete this._preventToolbarRebuild;
@@ -779,7 +779,7 @@ var gZenVerticalTabsManager = {
// on purpose, we set the orient to horizontal, because the arrowScrollbox is vertical
gBrowser.tabContainer.arrowScrollbox.scrollbox.setAttribute(
'orient',
isVerticalTabs && ZenWorkspaces.workspaceEnabled ? 'horizontal' : 'vertical'
isVerticalTabs && gZenWorkspaces.workspaceEnabled ? 'horizontal' : 'vertical'
);
const buttonsTarget = document.getElementById('zen-sidebar-top-buttons-customization-target');

View File

@@ -30,10 +30,10 @@ document.addEventListener(
gZenCompactModeManager.toggleToolbar();
break;
case 'cmd_zenWorkspaceForward':
ZenWorkspaces.changeWorkspaceShortcut();
gZenWorkspaces.changeWorkspaceShortcut();
break;
case 'cmd_zenWorkspaceBackward':
ZenWorkspaces.changeWorkspaceShortcut(-1);
gZenWorkspaces.changeWorkspaceShortcut(-1);
break;
case 'cmd_zenSplitViewGrid':
gZenViewSplitter.toggleShortcut('grid');
@@ -69,7 +69,7 @@ document.addEventListener(
gZenThemePicker.openThemePicker(event);
break;
case 'cmd_zenChangeWorkspaceTab':
ZenWorkspaces.changeTabWorkspace(
gZenWorkspaces.changeTabWorkspace(
event.sourceEvent.target.getAttribute('zen-workspace-id')
);
break;
@@ -100,7 +100,7 @@ document.addEventListener(
default:
if (event.target.id.startsWith('cmd_zenWorkspaceSwitch')) {
const index = parseInt(event.target.id.replace('cmd_zenWorkspaceSwitch', ''), 10) - 1;
ZenWorkspaces.shortcutSwitchTo(index);
gZenWorkspaces.shortcutSwitchTo(index);
}
break;
}

View File

@@ -111,7 +111,7 @@
gBrowser.unpinTab(otherTab);
}
this._piningFolder = false;
ZenWorkspaces.activeWorkspaceStrip.prepend(group);
gZenWorkspaces.activeWorkspaceStrip.prepend(group);
gBrowser.tabContainer._invalidateCachedTabs();
return true;
}

View File

@@ -609,7 +609,7 @@
}
finishOpeningGlance() {
ZenWorkspaces.updateTabsContainers();
gZenWorkspaces.updateTabsContainers();
this.browserWrapper.removeAttribute('animate-full');
this.overlay.classList.remove('zen-glance-overlay');
this._clearContainerStyles(this.browserWrapper);

View File

@@ -604,7 +604,7 @@
if (this._currentMediaController) this._currentMediaController.focus();
else if (this._currentBrowser) {
const tab = window.gBrowser.getTabForBrowser(this._currentBrowser);
if (tab) window.ZenWorkspaces.switchTabIfNeeded(tab);
if (tab) window.gZenWorkspaces.switchTabIfNeeded(tab);
}
}

View File

@@ -62,10 +62,10 @@
this.observer.addPinnedTabListener(this._onPinnedTabEvent.bind(this));
this._zenClickEventListener = this._onTabClick.bind(this);
ZenWorkspaces.addChangeListeners(this.onWorkspaceChange.bind(this));
gZenWorkspaces.addChangeListeners(this.onWorkspaceChange.bind(this));
await ZenPinnedTabsStorage.promiseInitialized;
ZenWorkspaces._resolvePinnedInitialized();
gZenWorkspaces._resolvePinnedInitialized();
}
async onWorkspaceChange(newWorkspace, onInit) {
@@ -90,14 +90,18 @@
if (!iconUrl) {
try {
setTimeout(() => {
PlacesUtils.favicons.getFaviconURLForPage(
tab.linkedBrowser.currentURI,
(url) => {
if (url) gBrowser.setIcon(tab, url.spec);
},
try {
PlacesUtils.favicons.getFaviconURLForPage(
tab.linkedBrowser?.currentURI,
(url) => {
if (url) gBrowser.setIcon(tab, url.spec);
},
0
);
0
);
} catch (error) {
console.warn('Error getting favicon URL:', error);
}
});
} catch {}
} else {
@@ -151,7 +155,7 @@
}
async _refreshPinnedTabs({ init = false } = {}) {
await ZenWorkspaces.promiseSectionsInitialized;
await gZenWorkspaces.promiseSectionsInitialized;
await this._initializePinsCache();
await this._initializePinnedTabs(init);
}
@@ -204,7 +208,7 @@
const pinsToCreate = new Set(pins.map((p) => p.uuid));
// First pass: identify existing tabs and remove those without pins
for (let tab of ZenWorkspaces.allStoredTabs) {
for (let tab of gZenWorkspaces.allStoredTabs) {
const pinId = tab.getAttribute('zen-pin-id');
if (!pinId) {
continue;
@@ -304,14 +308,14 @@
this.log(`Created new pinned tab for pin ${pin.uuid} (isEssential: ${pin.isEssential})`);
gBrowser.pinTab(newTab);
if (!pin.isEssential) {
const container = ZenWorkspaces.workspaceElement(
const container = gZenWorkspaces.workspaceElement(
pin.workspaceUuid
)?.pinnedTabsContainer;
if (container) {
container.insertBefore(newTab, container.lastChild);
}
} else {
ZenWorkspaces.getEssentialsSection(pin.containerTabId).appendChild(newTab);
gZenWorkspaces.getEssentialsSection(pin.containerTabId).appendChild(newTab);
}
gBrowser.tabContainer._invalidateCachedTabs();
newTab.initialize();
@@ -501,8 +505,8 @@
tab.removeAttribute('zen-pin-id');
tab.removeAttribute('zen-essential'); // Just in case
if (!tab.hasAttribute('zen-workspace-id') && ZenWorkspaces.workspaceEnabled) {
const workspace = await ZenWorkspaces.getActiveWorkspace();
if (!tab.hasAttribute('zen-workspace-id') && gZenWorkspaces.workspaceEnabled) {
const workspace = await gZenWorkspaces.getActiveWorkspace();
tab.setAttribute('zen-workspace-id', workspace.uuid);
}
}
@@ -591,7 +595,7 @@
let nextTab = findNextTab(1) || findNextTab(-1);
if (!nextTab) {
ZenWorkspaces.selectEmptyTab();
gZenWorkspaces.selectEmptyTab();
return;
}
@@ -669,7 +673,7 @@
: [TabContextMenu.contextTab];
for (let i = 0; i < tabs.length; i++) {
let tab = tabs[i];
const section = ZenWorkspaces.getEssentialsSection(tab);
const section = gZenWorkspaces.getEssentialsSection(tab);
if (section.children.length >= this.MAX_ESSENTIALS_TABS) {
continue;
}
@@ -700,7 +704,7 @@
}
tab.setAttribute('zenDefaultUserContextId', true);
if (tab.selected) {
ZenWorkspaces.switchTabIfNeeded(tab);
gZenWorkspaces.switchTabIfNeeded(tab);
}
this._onTabMove(tab);
this.onTabIconChanged(tab);
@@ -723,13 +727,13 @@
for (let i = 0; i < tabs.length; i++) {
const tab = tabs[i];
tab.removeAttribute('zen-essential');
if (ZenWorkspaces.workspaceEnabled && ZenWorkspaces.getActiveWorkspaceFromCache().uuid) {
tab.setAttribute('zen-workspace-id', ZenWorkspaces.getActiveWorkspaceFromCache().uuid);
if (gZenWorkspaces.workspaceEnabled && gZenWorkspaces.getActiveWorkspaceFromCache().uuid) {
tab.setAttribute('zen-workspace-id', gZenWorkspaces.getActiveWorkspaceFromCache().uuid);
}
if (unpin) {
gBrowser.unpinTab(tab);
} else {
const pinContainer = ZenWorkspaces.pinnedTabsContainer;
const pinContainer = gZenWorkspaces.pinnedTabsContainer;
pinContainer.prepend(tab);
gBrowser.tabContainer._invalidateCachedTabs();
this._onTabMove(tab);
@@ -947,7 +951,7 @@
}
this.dragIndicator.remove();
this._dragIndicator = null;
ZenWorkspaces.activeWorkspaceIndicator?.removeAttribute('open');
gZenWorkspaces.activeWorkspaceIndicator?.removeAttribute('open');
}
get dragIndicator() {
@@ -1010,9 +1014,9 @@
: draggedTab;
if (event.target.closest('.zen-current-workspace-indicator')) {
this.removeTabContainersDragoverClass();
ZenWorkspaces.activeWorkspaceIndicator?.setAttribute('open', true);
gZenWorkspaces.activeWorkspaceIndicator?.setAttribute('open', true);
} else {
ZenWorkspaces.activeWorkspaceIndicator?.removeAttribute('open');
gZenWorkspaces.activeWorkspaceIndicator?.removeAttribute('open');
}
// If there's no valid target tab, nothing to do

View File

@@ -94,7 +94,7 @@
return;
}
const currentTimestamp = Date.now();
const tabs = ZenWorkspaces.allStoredTabs;
const tabs = gZenWorkspaces.allStoredTabs;
for (let i = 0; i < tabs.length; i++) {
const tab = tabs[i];
if (this.unloader.canUnloadTab(tab, currentTimestamp)) {

View File

@@ -1,4 +1,5 @@
[DEFAULT]
prefs = ["zen.workspaces.container-specific-essentials-enabled=true"]
["browser_container_specific_essentials.js"]
["browser_container_auto_switch.js"]
["browser_container_specific_essentials.js"]

View File

@@ -0,0 +1,37 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
add_task(async function test_Container_Essentials_Auto_Swithc() {
await ZenWorkspaces.createAndSaveWorkspace('Container Profile 1', undefined, false, 1);
const workspaces = await ZenWorkspaces._workspaces();
ok(workspaces.workspaces.length === 2, 'Two workspaces should exist.');
let newTab = BrowserTestUtils.addTab(gBrowser, 'about:blank', {
skipAnimation: true,
userContextId: 1,
});
ok(newTab, 'New tab should be opened.');
gZenPinnedTabManager.addToEssentials(newTab);
ok(
newTab.hasAttribute('zen-essential') && newTab.parentNode.getAttribute('container') == '1',
'New tab should be marked as essential.'
);
ok(
gBrowser.tabs.find(
(t) => t.hasAttribute('zen-essential') && t.getAttribute('usercontextid') == 1
),
'New tab should be marked as essential.'
);
const newWorkspaceUUID = ZenWorkspaces.activeWorkspace;
Assert.equal(
ZenWorkspaces.activeWorkspace,
workspaces.workspaces[1].uuid,
'The new workspace should be active.'
);
// Change to the original workspace, there should be no essential tabs
await ZenWorkspaces.changeWorkspace(workspaces.workspaces[0]);
await ZenWorkspaces.removeWorkspace(newWorkspaceUUID);
});

View File

@@ -8,6 +8,7 @@ add_task(async function test_Check_Creation() {
const workspaces = await ZenWorkspaces._workspaces();
ok(workspaces.workspaces.length === 2, 'Two workspaces should exist.');
await ZenWorkspaces.changeWorkspace(workspaces.workspaces[1]);
let newTab = BrowserTestUtils.addTab(gBrowser, 'about:blank', {
skipAnimation: true,
userContextId: 1,

View File

@@ -4,5 +4,6 @@
["browser_pinned_removed.js"]
["browser_pinned_reorder_changed_label.js"]
["browser_pinned_reordered.js"]
["browser_pinned_to_essential.js"]
["browser_issue_7654.js"]

View File

@@ -0,0 +1,37 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
add_task(async function test_Pinned_To_Essential() {
let resolvePromise;
const promise = new Promise((resolve) => {
resolvePromise = resolve;
});
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
const newTab = gBrowser.selectedTab;
newTab.addEventListener(
'ZenPinnedTabCreated',
async function (event) {
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
const pinTabID = newTab.getAttribute('zen-pin-id');
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
gZenPinnedTabManager.addToEssentials(newTab);
ok(
newTab.hasAttribute('zen-essential') && newTab.parentNode.getAttribute('container') == '1',
'New tab should be marked as essential.'
);
resolvePromise();
},
{ once: true }
);
gBrowser.pinTab(newTab);
await promise;
await BrowserTestUtils.removeTab(newTab);
});

View File

@@ -257,7 +257,7 @@
async finish() {
_iconToData = undefined; // Unload icon data
ZenWorkspaces.reorganizeTabsAfterWelcome();
gZenWorkspaces.reorganizeTabsAfterWelcome();
await animate('#zen-welcome-page-content', { x: [0, '100%'] }, { bounce: 0 });
document.getElementById('zen-welcome-page-content').remove();
await this.animHeart();

View File

@@ -18,7 +18,7 @@
super();
if (
!Services.prefs.getBoolPref('zen.theme.gradient', true) ||
!ZenWorkspaces.shouldHaveWorkspaces
!gZenWorkspaces.shouldHaveWorkspaces
) {
return;
}
@@ -66,7 +66,7 @@
}
async onDarkModeChange(event, skipUpdate = false) {
const currentWorkspace = await ZenWorkspaces.getActiveWorkspace();
const currentWorkspace = await gZenWorkspaces.getActiveWorkspace();
this.onWorkspaceChange(currentWorkspace, skipUpdate);
}
@@ -1105,7 +1105,7 @@
return;
}
// Do not rebuild if the workspace is not the same as the current one
const windowWorkspace = await browser.ZenWorkspaces.getActiveWorkspace();
const windowWorkspace = await browser.gZenWorkspaces.getActiveWorkspace();
if (windowWorkspace.uuid !== uuid && theme !== null) {
return;
}
@@ -1374,13 +1374,13 @@
this.currentRotation,
this.currentTexture
);
let currentWorkspace = await ZenWorkspaces.getActiveWorkspace();
let currentWorkspace = await gZenWorkspaces.getActiveWorkspace();
if (!skipSave) {
await ZenWorkspacesStorage.saveWorkspaceTheme(currentWorkspace.uuid, gradient);
await ZenWorkspaces._propagateWorkspaceData();
await gZenWorkspaces._propagateWorkspaceData();
gZenUIManager.showToast('zen-panel-ui-gradient-generator-saved-message');
currentWorkspace = await ZenWorkspaces.getActiveWorkspace();
currentWorkspace = await gZenWorkspaces.getActiveWorkspace();
}
await this.onWorkspaceChange(currentWorkspace, true, skipSave ? gradient : null);

View File

@@ -17,9 +17,9 @@
button.setAttribute('class', 'subviewbutton');
button.setAttribute('tooltiptext', workspace.name);
button.setAttribute('zen-workspace-id', workspace.uuid);
const icon = document.createXULElement('div');
const icon = document.createXULElement('label');
icon.setAttribute('class', 'zen-workspace-icon');
if (ZenWorkspaces.workspaceHasIcon(workspace)) {
if (gZenWorkspaces.workspaceHasIcon(workspace)) {
icon.textContent = workspace.icon;
} else {
icon.setAttribute('no-icon', true);
@@ -30,7 +30,7 @@
}
async #updateIcons() {
const workspaces = await ZenWorkspaces._workspaces();
const workspaces = await gZenWorkspaces._workspaces();
this.innerHTML = '';
for (const workspace of workspaces.workspaces) {
const button = this.#createWorkspaceIcon(workspace);
@@ -47,7 +47,7 @@
const button = event.target;
const uuid = button.getAttribute('zen-workspace-id');
if (uuid) {
ZenWorkspaces.changeWorkspaceWithID(uuid);
gZenWorkspaces.changeWorkspaceWithID(uuid);
}
}

View File

@@ -2,7 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
/**
* Stores workspace IDs and their last selected tabs.
*/
@@ -68,8 +68,8 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
if (!this.shouldHaveWorkspaces) {
this._resolveInitialized();
console.warn('ZenWorkspaces: !!! ZenWorkspaces is disabled in hidden windows !!!');
return; // We are in a hidden window, don't initialize ZenWorkspaces
console.warn('gZenWorkspaces: !!! gZenWorkspaces is disabled in hidden windows !!!');
return; // We are in a hidden window, don't initialize gZenWorkspaces
}
this.ownerWindow = window;
@@ -121,7 +121,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
log(...args) {
if (this.#canDebug) {
console.debug(`[ZenWorkspaces]:`, ...args);
console.debug(`[gZenWorkspaces]:`, ...args);
}
}
@@ -131,7 +131,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
await this.delayedStartup();
}
await this.promiseSectionsInitialized;
this.log('ZenWorkspaces initialized');
this.log('gZenWorkspaces initialized');
await this.initializeWorkspaces();
if (
@@ -815,7 +815,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
gBrowser.tabContainer._positionPinnedTabs();
}
} catch (e) {
console.error('ZenWorkspaces: Error initializing theme picker', e);
console.error('gZenWorkspaces: Error initializing theme picker', e);
}
this.onWindowResize();
await this._selectStartPage();
@@ -945,7 +945,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this.openWorkspacesDialog(event);
};
indicator.addEventListener('contextmenu', th);
indicator.addEventListener('command', th);
indicator.addEventListener('click', th);
}
shouldCloseWindow() {
@@ -1366,7 +1366,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
await this.foreachWindowAsActive(async (browser) => {
// Do not update the window if workspaces are not enabled in it.
// For example, when the window is in private browsing mode.
if (!browser.ZenWorkspaces.workspaceEnabled) {
if (!browser.gZenWorkspaces.workspaceEnabled) {
return;
}
@@ -1385,7 +1385,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
(container) => container.userContextId === workspace.containerTabId
);
} catch (e) {
console.warn('ZenWorkspaces: Error setting container color', e);
console.warn('gZenWorkspaces: Error setting container color', e);
}
if (containerGroup) {
element.classList.add('identity-color-' + containerGroup.color);
@@ -1415,7 +1415,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
} else {
event.preventDefault();
}
}.bind(browser.ZenWorkspaces)
}.bind(browser.gZenWorkspaces)
);
element.addEventListener(
@@ -1434,7 +1434,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
}
}
}
}.bind(browser.ZenWorkspaces)
}.bind(browser.gZenWorkspaces)
);
element.addEventListener('dragenter', function (event) {
@@ -1463,7 +1463,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this.draggedElement = null;
}
}
}.bind(browser.ZenWorkspaces)
}.bind(browser.gZenWorkspaces)
);
element.addEventListener(
@@ -1477,7 +1477,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
for (const elem of workspaceElements) {
elem.classList.remove('dragover');
}
}.bind(browser.ZenWorkspaces)
}.bind(browser.gZenWorkspaces)
);
let childs = browser.MozXULElement.parseXULToFragment(`
@@ -1497,7 +1497,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
// use text content instead of innerHTML to avoid XSS
childs.querySelector('.zen-workspace-icon').textContent =
browser.ZenWorkspaces.getWorkspaceIcon(workspace);
browser.gZenWorkspaces.getWorkspaceIcon(workspace);
childs.querySelector('.zen-workspace-name').textContent = workspace.name;
if (containerGroup) {
childs.querySelector('.zen-workspace-container').textContent =
@@ -1513,7 +1513,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
.getAttribute('zen-workspace-id');
const popup = button.ownerDocument.getElementById('zenWorkspaceActionsMenu');
popup.openPopup(button, 'after_end');
}).bind(browser.ZenWorkspaces)
}).bind(browser.gZenWorkspaces)
);
element.appendChild(childs);
element.onclick = (async () => {
@@ -1529,7 +1529,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
await this.changeWorkspace(workspace);
let panel = this.ownerWindow.document.getElementById('PanelUI-zen-workspaces');
PanelMultiView.hidePopup(panel);
}).bind(browser.ZenWorkspaces);
}).bind(browser.gZenWorkspaces);
return element;
};
@@ -1549,7 +1549,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
element.classList.add('dragover');
}
}
}.bind(browser.ZenWorkspaces)
}.bind(browser.gZenWorkspaces)
);
element.addEventListener(
@@ -1558,14 +1558,14 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
if (this.isReorderModeOn(browser) && this.draggedElement) {
element.classList.add('dragover');
}
}.bind(browser.ZenWorkspaces)
}.bind(browser.gZenWorkspaces)
);
element.addEventListener(
'dragleave',
function (event) {
element.classList.remove('dragover');
}.bind(browser.ZenWorkspaces)
}.bind(browser.gZenWorkspaces)
);
element.addEventListener(
@@ -1583,24 +1583,24 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this.draggedElement = null;
}
}
}.bind(browser.ZenWorkspaces)
}.bind(browser.gZenWorkspaces)
);
return element;
};
if (clearCache) {
browser.ZenWorkspaces._workspaceCache = null;
browser.ZenWorkspaces._workspaceBookmarksCache = null;
browser.gZenWorkspaces._workspaceCache = null;
browser.gZenWorkspaces._workspaceBookmarksCache = null;
}
let workspaces = await browser.ZenWorkspaces._workspaces();
let workspaces = await browser.gZenWorkspaces._workspaces();
browser.dispatchEvent(
new CustomEvent('ZenWorkspacesUIUpdate', {
bubbles: true,
detail: { workspaces, activeIndex: browser.ZenWorkspaces.activeWorkspace },
detail: { workspaces, activeIndex: browser.gZenWorkspaces.activeWorkspace },
})
);
await browser.ZenWorkspaces.workspaceBookmarks();
await browser.gZenWorkspaces.workspaceBookmarks();
workspaceList.innerHTML = '';
workspaceList.parentNode.style.display = 'flex';
if (workspaces.workspaces.length <= 0) {
@@ -1618,7 +1618,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
workspaceList.appendChild(createLastPositionDropTarget());
if (!ignoreStrip) {
browser.ZenWorkspaces._fixIndicatorsNames(workspaces);
browser.gZenWorkspaces._fixIndicatorsNames(workspaces);
}
});
}
@@ -1691,8 +1691,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
if (!this.workspaceEnabled) {
return;
}
let target =
event.target.closest('.zen-current-workspace-indicator');
let target = event.target.closest('.zen-current-workspace-indicator');
let panel = document.getElementById('PanelUI-zen-workspaces');
await this._propagateWorkspaceData({
ignoreStrip: true,
@@ -1864,7 +1863,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this.log('Changing workspace to', workspace?.uuid);
await this._performWorkspaceChange(workspace, ...args);
} catch (e) {
console.error('ZenWorkspaces: Error changing workspace', e);
console.error('gZenWorkspaces: Error changing workspace', e);
}
this._inChangingWorkspace = false;
}
@@ -2409,9 +2408,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
previousWorkspace,
onInit,
});
this.workspaceIcons.activeIndex = workspace.uuid;
await this._organizeWorkspaceStripLocations(workspace, true);
gZenUIManager.tabsWrapper.style.scrollbarWidth = '';
this.workspaceIcons.activeIndex = workspace.uuid;
// Notify listeners
if (this._changeListeners?.length) {

View File

@@ -11,7 +11,7 @@ var ZenWorkspacesStorage = {
Weave: 'resource://services-sync/main.sys.mjs',
});
if (!window.ZenWorkspaces) return;
if (!window.gZenWorkspaces) return;
await this._ensureTable();
await ZenWorkspaceBookmarksStorage.init();
},
@@ -77,7 +77,7 @@ var ZenWorkspacesStorage = {
await ZenWorkspacesStorage.migrateWorkspacesFromJSON();
}
ZenWorkspaces._resolveDBInitialized();
gZenWorkspaces._resolveDBInitialized();
}
);
},

View File

@@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
@namespace html 'http://www.w3.org/1999/xhtml';
@namespace xul 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
#zen-workspaces-button {
justify-content: center;