forked from ZenBrowserMirrors/zen-desktop
660 lines
23 KiB
C++
660 lines
23 KiB
C++
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
|
index d5aa64842a35c6697263c63fd3a0571b64b01344..6943dc7f1d3d95ab1da315cbdbda0b032cf200f1 100644
|
|
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
|
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
|
@@ -413,11 +413,41 @@
|
|
return this.tabContainer.visibleTabs;
|
|
}
|
|
|
|
+ get _numVisiblePinTabsWithoutCollapsed() {
|
|
+ let i = 0;
|
|
+ for (let item of this.tabContainer.ariaFocusableItems) {
|
|
+ if (!!item?.classList?.contains("tab-group-label") && item.closest("tab-group").pinned) {
|
|
+ i += 1;
|
|
+ continue;
|
|
+ }
|
|
+ if (!item.pinned && !item.hasAttribute("zen-glance-tab")) {
|
|
+ break;
|
|
+ }
|
|
+ if ((!item.group?.hasAttribute("split-view-group") && !item.group?.collapsed) && !item.hidden) {
|
|
+ i += !item.hasAttribute("zen-glance-tab");
|
|
+ }
|
|
+ }
|
|
+ return i;
|
|
+ }
|
|
+
|
|
+ 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;
|
|
}
|
|
@@ -569,6 +599,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;
|
|
@@ -834,11 +865,13 @@
|
|
}
|
|
|
|
this.showTab(aTab);
|
|
- if (this.tabContainer.verticalMode) {
|
|
+ const handled = gZenFolders.handleTabPin(aTab);
|
|
+ if (!handled) this.ungroupTab(aTab);
|
|
+ if (this.tabContainer.verticalMode && !handled) {
|
|
this.#handleTabMove(aTab, () =>
|
|
- this.verticalPinnedTabsContainer.appendChild(aTab)
|
|
+ aTab.hasAttribute("zen-essential") ? gZenWorkspaces.getEssentialsSection(aTab).appendChild(aTab) : this.verticalPinnedTabsContainer.insertBefore(aTab, this.verticalPinnedTabsContainer.lastChild)
|
|
);
|
|
- } else {
|
|
+ } else if (!handled) {
|
|
this.moveTabTo(aTab, {
|
|
tabIndex: this.pinnedTabCount,
|
|
forceUngrouped: true,
|
|
@@ -855,12 +888,15 @@
|
|
}
|
|
|
|
if (this.tabContainer.verticalMode) {
|
|
+ const handled = gZenFolders.handleTabUnpin(aTab);
|
|
this.#handleTabMove(aTab, () => {
|
|
// we remove this attribute first, so that allTabs represents
|
|
// the moving of a tab from the vertical pinned tabs container
|
|
// and back into arrowscrollbox.
|
|
aTab.removeAttribute("pinned");
|
|
- this.tabContainer.arrowScrollbox.prepend(aTab);
|
|
+ if (!handled) {
|
|
+ gZenWorkspaces.activeWorkspaceStrip.prepend(aTab);
|
|
+ }
|
|
});
|
|
} else {
|
|
this.moveTabTo(aTab, {
|
|
@@ -1044,6 +1080,8 @@
|
|
|
|
let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"];
|
|
|
|
+ try {
|
|
+ gZenPinnedTabManager.onTabIconChanged(aTab, aIconURL);
|
|
if (
|
|
aIconURL &&
|
|
!aLoadingPrincipal &&
|
|
@@ -1054,6 +1092,9 @@
|
|
);
|
|
return;
|
|
}
|
|
+ } catch (e) {
|
|
+ console.warn(e);
|
|
+ }
|
|
|
|
let browser = this.getBrowserForTab(aTab);
|
|
browser.mIconURL = aIconURL;
|
|
@@ -1303,6 +1344,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()) {
|
|
@@ -1455,6 +1497,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();
|
|
@@ -1778,7 +1823,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;
|
|
}
|
|
|
|
@@ -1886,7 +1932,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"
|
|
@@ -2150,6 +2196,7 @@
|
|
uriIsAboutBlank,
|
|
userContextId,
|
|
skipLoad,
|
|
+ _forZenEmptyTab,
|
|
} = {}) {
|
|
let b = document.createXULElement("browser");
|
|
// Use the JSM global to create the permanentKey, so that if the
|
|
@@ -2223,8 +2270,7 @@
|
|
// we use a different attribute name for this?
|
|
b.setAttribute("name", name);
|
|
}
|
|
-
|
|
- if (this._allowTransparentBrowser) {
|
|
+ if (this._allowTransparentBrowser || _forZenEmptyTab) {
|
|
b.setAttribute("transparent", "true");
|
|
}
|
|
|
|
@@ -2389,7 +2435,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.
|
|
@@ -2448,8 +2494,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;
|
|
}
|
|
@@ -2680,6 +2726,7 @@
|
|
schemelessInput,
|
|
hasValidUserGestureActivation = false,
|
|
textDirectiveUserActivation = false,
|
|
+ _forZenEmptyTab,
|
|
} = {}
|
|
) {
|
|
// all callers of addTab that pass a params object need to pass
|
|
@@ -2690,6 +2737,12 @@
|
|
);
|
|
}
|
|
|
|
+ let hasZenDefaultUserContextId = false;
|
|
+ let zenForcedWorkspaceId = undefined;
|
|
+ if (typeof gZenWorkspaces !== "undefined" && !_forZenEmptyTab) {
|
|
+ [userContextId, hasZenDefaultUserContextId, zenForcedWorkspaceId] = gZenWorkspaces.getContextIdIfNeeded(userContextId, fromExternal, allowInheritPrincipal);
|
|
+ }
|
|
+
|
|
if (!UserInteraction.running("browser.tabs.opening", window)) {
|
|
UserInteraction.start("browser.tabs.opening", "initting", window);
|
|
}
|
|
@@ -2753,6 +2806,16 @@
|
|
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 (insertTab) {
|
|
// Insert the tab into the tab container in the correct position.
|
|
// For now, we support `index` as an alias for `tabIndex`.
|
|
@@ -2783,6 +2846,7 @@
|
|
openWindowInfo,
|
|
skipLoad,
|
|
triggeringRemoteType,
|
|
+ _forZenEmptyTab,
|
|
}));
|
|
|
|
if (focusUrlBar) {
|
|
@@ -2902,6 +2966,12 @@
|
|
}
|
|
}
|
|
|
|
+ if (typeof window.gZenVerticalTabsManager !== "undefined") {
|
|
+ gZenVerticalTabsManager.animateTab(t);
|
|
+ }
|
|
+ if (typeof window.gZenCompactModeManager !== "undefined" && !skipLoad && insertTab) {
|
|
+ gZenCompactModeManager._onTabOpen(t, inBackground);
|
|
+ }
|
|
// Additionally send pinned tab events
|
|
if (pinned) {
|
|
this._notifyPinnedStatus(t);
|
|
@@ -2990,10 +3060,10 @@
|
|
isAdoptingGroup = false,
|
|
isUserTriggered = false,
|
|
telemetryUserCreateSource = "unknown",
|
|
+ forSplitView = false,
|
|
} = {}
|
|
) {
|
|
if (!tabs?.length) {
|
|
- throw new Error("Cannot create tab group with zero tabs");
|
|
}
|
|
|
|
if (!color) {
|
|
@@ -3014,7 +3084,12 @@
|
|
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);
|
|
+ ((insertBefore?.group ?? insertBefore).parentNode).insertBefore(
|
|
group,
|
|
insertBefore?.group ?? insertBefore
|
|
);
|
|
@@ -3303,6 +3378,7 @@
|
|
openWindowInfo,
|
|
skipLoad,
|
|
triggeringRemoteType,
|
|
+ _forZenEmptyTab
|
|
}
|
|
) {
|
|
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
|
|
@@ -3372,6 +3448,7 @@
|
|
openWindowInfo,
|
|
name,
|
|
skipLoad,
|
|
+ _forZenEmptyTab
|
|
});
|
|
}
|
|
|
|
@@ -3560,7 +3637,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) {
|
|
@@ -3598,7 +3675,29 @@
|
|
skipLoad: true,
|
|
preferredRemoteType,
|
|
});
|
|
+ tab._originalUrl = url;
|
|
|
|
+ if (tabData.zenWorkspace) {
|
|
+ tab.setAttribute("zen-workspace-id", tabData.zenWorkspace);
|
|
+ }
|
|
+ if (tabData.zenPinnedId) {
|
|
+ tab.setAttribute("zen-pin-id", tabData.zenPinnedId);
|
|
+ }
|
|
+ if (tabData.zenIsEmpty) {
|
|
+ tab.setAttribute("zen-empty-tab", "true");
|
|
+ }
|
|
+ if (tabData.zenHasStaticLabel) {
|
|
+ tab.setAttribute("zen-has-static-label", "true");
|
|
+ }
|
|
+ if (tabData.zenEssential) {
|
|
+ tab.setAttribute("zen-essential", "true");
|
|
+ }
|
|
+ if (tabData.zenDefaultUserContextId) {
|
|
+ tab.setAttribute("zenDefaultUserContextId", "true");
|
|
+ }
|
|
+ if (tabData.zenPinnedEntry) {
|
|
+ tab.setAttribute("zen-pinned-entry", tabData.zenPinnedEntry);
|
|
+ }
|
|
if (select) {
|
|
tabToSelect = tab;
|
|
}
|
|
@@ -3622,7 +3721,8 @@
|
|
// needs calling:
|
|
shouldUpdateForPinnedTabs = true;
|
|
}
|
|
- } 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
|
|
@@ -3636,7 +3736,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);
|
|
}
|
|
@@ -3684,8 +3787,16 @@
|
|
// to remove the old selected tab.
|
|
if (tabToSelect) {
|
|
let leftoverTab = this.selectedTab;
|
|
- this.selectedTab = tabToSelect;
|
|
- this.removeTab(leftoverTab);
|
|
+ gZenWorkspaces._tabToRemoveForEmpty = leftoverTab;
|
|
+ if (Services.prefs.getBoolPref("zen.workspaces.continue-where-left-off")) {
|
|
+ gZenWorkspaces._tabToSelect = selectTab - 1;
|
|
+ }
|
|
+ if (gZenWorkspaces._initialTab && !gZenVerticalTabsManager._canReplaceNewTab) {
|
|
+ gZenWorkspaces._initialTab._shouldRemove = true;
|
|
+ }
|
|
+ }
|
|
+ else {
|
|
+ gZenWorkspaces._tabToRemoveForEmpty = this.selectedTab;
|
|
}
|
|
|
|
if (tabs.length > 1 || !tabs[0].selected) {
|
|
@@ -3881,7 +3992,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 &&
|
|
@@ -3904,7 +4015,7 @@
|
|
) {
|
|
elementIndex = Infinity;
|
|
} else if (previousTab.visible) {
|
|
- elementIndex = previousTab.elementIndex + 1;
|
|
+ elementIndex = (typeof previousTab.elementIndex === 'undefined') ? index : (previousTab.elementIndex + 1);
|
|
} else if (previousTab == FirefoxViewHandler.tab) {
|
|
elementIndex = 0;
|
|
}
|
|
@@ -3932,10 +4043,10 @@
|
|
}
|
|
// 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} */
|
|
@@ -3947,7 +4058,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);
|
|
@@ -4268,6 +4379,9 @@
|
|
return;
|
|
}
|
|
|
|
+ for (let tab of selectedTabs) {
|
|
+ gZenPinnedTabManager._removePinnedAttributes(tab, true);
|
|
+ }
|
|
this.removeTabs(selectedTabs, { telemetrySource });
|
|
}
|
|
|
|
@@ -4520,6 +4634,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 (
|
|
@@ -4604,6 +4719,7 @@
|
|
if (lastToClose) {
|
|
this.removeTab(lastToClose, aParams);
|
|
}
|
|
+ gZenUIManager.onTabClose(undefined);
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
@@ -4641,6 +4757,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) {
|
|
@@ -4655,7 +4777,9 @@
|
|
// frame created for it (for example, by updating the visually selected
|
|
// state).
|
|
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
|
|
-
|
|
+ if (gZenGlanceManager.manageTabClose(aTab)) {
|
|
+ return;
|
|
+ }
|
|
if (
|
|
!this._beginRemoveTab(aTab, {
|
|
closeWindowFastpath: true,
|
|
@@ -4821,7 +4945,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,
|
|
@@ -4845,6 +4969,7 @@
|
|
|
|
newTab = true;
|
|
}
|
|
+ gZenWorkspaces._removedByStartupPage = false;
|
|
aTab._endRemoveArgs = [closeWindow, newTab];
|
|
|
|
// swapBrowsersAndCloseOther will take care of closing the window without animation.
|
|
@@ -4885,9 +5010,7 @@
|
|
aTab._mouseleave();
|
|
|
|
if (newTab) {
|
|
- this.addTrustedTab(BROWSER_NEW_TAB_URL, {
|
|
- skipAnimation: true,
|
|
- });
|
|
+ gZenWorkspaces.selectEmptyTab(BROWSER_NEW_TAB_URL);
|
|
} else {
|
|
TabBarVisibility.update();
|
|
}
|
|
@@ -5016,6 +5139,8 @@
|
|
this.tabs[i]._tPos = i;
|
|
}
|
|
|
|
+ gZenWorkspaces.updateTabsContainers();
|
|
+
|
|
if (!this._windowIsClosing) {
|
|
if (wasPinned) {
|
|
this.tabContainer._positionPinnedTabs();
|
|
@@ -5230,6 +5355,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.
|
|
@@ -5242,13 +5368,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, {
|
|
@@ -5264,7 +5390,7 @@
|
|
}
|
|
|
|
if (tab) {
|
|
- return tab;
|
|
+ return gZenWorkspaces.findTabToBlur(tab);
|
|
}
|
|
|
|
// If no qualifying visible tab was found, see if there is a tab in
|
|
@@ -5285,7 +5411,7 @@
|
|
});
|
|
}
|
|
|
|
- return tab;
|
|
+ return gZenWorkspaces.findTabToBlur(tab);
|
|
}
|
|
|
|
_blurTab(aTab) {
|
|
@@ -5686,10 +5812,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.
|
|
@@ -5986,7 +6112,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);
|
|
}
|
|
@@ -6012,10 +6138,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 {
|
|
@@ -6084,17 +6216,26 @@
|
|
targetElement = targetElement.group;
|
|
}
|
|
}
|
|
-
|
|
+ if (element.group?.hasAttribute("split-view-group")) {
|
|
+ element = element.group;
|
|
+ }
|
|
// Don't allow mixing pinned and unpinned tabs.
|
|
if (element.pinned && !targetElement?.pinned) {
|
|
- targetElement = this.tabs[this.pinnedTabCount - 1];
|
|
+ targetElement = this.tabs.filter(tab => !tab.hasAttribute('zen-glance-tab'))[this.pinnedTabCount - 1];
|
|
moveBefore = false;
|
|
} else if (!element.pinned && targetElement && targetElement.pinned) {
|
|
- targetElement = this.tabs[this.pinnedTabCount];
|
|
+ targetElement = this.tabs.filter(tab => !tab.hasAttribute('zen-glance-tab'))[this.pinnedTabCount];
|
|
moveBefore = true;
|
|
}
|
|
|
|
+ if (targetElement?.group?.hasAttribute("split-view-group")) {
|
|
+ targetElement = targetElement.group;
|
|
+ }
|
|
+ targetElement = gZenGlanceManager.getTabOrGlanceParent(targetElement);
|
|
let getContainer = () => {
|
|
+ if (element.hasAttribute("zen-essential")) {
|
|
+ return gZenWorkspaces.getEssentialsSection(element);
|
|
+ }
|
|
if (element.pinned && this.tabContainer.verticalMode) {
|
|
return this.tabContainer.verticalPinnedTabsContainer;
|
|
}
|
|
@@ -6154,7 +6295,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) {
|
|
@@ -6248,6 +6389,10 @@
|
|
|
|
moveActionCallback();
|
|
|
|
+ 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();
|
|
@@ -7145,7 +7290,7 @@
|
|
// preventDefault(). It will still raise the window if appropriate.
|
|
break;
|
|
}
|
|
- this.selectedTab = tab;
|
|
+ gZenWorkspaces.switchTabIfNeeded(tab);
|
|
window.focus();
|
|
aEvent.preventDefault();
|
|
break;
|
|
@@ -8044,6 +8189,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;
|
|
}
|
|
@@ -9009,7 +9155,7 @@ var TabContextMenu = {
|
|
);
|
|
contextUnpinSelectedTabs.hidden =
|
|
!this.contextTab.pinned || !this.multiselected;
|
|
-
|
|
+ gZenPinnedTabManager.updatePinnedTabContextMenu(this.contextTab);
|
|
// Move Tab items
|
|
let contextMoveTabOptions = document.getElementById(
|
|
"context_moveTabOptions"
|
|
@@ -9278,6 +9424,7 @@ var TabContextMenu = {
|
|
telemetrySource: gBrowser.TabMetrics.METRIC_SOURCE.TAB_STRIP,
|
|
});
|
|
} else {
|
|
+ gZenPinnedTabManager._removePinnedAttributes(this.contextTab, true);
|
|
gBrowser.removeTab(this.contextTab, {
|
|
animate: true,
|
|
telemetrySource: gBrowser.TabMetrics.METRIC_SOURCE.TAB_STRIP,
|