diff --git a/src/browser/components/tabbrowser/content/tabbrowser-js.patch b/src/browser/components/tabbrowser/content/tabbrowser-js.patch index 5b1277a5f..6494a3137 100644 --- a/src/browser/components/tabbrowser/content/tabbrowser-js.patch +++ b/src/browser/components/tabbrowser/content/tabbrowser-js.patch @@ -1,5 +1,5 @@ diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js -index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c1ee4358d 100644 +index 3204f253c23551650991d3385dd256d55892a012..7c30015ac4591fdb97426521ae87b80ed9d2317a 100644 --- a/browser/components/tabbrowser/content/tabbrowser.js +++ b/browser/components/tabbrowser/content/tabbrowser.js @@ -427,15 +427,64 @@ @@ -128,22 +128,6 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c let browser = this.getBrowserForTab(aTab); browser.mIconURL = aIconURL; -@@ -1249,13 +1312,13 @@ - let oldTab = this.selectedTab; - - // Preview mode should not reset the owner -- if (!this._previewMode && !oldTab.selected) { -+ if (!this._previewMode && !oldTab.selected && oldTab.owner && !oldTab.hasAttribute("zen-essential")) { - oldTab.owner = null; - } - - let lastRelatedTab = this._lastRelatedTabMap.get(oldTab); - if (lastRelatedTab) { -- if (!lastRelatedTab.selected) { -+ if (!lastRelatedTab.selected && lastRelatedTab.owner && !lastRelatedTab.hasAttribute("zen-essential")) { - lastRelatedTab.owner = null; - } - } @@ -1333,6 +1396,7 @@ if (!this._previewMode) { newTab.recordTimeFromUnloadToReload(); @@ -249,15 +233,6 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c if (!UserInteraction.running("browser.tabs.opening", window)) { UserInteraction.start("browser.tabs.opening", "initting", window); } -@@ -2752,7 +2827,7 @@ - ownerTab ??= inBackground ? null : this.selectedTab; - - // if we're adding tabs, we're past interrupt mode, ditch the owner -- if (this.selectedTab.owner) { -+ if (this.selectedTab.owner && !this.selectedTab.hasAttribute("zen-essential")) { - this.selectedTab.owner = null; - } - @@ -2807,6 +2882,19 @@ noInitialLabel, skipBackgroundNotify, @@ -453,7 +428,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c tabGroup = previousTab.group; } if ( -@@ -3975,13 +4101,15 @@ +@@ -3975,7 +4101,7 @@ ) { elementIndex = Infinity; } else if (previousTab.visible) { @@ -462,16 +437,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c } else if (previousTab == FirefoxViewHandler.tab) { elementIndex = 0; } - - if (lastRelatedTab) { -- lastRelatedTab.owner = null; -+ if (!lastRelatedTab.hasAttribute("zen-essential")) { -+ lastRelatedTab.owner = null; -+ } - } else if (openerTab) { - tab.owner = openerTab; - } -@@ -4003,14 +4131,14 @@ +@@ -4003,14 +4129,14 @@ } // Ensure index is within bounds. if (tab.pinned) { @@ -490,7 +456,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c if (pinned && !itemAfter?.pinned) { itemAfter = null; -@@ -4021,7 +4149,7 @@ +@@ -4021,7 +4147,7 @@ this.tabContainer._invalidateCachedTabs(); @@ -499,7 +465,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c 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); -@@ -4057,6 +4185,7 @@ +@@ -4057,6 +4183,7 @@ if (pinned) { this._updateTabBarForPinnedTabs(); } @@ -507,7 +473,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c TabBarVisibility.update(); } -@@ -4346,6 +4475,9 @@ +@@ -4346,6 +4473,9 @@ return; } @@ -517,7 +483,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c this.removeTabs(selectedTabs, { isUserTriggered, telemetrySource }); } -@@ -4607,6 +4739,7 @@ +@@ -4607,6 +4737,7 @@ telemetrySource, } = {} ) { @@ -525,7 +491,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c // When 'closeWindowWithLastTab' pref is enabled, closing all tabs // can be considered equivalent to closing the window. if ( -@@ -4696,6 +4829,7 @@ +@@ -4696,6 +4827,7 @@ if (lastToClose) { this.removeTab(lastToClose, aParams); } @@ -533,7 +499,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c } catch (e) { console.error(e); } -@@ -4734,6 +4868,12 @@ +@@ -4734,6 +4866,12 @@ aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start(); } @@ -546,7 +512,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c // Handle requests for synchronously removing an already // asynchronously closing tab. if (!animate && aTab.closing) { -@@ -4748,6 +4888,9 @@ +@@ -4748,6 +4886,9 @@ // state). let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width; let isLastTab = this.#isLastTabInWindow(aTab); @@ -556,7 +522,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c if ( !this._beginRemoveTab(aTab, { closeWindowFastpath: true, -@@ -4796,7 +4939,13 @@ +@@ -4796,7 +4937,13 @@ // We're not animating, so we can cancel the animation stopwatch. Glean.browserTabclose.timeAnim.cancel(aTab._closeTimeAnimTimerId); aTab._closeTimeAnimTimerId = null; @@ -571,7 +537,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c return; } -@@ -4930,7 +5079,7 @@ +@@ -4930,7 +5077,7 @@ closeWindowWithLastTab != null ? closeWindowWithLastTab : !window.toolbar.visible || @@ -580,7 +546,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c if (closeWindow) { // We've already called beforeunload on all the relevant tabs if we get here, -@@ -4954,6 +5103,7 @@ +@@ -4954,6 +5101,7 @@ newTab = true; } @@ -588,7 +554,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c aTab._endRemoveArgs = [closeWindow, newTab]; // swapBrowsersAndCloseOther will take care of closing the window without animation. -@@ -4994,13 +5144,7 @@ +@@ -4994,13 +5142,7 @@ aTab._mouseleave(); if (newTab) { @@ -603,7 +569,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c } else { TabBarVisibility.update(); } -@@ -5133,6 +5277,7 @@ +@@ -5133,6 +5275,7 @@ this.tabs[i]._tPos = i; } @@ -611,7 +577,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c if (!this._windowIsClosing) { // update tab close buttons state this.tabContainer._updateCloseButtons(); -@@ -5345,6 +5490,7 @@ +@@ -5345,6 +5488,7 @@ } let excludeTabs = new Set(aExcludeTabs); @@ -619,7 +585,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c // If this tab has a successor, it should be selectable, since // hiding or closing a tab removes that tab as a successor. -@@ -5357,13 +5503,13 @@ +@@ -5357,13 +5501,13 @@ !excludeTabs.has(aTab.owner) && Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose") ) { @@ -635,7 +601,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c ); let tab = this.tabContainer.findNextTab(aTab, { -@@ -5379,7 +5525,7 @@ +@@ -5379,7 +5523,7 @@ } if (tab) { @@ -644,7 +610,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c } // If no qualifying visible tab was found, see if there is a tab in -@@ -5400,7 +5546,7 @@ +@@ -5400,7 +5544,7 @@ }); } @@ -653,7 +619,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c } _blurTab(aTab) { -@@ -5802,10 +5948,10 @@ +@@ -5802,10 +5946,10 @@ SessionStore.deleteCustomTabValue(aTab, "hiddenBy"); } @@ -666,7 +632,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c aTab.selected || aTab.closing || // Tabs that are sharing the screen, microphone or camera cannot be hidden. -@@ -5864,6 +6010,7 @@ +@@ -5864,6 +6008,7 @@ * @param {MozTabbrowserTab|MozTabbrowserTabGroup|MozTabbrowserTabGroup.labelElement} aTab */ replaceTabWithWindow(aTab, aOptions) { @@ -674,7 +640,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c if (this.tabs.length == 1) { return null; } -@@ -5997,7 +6144,7 @@ +@@ -5997,7 +6142,7 @@ * `true` if element is a `` */ isTabGroup(element) { @@ -683,7 +649,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c } /** -@@ -6073,8 +6220,8 @@ +@@ -6073,8 +6218,8 @@ } // Don't allow mixing pinned and unpinned tabs. @@ -694,7 +660,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c } else { tabIndex = Math.max(tabIndex, this.pinnedTabCount); } -@@ -6100,10 +6247,16 @@ +@@ -6100,10 +6245,16 @@ this.#handleTabMove( element, () => { @@ -713,7 +679,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c if (neighbor && this.isTab(element) && tabIndex > element._tPos) { neighbor.after(element); } else { -@@ -6161,23 +6314,28 @@ +@@ -6161,23 +6312,28 @@ #moveTabNextTo(element, targetElement, moveBefore = false, metricsContext) { if (this.isTabGroupLabel(targetElement)) { targetElement = targetElement.group; @@ -748,7 +714,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c } else if (!element.pinned && targetElement && targetElement.pinned) { // If the caller asks to move an unpinned element next to a pinned // tab, move the unpinned element to be the first unpinned element -@@ -6190,14 +6348,34 @@ +@@ -6190,14 +6346,34 @@ // move the tab group right before the first unpinned tab. // 4. Moving a tab group and the first unpinned tab is grouped: // move the tab group right before the first unpinned tab's tab group. @@ -784,7 +750,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c element.pinned ? this.tabContainer.pinnedTabsContainer : this.tabContainer; -@@ -6206,7 +6384,7 @@ +@@ -6206,7 +6382,7 @@ element, () => { if (moveBefore) { @@ -793,7 +759,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c } else if (targetElement) { targetElement.after(element); } else { -@@ -6252,10 +6430,10 @@ +@@ -6252,10 +6428,10 @@ * @param {TabMetricsContext} [metricsContext] */ moveTabToGroup(aTab, aGroup, metricsContext) { @@ -806,7 +772,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c return; } if (aTab.group && aTab.group.id === aGroup.id) { -@@ -6285,6 +6463,7 @@ +@@ -6285,6 +6461,7 @@ let state = { tabIndex: tab._tPos, @@ -814,7 +780,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c }; if (tab.visible) { state.elementIndex = tab.elementIndex; -@@ -6311,7 +6490,7 @@ +@@ -6311,7 +6488,7 @@ let changedTabGroup = previousTabState.tabGroupId != currentTabState.tabGroupId; @@ -823,7 +789,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c tab.dispatchEvent( new CustomEvent("TabMove", { bubbles: true, -@@ -6348,6 +6527,10 @@ +@@ -6348,6 +6525,10 @@ moveActionCallback(); @@ -834,7 +800,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c // Clear tabs cache after moving nodes because the order of tabs may have // changed. this.tabContainer._invalidateCachedTabs(); -@@ -7249,7 +7432,7 @@ +@@ -7249,7 +7430,7 @@ // preventDefault(). It will still raise the window if appropriate. break; } @@ -843,7 +809,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c window.focus(); aEvent.preventDefault(); break; -@@ -7264,7 +7447,6 @@ +@@ -7264,7 +7445,6 @@ } case "TabGroupCollapse": aEvent.target.tabs.forEach(tab => { @@ -851,7 +817,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c }); break; case "TabGroupCreateByUser": -@@ -8199,6 +8381,7 @@ +@@ -8199,6 +8379,7 @@ aWebProgress.isTopLevel ) { this.mTab.setAttribute("busy", "true"); @@ -859,7 +825,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c gBrowser._tabAttrModified(this.mTab, ["busy"]); this.mTab._notselectedsinceload = !this.mTab.selected; } -@@ -9200,7 +9383,7 @@ var TabContextMenu = { +@@ -9200,7 +9381,7 @@ var TabContextMenu = { ); contextUnpinSelectedTabs.hidden = !this.contextTab.pinned || !this.multiselected; @@ -868,7 +834,7 @@ index 3204f253c23551650991d3385dd256d55892a012..792e54079e9f82013617306243fe313c // Build Ask Chat items TabContextMenu.GenAI.buildTabMenu( document.getElementById("context_askChat"), -@@ -9520,6 +9703,7 @@ var TabContextMenu = { +@@ -9520,6 +9701,7 @@ var TabContextMenu = { ) ); } else { diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index 3bfece219..f76daecb5 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -1495,6 +1495,7 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature { continue; } + tab.owner = null; if (container) { if (tab.group?.hasAttribute('split-view-group')) { gBrowser.zenHandleTabMove(tab.group, () => { @@ -2751,14 +2752,12 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature { getTabsToExclude(aTab) { const tabWorkspaceId = aTab.getAttribute('zen-workspace-id'); + const containerId = aTab.getAttribute('usercontextid') ?? '0'; // Return all tabs that are not on the same workspace return this.allStoredTabs.filter( (tab) => tab.getAttribute('zen-workspace-id') !== tabWorkspaceId && - !( - this.containerSpecificEssentials && - tab.getAttribute('container') !== aTab.getAttribute('container') - ) && + !this._shouldShowTab(tab, tabWorkspaceId, containerId, this._workspaceCache) && !tab.hasAttribute('zen-empty-tab') ); }