mirror of
https://github.com/zen-browser/desktop.git
synced 2025-09-05 19:08:18 +00:00
771 lines
27 KiB
C++
771 lines
27 KiB
C++
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
|
index d80a66a01002e78a9c65545d08fe786328ddf124..a25073f3a700e4d6765a9ba92eddbc0bf4bfa444 100644
|
|
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
|
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
|
@@ -422,15 +422,60 @@
|
|
return this.tabContainer.visibleTabs;
|
|
}
|
|
|
|
+ get _numVisiblePinTabsWithoutCollapsed() {
|
|
+ let i = 0;
|
|
+ for (let item of this.tabContainer.ariaFocusableItems) {
|
|
+ if (this.isTabGroupLabel(item) && item.group?.pinned) {
|
|
+ i += 1;
|
|
+ continue;
|
|
+ }
|
|
+ if (!item.pinned && !item.hasAttribute("zen-glance-tab")) {
|
|
+ break;
|
|
+ }
|
|
+ if (item.visible) {
|
|
+ i += !item.hasAttribute("zen-glance-tab");
|
|
+ }
|
|
+ }
|
|
+ return i;
|
|
+ }
|
|
+
|
|
+ ungroupTabsUntilNoActive(tab) {
|
|
+ if (!tab || !tab.group) return;
|
|
+ const activeGroups = tab.group.activeGroups;
|
|
+ if (activeGroups?.length) {
|
|
+ const lastActiveGroup = activeGroups[activeGroups.length - 1];
|
|
+ this.#handleTabMove(tab, () => {
|
|
+ lastActiveGroup.after(tab);
|
|
+ });
|
|
+ }
|
|
+ }
|
|
+
|
|
+ get _numZenEssentials() {
|
|
+ let i = 0;
|
|
+ for (let tab of this.tabs) {
|
|
+ if (!tab.hasAttribute("zen-essential") && !tab.hasAttribute("zen-glance-tab")) {
|
|
+ break;
|
|
+ }
|
|
+ i += !tab.hasAttribute("zen-glance-tab");
|
|
+ }
|
|
+ return i;
|
|
+ }
|
|
+
|
|
get pinnedTabCount() {
|
|
- 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 && !tab.hasAttribute("zen-glance-tab")) {
|
|
break;
|
|
}
|
|
+ i += !tab.hasAttribute("zen-glance-tab");
|
|
}
|
|
return i;
|
|
}
|
|
|
|
+ get tabsWithoutGlance() {
|
|
+ return this.tabs.filter(tab => !tab.hasAttribute("zen-glance-tab"));
|
|
+ }
|
|
+
|
|
set selectedTab(val) {
|
|
if (
|
|
gSharedTabWarning.willShowSharedTabWarning(val) ||
|
|
@@ -578,6 +623,7 @@
|
|
this.tabpanels.appendChild(panel);
|
|
|
|
let tab = this.tabs[0];
|
|
+ gZenWorkspaces.handleInitialTab(tab, (!remoteType || remoteType === E10SUtils.PRIVILEGEDABOUT_REMOTE_TYPE) && !gZenUIManager.testingEnabled);
|
|
tab.linkedPanel = uniqueId;
|
|
this._selectedTab = tab;
|
|
this._selectedBrowser = browser;
|
|
@@ -863,9 +909,13 @@
|
|
}
|
|
|
|
this.showTab(aTab);
|
|
+ const handled = gZenFolders.handleTabPin(aTab);
|
|
+ if (!handled) {
|
|
+ this.ungroupTab(aTab);
|
|
this.#handleTabMove(aTab, () =>
|
|
- this.pinnedTabsContainer.appendChild(aTab)
|
|
+ aTab.hasAttribute("zen-essential") ? gZenWorkspaces.getEssentialsSection(aTab).appendChild(aTab) : this.pinnedTabsContainer.insertBefore(aTab, this.pinnedTabsContainer.lastChild)
|
|
);
|
|
+ }
|
|
|
|
aTab.setAttribute("pinned", "true");
|
|
this._updateTabBarForPinnedTabs();
|
|
@@ -878,11 +928,15 @@
|
|
}
|
|
|
|
this.#handleTabMove(aTab, () => {
|
|
+ const handled = gZenFolders.handleTabUnpin(aTab);
|
|
+
|
|
// we remove this attribute first, so that allTabs represents
|
|
// the moving of a tab from the pinned tabs container
|
|
// and back into arrowscrollbox.
|
|
aTab.removeAttribute("pinned");
|
|
- this.tabContainer.arrowScrollbox.prepend(aTab);
|
|
+ if (!handled) {
|
|
+ gZenWorkspaces.activeWorkspaceStrip.prepend(aTab);
|
|
+ }
|
|
});
|
|
|
|
aTab.style.marginInlineStart = "";
|
|
@@ -1060,6 +1114,8 @@
|
|
|
|
let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"];
|
|
|
|
+ try {
|
|
+ gZenPinnedTabManager.onTabIconChanged(aTab, aIconURL);
|
|
if (
|
|
aIconURL &&
|
|
!aLoadingPrincipal &&
|
|
@@ -1070,6 +1126,9 @@
|
|
);
|
|
return;
|
|
}
|
|
+ } catch (e) {
|
|
+ console.warn(e);
|
|
+ }
|
|
|
|
let browser = this.getBrowserForTab(aTab);
|
|
browser.mIconURL = aIconURL;
|
|
@@ -1319,6 +1378,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()) {
|
|
@@ -1471,6 +1531,9 @@
|
|
}
|
|
|
|
let activeEl = document.activeElement;
|
|
+ if (gURLBar._zenHandleUrlbarClose) {
|
|
+ gURLBar._zenHandleUrlbarClose(true);
|
|
+ }
|
|
// If focus is on the old tab, move it to the new tab.
|
|
if (activeEl == oldTab) {
|
|
newTab.focus();
|
|
@@ -1794,7 +1857,8 @@
|
|
}
|
|
|
|
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
|
|
- if (!aLabel || aLabel.includes("about:reader?")) {
|
|
+ gZenPinnedTabManager.onTabLabelChanged(aTab);
|
|
+ if (!aLabel || aLabel.includes("about:reader?") || aTab.hasAttribute("zen-has-static-label")) {
|
|
return false;
|
|
}
|
|
|
|
@@ -1902,7 +1966,7 @@
|
|
newIndex = this.selectedTab._tPos + 1;
|
|
}
|
|
|
|
- if (replace) {
|
|
+ if (replace && !(!targetTab && this.selectedTab?.hasAttribute('zen-empty-tab'))) {
|
|
if (this.isTabGroupLabel(targetTab)) {
|
|
throw new Error(
|
|
"Replacing a tab group label with a tab is not supported"
|
|
@@ -2166,6 +2230,7 @@
|
|
uriIsAboutBlank,
|
|
userContextId,
|
|
skipLoad,
|
|
+ _forZenEmptyTab,
|
|
} = {}) {
|
|
let b = document.createXULElement("browser");
|
|
// Use the JSM global to create the permanentKey, so that if the
|
|
@@ -2239,8 +2304,7 @@
|
|
// we use a different attribute name for this?
|
|
b.setAttribute("name", name);
|
|
}
|
|
-
|
|
- if (this._allowTransparentBrowser) {
|
|
+ if (this._allowTransparentBrowser || _forZenEmptyTab) {
|
|
b.setAttribute("transparent", "true");
|
|
}
|
|
|
|
@@ -2405,7 +2469,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.
|
|
@@ -2464,8 +2528,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) {
|
|
- this.tabs[0].linkedBrowser.browsingContext.hasSiblings = true;
|
|
- this.tabs[1].linkedBrowser.browsingContext.hasSiblings = true;
|
|
+ if (this.tabs[0].linkedBrowser.browsingContext) this.tabs[0].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;
|
|
}
|
|
@@ -2629,7 +2693,6 @@
|
|
this.selectedTab = this.addTrustedTab(BROWSER_NEW_TAB_URL, {
|
|
tabIndex: tab._tPos + 1,
|
|
userContextId: tab.userContextId,
|
|
- tabGroup: tab.group,
|
|
focusUrlBar: true,
|
|
});
|
|
resolve(this.selectedBrowser);
|
|
@@ -2709,6 +2772,8 @@
|
|
schemelessInput,
|
|
hasValidUserGestureActivation = false,
|
|
textDirectiveUserActivation = false,
|
|
+ _forZenEmptyTab,
|
|
+ essential,
|
|
} = {}
|
|
) {
|
|
// all callers of addTab that pass a params object need to pass
|
|
@@ -2719,6 +2784,12 @@
|
|
);
|
|
}
|
|
|
|
+ let hasZenDefaultUserContextId = false;
|
|
+ let zenForcedWorkspaceId = undefined;
|
|
+ if (typeof gZenWorkspaces !== "undefined" && !_forZenEmptyTab) {
|
|
+ [userContextId, hasZenDefaultUserContextId, zenForcedWorkspaceId] = gZenWorkspaces.getContextIdIfNeeded(userContextId, fromExternal);
|
|
+ }
|
|
+
|
|
if (!UserInteraction.running("browser.tabs.opening", window)) {
|
|
UserInteraction.start("browser.tabs.opening", "initting", window);
|
|
}
|
|
@@ -2782,6 +2853,19 @@
|
|
noInitialLabel,
|
|
skipBackgroundNotify,
|
|
});
|
|
+ if (hasZenDefaultUserContextId) {
|
|
+ t.setAttribute("zenDefaultUserContextId", "true");
|
|
+ }
|
|
+ if (zenForcedWorkspaceId !== undefined) {
|
|
+ t.setAttribute("zen-workspace-id", zenForcedWorkspaceId);
|
|
+ t.setAttribute("change-workspace", "")
|
|
+ }
|
|
+ if (_forZenEmptyTab) {
|
|
+ t.setAttribute("zen-empty-tab", "true");
|
|
+ }
|
|
+ if (essential) {
|
|
+ t.setAttribute("zen-essential", "true");
|
|
+ }
|
|
if (insertTab) {
|
|
// Insert the tab into the tab container in the correct position.
|
|
this.#insertTabAtIndex(t, {
|
|
@@ -2790,6 +2874,7 @@
|
|
ownerTab,
|
|
openerTab,
|
|
pinned,
|
|
+ essential,
|
|
bulkOrderedOpen,
|
|
tabGroup: tabGroup ?? openerTab?.group,
|
|
});
|
|
@@ -2808,6 +2893,7 @@
|
|
openWindowInfo,
|
|
skipLoad,
|
|
triggeringRemoteType,
|
|
+ _forZenEmptyTab,
|
|
}));
|
|
|
|
if (focusUrlBar) {
|
|
@@ -2928,6 +3014,12 @@
|
|
}
|
|
}
|
|
|
|
+ if (typeof window.gZenVerticalTabsManager !== "undefined") {
|
|
+ gZenVerticalTabsManager.animateItemOpen(t);
|
|
+ }
|
|
+ if (typeof window.gZenCompactModeManager !== "undefined" && !skipLoad && insertTab) {
|
|
+ gZenCompactModeManager._onTabOpen(t, inBackground);
|
|
+ }
|
|
// Additionally send pinned tab events
|
|
if (pinned) {
|
|
this.#notifyPinnedStatus(t);
|
|
@@ -3016,10 +3108,10 @@
|
|
isAdoptingGroup = false,
|
|
isUserTriggered = false,
|
|
telemetryUserCreateSource = "unknown",
|
|
+ forSplitView = false,
|
|
} = {}
|
|
) {
|
|
if (!tabs?.length) {
|
|
- throw new Error("Cannot create tab group with zero tabs");
|
|
}
|
|
|
|
if (!color) {
|
|
@@ -3040,9 +3132,14 @@
|
|
label,
|
|
isAdoptingGroup
|
|
);
|
|
- this.tabContainer.insertBefore(
|
|
+ if (forSplitView) {
|
|
+ group.setAttribute('split-view-group', true);
|
|
+ }
|
|
+ group.essential = tabs.some(tab => tab.hasAttribute("essential"));
|
|
+ group.pinned = group.essential || tabs.some(tab => tab.pinned);
|
|
+ if (forSplitView && !insertBefore?.group?.isZenFolder) insertBefore = insertBefore?.group ?? insertBefore;
|
|
+ insertBefore.before(
|
|
group,
|
|
- insertBefore?.group ?? insertBefore
|
|
);
|
|
group.addTabs(tabs);
|
|
|
|
@@ -3163,7 +3260,7 @@
|
|
}
|
|
|
|
this.#handleTabMove(tab, () =>
|
|
- gBrowser.tabContainer.insertBefore(tab, tab.group.nextElementSibling)
|
|
+ tab.group.after(tab)
|
|
);
|
|
}
|
|
|
|
@@ -3365,6 +3462,7 @@
|
|
openWindowInfo,
|
|
skipLoad,
|
|
triggeringRemoteType,
|
|
+ _forZenEmptyTab
|
|
}
|
|
) {
|
|
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
|
|
@@ -3434,6 +3532,7 @@
|
|
openWindowInfo,
|
|
name,
|
|
skipLoad,
|
|
+ _forZenEmptyTab
|
|
});
|
|
}
|
|
|
|
@@ -3621,7 +3720,7 @@
|
|
// Add a new tab if needed.
|
|
if (!tab) {
|
|
let createLazyBrowser =
|
|
- restoreTabsLazily && !select && !tabData.pinned;
|
|
+ restoreTabsLazily && !tabData.pinned;
|
|
|
|
let url = "about:blank";
|
|
if (tabData.entries?.length) {
|
|
@@ -3658,8 +3757,10 @@
|
|
insertTab: false,
|
|
skipLoad: true,
|
|
preferredRemoteType,
|
|
+ _forZenEmptyTab: tabData.zenIsEmpty,
|
|
});
|
|
-
|
|
+ tab._originalUrl = url;
|
|
+ gZenSessionStore.restoreInitialTabData(tab, tabData);
|
|
if (select) {
|
|
tabToSelect = tab;
|
|
}
|
|
@@ -3671,7 +3772,8 @@
|
|
this.pinTab(tab);
|
|
// Then ensure all the tab open/pinning information is sent.
|
|
this._fireTabOpen(tab, {});
|
|
- } else if (tabData.groupId) {
|
|
+ }
|
|
+ if (tabData.groupId) {
|
|
let { groupId } = tabData;
|
|
const tabGroup = tabGroupWorkingData.get(groupId);
|
|
// if a tab refers to a tab group we don't know, skip any group
|
|
@@ -3685,7 +3787,10 @@
|
|
tabGroup.stateData.id,
|
|
tabGroup.stateData.color,
|
|
tabGroup.stateData.collapsed,
|
|
- tabGroup.stateData.name
|
|
+ tabGroup.stateData.name,
|
|
+ tabGroup.stateData.pinned,
|
|
+ tabGroup.stateData.essential,
|
|
+ tabGroup.stateData.splitView,
|
|
);
|
|
tabsFragment.appendChild(tabGroup.node);
|
|
}
|
|
@@ -3730,9 +3835,23 @@
|
|
// to remove the old selected tab.
|
|
if (tabToSelect) {
|
|
let leftoverTab = this.selectedTab;
|
|
+ if (this._hasAlreadyInitializedZenSessionStore || !gZenWorkspaces.workspaceEnabled) {
|
|
this.selectedTab = tabToSelect;
|
|
this.removeTab(leftoverTab);
|
|
+ } else {
|
|
+ gZenWorkspaces._tabToRemoveForEmpty = leftoverTab;
|
|
+ if (Services.prefs.getBoolPref("zen.workspaces.continue-where-left-off")) {
|
|
+ gZenWorkspaces._tabToSelect = selectTab - 2; // -1 for the offset, and another -1 for the empty tab.
|
|
+ }
|
|
+ if (gZenWorkspaces._initialTab && !gZenVerticalTabsManager._canReplaceNewTab) {
|
|
+ gZenWorkspaces._initialTab._shouldRemove = true;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ else {
|
|
+ gZenWorkspaces._tabToRemoveForEmpty = this.selectedTab;
|
|
}
|
|
+ this._hasAlreadyInitializedZenSessionStore = true;
|
|
|
|
if (tabs.length > 1 || !tabs[0].selected) {
|
|
this._updateTabsAfterInsert();
|
|
@@ -3927,7 +4046,7 @@
|
|
// Ensure we have an index if one was not provided.
|
|
if (typeof elementIndex != "number" && typeof tabIndex != "number") {
|
|
// Move the new tab after another tab if needed, to the end otherwise.
|
|
- elementIndex = Infinity;
|
|
+ elementIndex = Services.prefs.getBoolPref("zen.view.show-newtab-button-top") ? this._numVisiblePinTabsWithoutCollapsed : Infinity;
|
|
if (
|
|
!bulkOrderedOpen &&
|
|
((openerTab &&
|
|
@@ -3939,7 +4058,7 @@
|
|
let lastRelatedTab =
|
|
openerTab && this._lastRelatedTabMap.get(openerTab);
|
|
let previousTab = lastRelatedTab || openerTab || this.selectedTab;
|
|
- if (!tabGroup) {
|
|
+ if (!tabGroup && pinned === previousTab.group?.pinned) {
|
|
tabGroup = previousTab.group;
|
|
}
|
|
if (
|
|
@@ -3950,7 +4069,7 @@
|
|
) {
|
|
elementIndex = Infinity;
|
|
} else if (previousTab.visible) {
|
|
- elementIndex = previousTab.elementIndex + 1;
|
|
+ elementIndex = (typeof previousTab.elementIndex === 'undefined') ? elementIndex : (previousTab.elementIndex + 1);
|
|
} else if (previousTab == FirefoxViewHandler.tab) {
|
|
elementIndex = 0;
|
|
}
|
|
@@ -3978,14 +4097,14 @@
|
|
}
|
|
// Ensure index is within bounds.
|
|
if (tab.pinned) {
|
|
- index = Math.max(index, 0);
|
|
- index = Math.min(index, this.pinnedTabCount);
|
|
+ index = Math.max(index, tab.hasAttribute("zen-essential") ? 0 : this._numZenEssentials);
|
|
+ index = Math.min(index, tab.hasAttribute("zen-essential") ? this._numZenEssentials : this._numVisiblePinTabsWithoutCollapsed);
|
|
} else {
|
|
- index = Math.max(index, this.pinnedTabCount);
|
|
+ index = Math.max(index, this._numVisiblePinTabsWithoutCollapsed);
|
|
index = Math.min(index, allItems.length);
|
|
}
|
|
/** @type {MozTabbrowserTab|undefined} */
|
|
- let itemAfter = allItems.at(index);
|
|
+ let itemAfter = gZenGlanceManager.getTabOrGlanceParent(allItems.at(index));
|
|
|
|
if (pinned && !itemAfter?.pinned) {
|
|
itemAfter = null;
|
|
@@ -3996,7 +4115,7 @@
|
|
|
|
this.tabContainer._invalidateCachedTabs();
|
|
|
|
- if (tabGroup) {
|
|
+ if (tabGroup && !tabGroup.hasAttribute("split-view-group")) {
|
|
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);
|
|
@@ -4032,6 +4151,7 @@
|
|
if (pinned) {
|
|
this._updateTabBarForPinnedTabs();
|
|
}
|
|
+ gZenWorkspaces.fixTabInsertLocation(tab, itemAfter);
|
|
|
|
TabBarVisibility.update();
|
|
}
|
|
@@ -4321,6 +4441,9 @@
|
|
return;
|
|
}
|
|
|
|
+ for (let tab of selectedTabs) {
|
|
+ gZenPinnedTabManager._removePinnedAttributes(tab, true);
|
|
+ }
|
|
this.removeTabs(selectedTabs, { isUserTriggered, telemetrySource });
|
|
}
|
|
|
|
@@ -4582,6 +4705,7 @@
|
|
telemetrySource,
|
|
} = {}
|
|
) {
|
|
+ tabs = tabs.filter(tab => !tab.hasAttribute("zen-empty-tab"));
|
|
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
|
|
// can be considered equivalent to closing the window.
|
|
if (
|
|
@@ -4671,6 +4795,7 @@
|
|
if (lastToClose) {
|
|
this.removeTab(lastToClose, aParams);
|
|
}
|
|
+ gZenUIManager.onTabClose(undefined);
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
@@ -4709,6 +4834,12 @@
|
|
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
|
|
}
|
|
|
|
+ if (gZenWorkspaces.workspaceEnabled) {
|
|
+ let newTab = gZenWorkspaces.handleTabBeforeClose(aTab, closeWindowWithLastTab);
|
|
+ if (newTab) {
|
|
+ this.selectedTab = newTab;
|
|
+ }
|
|
+ }
|
|
// Handle requests for synchronously removing an already
|
|
// asynchronously closing tab.
|
|
if (!animate && aTab.closing) {
|
|
@@ -4723,6 +4854,9 @@
|
|
// state).
|
|
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
|
|
let isLastTab = this.#isLastTabInWindow(aTab);
|
|
+ if (gZenGlanceManager.manageTabClose(aTab)) {
|
|
+ return;
|
|
+ }
|
|
if (
|
|
!this._beginRemoveTab(aTab, {
|
|
closeWindowFastpath: true,
|
|
@@ -4905,7 +5039,7 @@
|
|
closeWindowWithLastTab != null
|
|
? closeWindowWithLastTab
|
|
: !window.toolbar.visible ||
|
|
- Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab");
|
|
+ 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,
|
|
@@ -4929,6 +5063,7 @@
|
|
|
|
newTab = true;
|
|
}
|
|
+ gZenWorkspaces._removedByStartupPage = false;
|
|
aTab._endRemoveArgs = [closeWindow, newTab];
|
|
|
|
// swapBrowsersAndCloseOther will take care of closing the window without animation.
|
|
@@ -4969,13 +5104,7 @@
|
|
aTab._mouseleave();
|
|
|
|
if (newTab) {
|
|
- this.addTrustedTab(BROWSER_NEW_TAB_URL, {
|
|
- skipAnimation: true,
|
|
- // In the event that insertAfterCurrent is set and the current tab is
|
|
- // inside a group that is being closed we want to avoid creating the
|
|
- // new tab inside that group.
|
|
- tabIndex: 0,
|
|
- });
|
|
+ gZenWorkspaces.selectEmptyTab(BROWSER_NEW_TAB_URL);
|
|
} else {
|
|
TabBarVisibility.update();
|
|
}
|
|
@@ -5108,6 +5237,7 @@
|
|
this.tabs[i]._tPos = i;
|
|
}
|
|
|
|
+ gZenWorkspaces.updateTabsContainers();
|
|
if (!this._windowIsClosing) {
|
|
// update tab close buttons state
|
|
this.tabContainer._updateCloseButtons();
|
|
@@ -5320,6 +5450,7 @@
|
|
}
|
|
|
|
let excludeTabs = new Set(aExcludeTabs);
|
|
+ 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.
|
|
@@ -5332,13 +5463,13 @@
|
|
!excludeTabs.has(aTab.owner) &&
|
|
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
|
|
) {
|
|
- return 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) && gZenWorkspaces._shouldChangeToTab(tab)
|
|
);
|
|
|
|
let tab = this.tabContainer.findNextTab(aTab, {
|
|
@@ -5354,7 +5485,7 @@
|
|
}
|
|
|
|
if (tab) {
|
|
- return tab;
|
|
+ return gZenWorkspaces.findTabToBlur(tab);
|
|
}
|
|
|
|
// If no qualifying visible tab was found, see if there is a tab in
|
|
@@ -5375,7 +5506,7 @@
|
|
});
|
|
}
|
|
|
|
- return tab;
|
|
+ return gZenWorkspaces.findTabToBlur(tab);
|
|
}
|
|
|
|
_blurTab(aTab) {
|
|
@@ -5777,10 +5908,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.
|
|
@@ -5972,7 +6103,7 @@
|
|
* `true` if element is a `<tab-group>`
|
|
*/
|
|
isTabGroup(element) {
|
|
- return !!(element?.tagName == "tab-group");
|
|
+ return !!(element?.tagName == "tab-group" || element?.tagName == "zen-folder");
|
|
}
|
|
|
|
/**
|
|
@@ -6049,7 +6180,7 @@
|
|
|
|
// Don't allow mixing pinned and unpinned tabs.
|
|
if (this.isTab(element) && element.pinned) {
|
|
- tabIndex = Math.min(tabIndex, this.pinnedTabCount - 1);
|
|
+ tabIndex = element.hasAttribute('zen-essential') ? Math.min(tabIndex, this._numZenEssentials - 1) : Math.min(Math.max(tabIndex, this._numZenEssentials), this.pinnedTabCount - 1);
|
|
} else {
|
|
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
|
|
}
|
|
@@ -6075,10 +6206,16 @@
|
|
this.#handleTabMove(
|
|
element,
|
|
() => {
|
|
- let neighbor = this.tabs[tabIndex];
|
|
- if (forceUngrouped && neighbor?.group) {
|
|
+ let neighbor = gZenGlanceManager.getTabOrGlanceParent(this.tabs[tabIndex]);
|
|
+ if ((forceUngrouped && neighbor?.group) || neighbor?.group?.hasAttribute("split-view-group")) {
|
|
neighbor = neighbor.group;
|
|
}
|
|
+ if (element.group?.hasAttribute("split-view-group")) {
|
|
+ element = element.group;
|
|
+ }
|
|
+ if (element.group?.hasAttribute("split-view-group") && neighbor == element.group) {
|
|
+ return;
|
|
+ }
|
|
if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
|
|
neighbor.after(element);
|
|
} else {
|
|
@@ -6136,22 +6273,23 @@
|
|
#moveTabNextTo(element, targetElement, moveBefore = false, metricsContext) {
|
|
if (this.isTabGroupLabel(targetElement)) {
|
|
targetElement = targetElement.group;
|
|
- if (!moveBefore && !targetElement.collapsed) {
|
|
+ if (!moveBefore && !targetElement.collapsed && !targetElement.hasAttribute("split-view-group")) {
|
|
// Right after the tab group label = before the first tab in the tab group
|
|
targetElement = targetElement.tabs[0];
|
|
moveBefore = true;
|
|
}
|
|
}
|
|
- if (this.isTabGroupLabel(element)) {
|
|
+ if (this.isTabGroupLabel(element) || element.group?.hasAttribute("split-view-group")) {
|
|
element = element.group;
|
|
- if (targetElement?.group) {
|
|
- targetElement = targetElement.group;
|
|
- }
|
|
}
|
|
|
|
// Don't allow mixing pinned and unpinned tabs.
|
|
+ targetElement = gZenGlanceManager.getTabOrGlanceParent(targetElement);
|
|
+ if (element.hasAttribute('zen-essential') && !targetElement?.hasAttribute('zen-essential')) {
|
|
+ targetElement = this.tabsWithoutGlance[this._numZenEssentials - 1];
|
|
+ } else
|
|
if (element.pinned && !targetElement?.pinned) {
|
|
- targetElement = this.tabs[this.pinnedTabCount - 1];
|
|
+ targetElement = this.tabsWithoutGlance[this.pinnedTabCount - 1];
|
|
moveBefore = false;
|
|
} else if (!element.pinned && targetElement && targetElement.pinned) {
|
|
// If the caller asks to move an unpinned element next to a pinned
|
|
@@ -6165,14 +6303,29 @@
|
|
// 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.
|
|
- targetElement = this.tabs[this.pinnedTabCount];
|
|
+ targetElement = this.tabsWithoutGlance[this.pinnedTabCount];
|
|
if (targetElement.group) {
|
|
targetElement = targetElement.group;
|
|
}
|
|
moveBefore = true;
|
|
}
|
|
+ if (!gZenFolders.canDropElement(element, targetElement)) {
|
|
+ element = element.group;
|
|
+ }
|
|
+ // It is necessary to place the check below to avoid inserting an element
|
|
+ // inside when the split group is the last element.
|
|
+ if (targetElement?.group?.hasAttribute("split-view-group")) {
|
|
+ targetElement = targetElement.group;
|
|
+ }
|
|
+ // When the folder is the last element in the pinned section,
|
|
+ // targetElement is a tab with the zen-empty-tab attribute.
|
|
+ // If the movement is from top to bottom, it must be redefined as a folder.
|
|
+ if (targetElement?.hasAttribute("zen-empty-tab") && !moveBefore) {
|
|
+ targetElement = targetElement.group;
|
|
+ }
|
|
|
|
let getContainer = () =>
|
|
+ element.hasAttribute("zen-essential") ? gZenWorkspaces.getEssentialsSection(element) :
|
|
element.pinned
|
|
? this.tabContainer.pinnedTabsContainer
|
|
: this.tabContainer;
|
|
@@ -6181,7 +6334,7 @@
|
|
element,
|
|
() => {
|
|
if (moveBefore) {
|
|
- getContainer().insertBefore(element, targetElement);
|
|
+ targetElement.parentElement.insertBefore(element, targetElement);
|
|
} else if (targetElement) {
|
|
targetElement.after(element);
|
|
} else {
|
|
@@ -6230,7 +6383,7 @@
|
|
if (!this.isTab(aTab)) {
|
|
throw new Error("Can only move a tab into a tab group");
|
|
}
|
|
- if (aTab.pinned) {
|
|
+ if (aTab.pinned != !!aGroup.pinned) {
|
|
return;
|
|
}
|
|
if (aTab.group && aTab.group.id === aGroup.id) {
|
|
@@ -6324,6 +6477,10 @@
|
|
|
|
moveActionCallback();
|
|
|
|
+ gZenWorkspaces.makeSureEmptyTabIsFirst();
|
|
+ gZenViewSplitter._maybeRemoveFakeBrowser(false);
|
|
+ gZenViewSplitter._canDrop = false;
|
|
+
|
|
// Clear tabs cache after moving nodes because the order of tabs may have
|
|
// changed.
|
|
this.tabContainer._invalidateCachedTabs();
|
|
@@ -7221,7 +7378,7 @@
|
|
// preventDefault(). It will still raise the window if appropriate.
|
|
break;
|
|
}
|
|
- this.selectedTab = tab;
|
|
+ gZenWorkspaces.switchTabIfNeeded(tab);
|
|
window.focus();
|
|
aEvent.preventDefault();
|
|
break;
|
|
@@ -8166,6 +8323,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;
|
|
}
|
|
@@ -9157,7 +9315,7 @@ var TabContextMenu = {
|
|
);
|
|
contextUnpinSelectedTabs.hidden =
|
|
!this.contextTab.pinned || !this.multiselected;
|
|
-
|
|
+ gZenPinnedTabManager.updatePinnedTabContextMenu(this.contextTab);
|
|
// Build Ask Chat items
|
|
TabContextMenu.GenAI.buildTabMenu(
|
|
document.getElementById("context_askChat"),
|
|
@@ -9476,6 +9634,7 @@ var TabContextMenu = {
|
|
)
|
|
);
|
|
} else {
|
|
+ gZenPinnedTabManager._removePinnedAttributes(this.contextTab, true);
|
|
gBrowser.removeTab(this.contextTab, {
|
|
animate: true,
|
|
...gBrowser.TabMetrics.userTriggeredContext(
|
|
|