diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js index c89ae2cbb978d6218bd56a059c5ca1e371231607..6608e0d7df1092a7398979abb166895e0b4fb66b 100644 --- a/browser/components/tabbrowser/content/tabbrowser.js +++ b/browser/components/tabbrowser/content/tabbrowser.js @@ -456,11 +456,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; }, @@ -2705,6 +2720,11 @@ ); } + let hasZenDefaultUserContextId = false; + if (typeof ZenWorkspaces !== "undefined") { + [userContextId, hasZenDefaultUserContextId] = ZenWorkspaces.getContextIdIfNeeded(userContextId); + } + if (!UserInteraction.running("browser.tabs.opening", window)) { UserInteraction.start("browser.tabs.opening", "initting", window); } @@ -2773,6 +2793,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, { @@ -3262,6 +3285,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 { @@ -3283,6 +3314,13 @@ url = tabData.entries[activeIndex].url; } + if(Services.prefs.getBoolPref("zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url", false) && tabData.pinned && tabData.zenPinnedUrl) { + tabData.entries = [{url: tabData.zenPinnedUrl, title: tabData.zenPinnedTitle}]; + tabData.image = tabData.zenPinnedIcon; + tabData.index = 0; + url = tabData.zenPinnedUrl; + } + let preferredRemoteType = E10SUtils.getRemoteTypeForURI( url, gMultiProcessBrowser, @@ -3311,6 +3349,12 @@ preferredRemoteType, }); + if (tabData.zenWorkspace) { + tab.setAttribute("zen-workspace-id", tabData.zenWorkspace); + } + if (tabData.zenDefaultUserContextId) { + tab.setAttribute("zenDefaultUserContextId", "true"); + } if (select) { tabToSelect = tab; } @@ -3345,7 +3389,17 @@ this.tabContainer._invalidateCachedTabs(); } } + if (tabData.zenPinnedUrl) { + tab.setAttribute("zen-pinned-url", tabData.zenPinnedUrl); + } + if (tabData.zenPinnedTitle) { + tab.setAttribute("zen-pinned-title", tabData.zenPinnedTitle); + } + + if(tabData.zenPinnedIcon) { + tab.setAttribute("zen-pinned-icon", tabData.zenPinnedIcon); + } tab.initialize(); } @@ -4198,6 +4252,7 @@ isLastTab || aTab.pinned || aTab.hidden || + true || this._removingTabs.size > 3 /* don't want lots of concurrent animations */ || !aTab.hasAttribute( @@ -5131,10 +5186,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. @@ -7870,7 +7925,14 @@ var TabContextMenu = { ); contextUnpinSelectedTabs.hidden = !this.contextTab.pinned || !multiselectionContext; - + let contextResetPinnedTab = document.getElementById("context_zen-reset-pinned-tab"); + if(contextResetPinnedTab) { + contextResetPinnedTab.hidden = !this.contextTab.pinned || !this.contextTab.getAttribute("zen-pinned-url") || multiselectionContext; + } + let contextReplacePinnedUrlWithCurrent = document.getElementById("context_zen-replace-pinned-url-with-current"); + if(contextReplacePinnedUrlWithCurrent) { + contextReplacePinnedUrlWithCurrent.hidden = !this.contextTab.pinned || !this.contextTab.getAttribute("zen-pinned-url") || multiselectionContext; + } // Move Tab items let contextMoveTabOptions = document.getElementById( "context_moveTabOptions"