mirror of
https://github.com/zen-browser/desktop.git
synced 2025-07-08 23:25:30 +02:00
186 lines
6.2 KiB
C++
186 lines
6.2 KiB
C++
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
|
index 14de79b543cf07b04d06ef5a3f94d9aa988ea39a..1dab566aa17efd996f7082c709ab2a3e1e46aca1 100644
|
|
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
|
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
|
@@ -462,11 +462,26 @@
|
|
return duplicateTabs;
|
|
},
|
|
|
|
+ get _numVisiblePinTabs() {
|
|
+ let i = 0;
|
|
+ for (let tab of this.tabs) {
|
|
+ if (!tab.pinned) {
|
|
+ break;
|
|
+ }
|
|
+ if (!tab.hidden) {
|
|
+ i++;
|
|
+ }
|
|
+ }
|
|
+ return i;
|
|
+ },
|
|
+
|
|
get _numPinnedTabs() {
|
|
- for (var i = 0; i < this.tabs.length; i++) {
|
|
- if (!this.tabs[i].pinned) {
|
|
+ let i = 0;
|
|
+ for (let tab of this.tabs) {
|
|
+ if (!tab.pinned) {
|
|
break;
|
|
}
|
|
+ i++;
|
|
}
|
|
return i;
|
|
},
|
|
@@ -1346,6 +1361,7 @@
|
|
if (!this._previewMode) {
|
|
newTab.recordTimeFromUnloadToReload();
|
|
newTab.updateLastAccessed();
|
|
+ newTab.removeAttribute("unread");
|
|
oldTab.updateLastAccessed();
|
|
// if this is the foreground window, update the last-seen timestamps.
|
|
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
|
|
@@ -2270,6 +2286,13 @@
|
|
b.setAttribute("transparent", "true");
|
|
}
|
|
|
|
+ if (this.zenGlanceBrowser) {
|
|
+ b.setAttribute("zen-glance", "true");
|
|
+ gZenGlanceManager.browser.appendChild(b);
|
|
+ this.zenGlanceBrowser = undefined;
|
|
+ return b;
|
|
+ }
|
|
+
|
|
let stack = document.createXULElement("stack");
|
|
stack.className = "browserStack";
|
|
stack.appendChild(b);
|
|
@@ -2431,7 +2454,7 @@
|
|
|
|
let panel = this.getPanel(browser);
|
|
let uniqueId = this._generateUniquePanelID();
|
|
- panel.id = uniqueId;
|
|
+ if (!panel.id?.startsWith("zen-")) panel.id = uniqueId;
|
|
aTab.linkedPanel = uniqueId;
|
|
|
|
// Inject the <browser> into the DOM if necessary.
|
|
@@ -2491,7 +2514,7 @@
|
|
// hasSiblings=false on both the existing browser and the new browser.
|
|
if (this.tabs.length == 2) {
|
|
this.tabs[0].linkedBrowser.browsingContext.hasSiblings = true;
|
|
- this.tabs[1].linkedBrowser.browsingContext.hasSiblings = true;
|
|
+ if (this.tabs[1].linkedBrowser.browsingContext) this.tabs[1].linkedBrowser.browsingContext.hasSiblings = true;
|
|
} else {
|
|
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
|
|
}
|
|
@@ -2711,6 +2734,11 @@
|
|
);
|
|
}
|
|
|
|
+ let hasZenDefaultUserContextId = false;
|
|
+ if (typeof ZenWorkspaces !== "undefined") {
|
|
+ [userContextId, hasZenDefaultUserContextId] = ZenWorkspaces.getContextIdIfNeeded(userContextId, fromExternal, allowInheritPrincipal);
|
|
+ }
|
|
+
|
|
if (!UserInteraction.running("browser.tabs.opening", window)) {
|
|
UserInteraction.start("browser.tabs.opening", "initting", window);
|
|
}
|
|
@@ -2780,6 +2808,9 @@
|
|
noInitialLabel,
|
|
skipBackgroundNotify,
|
|
});
|
|
+ if (hasZenDefaultUserContextId) {
|
|
+ t.setAttribute("zenDefaultUserContextId", "true");
|
|
+ }
|
|
if (insertTab) {
|
|
// insert the tab into the tab container in the correct position
|
|
this._insertTabAtIndex(t, {
|
|
@@ -3291,6 +3322,14 @@
|
|
) {
|
|
tabWasReused = true;
|
|
tab = this.selectedTab;
|
|
+
|
|
+ if (tabData.zenWorkspace) {
|
|
+ tab.setAttribute("zen-workspace-id", tabData.zenWorkspace);
|
|
+ }
|
|
+ if (tabData.zenDefaultUserContextId) {
|
|
+ tab.setAttribute("zenDefaultUserContextId", "true");
|
|
+ }
|
|
+
|
|
if (!tabData.pinned) {
|
|
this.unpinTab(tab);
|
|
} else {
|
|
@@ -3304,6 +3343,9 @@
|
|
restoreTabsLazily && !select && !tabData.pinned;
|
|
|
|
let url = "about:blank";
|
|
+
|
|
+ gZenPinnedTabManager.resetPinnedTabData(tabData);
|
|
+
|
|
if (tabData.entries?.length) {
|
|
let activeIndex = (tabData.index || tabData.entries.length) - 1;
|
|
// Ensure the index is in bounds.
|
|
@@ -3340,6 +3382,12 @@
|
|
preferredRemoteType,
|
|
});
|
|
|
|
+ if (tabData.zenWorkspace) {
|
|
+ tab.setAttribute("zen-workspace-id", tabData.zenWorkspace);
|
|
+ }
|
|
+ if (tabData.zenDefaultUserContextId) {
|
|
+ tab.setAttribute("zenDefaultUserContextId", "true");
|
|
+ }
|
|
if (select) {
|
|
tabToSelect = tab;
|
|
}
|
|
@@ -3374,7 +3422,7 @@
|
|
this.tabContainer._invalidateCachedTabs();
|
|
}
|
|
}
|
|
-
|
|
+ gZenPinnedTabManager.updatePinnedTabForSessionRestore(tabData, tab);
|
|
tab.initialize();
|
|
}
|
|
|
|
@@ -4148,6 +4196,13 @@
|
|
TelemetryStopwatch.start("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
|
|
}
|
|
|
|
+ if (ZenWorkspaces.workspaceEnabled) {
|
|
+ let newTab = ZenWorkspaces.handleTabBeforeClose(aTab);
|
|
+ if (newTab) {
|
|
+ this.selectedTab = newTab;
|
|
+ }
|
|
+ }
|
|
+
|
|
// Handle requests for synchronously removing an already
|
|
// asynchronously closing tab.
|
|
if (!animate && aTab.closing) {
|
|
@@ -5123,10 +5178,10 @@
|
|
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
|
|
},
|
|
|
|
- hideTab(aTab, aSource) {
|
|
+ hideTab(aTab, aSource, forZenWorkspaces = false) {
|
|
if (
|
|
aTab.hidden ||
|
|
- aTab.pinned ||
|
|
+ (aTab.pinned && !forZenWorkspaces) ||
|
|
aTab.selected ||
|
|
aTab.closing ||
|
|
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
|
|
@@ -7042,6 +7097,7 @@
|
|
aWebProgress.isTopLevel
|
|
) {
|
|
this.mTab.setAttribute("busy", "true");
|
|
+ if (!this.mTab.selected) this.mTab.setAttribute("unread", "true");
|
|
gBrowser._tabAttrModified(this.mTab, ["busy"]);
|
|
this.mTab._notselectedsinceload = !this.mTab.selected;
|
|
gBrowser.syncThrobberAnimations(this.mTab);
|
|
@@ -7874,7 +7930,7 @@ var TabContextMenu = {
|
|
);
|
|
contextUnpinSelectedTabs.hidden =
|
|
!this.contextTab.pinned || !multiselectionContext;
|
|
-
|
|
+ gZenPinnedTabManager.updatePinnedTabContextMenu(this.contextTab);
|
|
// Move Tab items
|
|
let contextMoveTabOptions = document.getElementById(
|
|
"context_moveTabOptions"
|