diff --git a/browser/components/tabbrowser/content/tab.js b/browser/components/tabbrowser/content/tab.js index 836bee14d2b63604688ebe477a5d915a5e99b305..a675aed711560b4a44604fc17478cffa7fb68439 100644 --- a/browser/components/tabbrowser/content/tab.js +++ b/browser/components/tabbrowser/content/tab.js @@ -21,6 +21,7 @@ + @@ -38,9 +39,11 @@ + `; @@ -86,7 +89,7 @@ ".tab-content": "pinned,selected=visuallyselected,multiselected,titlechanged,attention", ".tab-icon-stack": - "sharing,pictureinpicture,crashed,busy,soundplaying,soundplaying-scheduledremoval,pinned,muted,blocked,selected=visuallyselected,activemedia-blocked", + "zen-essential,sharing,pictureinpicture,crashed,busy,soundplaying,soundplaying-scheduledremoval,pinned,muted,blocked,selected=visuallyselected,activemedia-blocked", ".tab-throbber": "fadein,pinned,busy,progress,selected=visuallyselected", ".tab-icon-pending": @@ -95,9 +98,9 @@ "src=image,requestcontextid,fadein,pinned,selected=visuallyselected,busy,crashed,sharing,pictureinpicture,pending,discarded", ".tab-sharing-icon-overlay": "sharing,selected=visuallyselected,pinned", ".tab-icon-overlay": - "sharing,pictureinpicture,crashed,busy,soundplaying,soundplaying-scheduledremoval,pinned,muted,blocked,selected=visuallyselected,activemedia-blocked", + "zen-essential,sharing,pictureinpicture,crashed,busy,soundplaying,soundplaying-scheduledremoval,pinned,muted,blocked,selected=visuallyselected,activemedia-blocked", ".tab-audio-button": - "crashed,soundplaying,soundplaying-scheduledremoval,pinned,muted,activemedia-blocked", + "zen-essential,crashed,soundplaying,soundplaying-scheduledremoval,pinned,muted,activemedia-blocked", ".tab-label-container": "pinned,selected=visuallyselected,labeldirection", ".tab-label": @@ -188,7 +191,7 @@ } set _visuallySelected(val) { - if (val == this.hasAttribute("visuallyselected")) { + if (val == this.hasAttribute("visuallyselected") || (!val && this.linkedBrowser?.closest('.browserSidebarContainer').classList.contains('zen-glance-background'))) { return; } @@ -224,11 +227,23 @@ } get visible() { - return ( - this.isOpen && - !this.hidden && - (!this.group || this.group.isTabVisibleInGroup(this)) - ); + if (!this.isOpen || this.hidden || this.hasAttribute("zen-empty-tab")) { + return false; + } + // Selected tabs are always visible + if (this.selected || this.multiselected || this.hasAttribute("folder-active")) return true; + // Recursively check all parent groups + let currentParent = this.group; + while (currentParent) { + if (currentParent.collapsed) { + return false; + } + currentParent = currentParent.group; + } + if (this.pinned && !this.hasAttribute("zen-essential") && gZenWorkspaces.activeWorkspaceElement?.hasCollapsedPinnedTabs) { + return false; + } + return true; } get hidden() { @@ -307,7 +322,7 @@ return false; } - return true; + return !this.hasAttribute("zen-empty-tab"); } get lastAccessed() { @@ -384,7 +399,18 @@ } get group() { - return this.closest("tab-group"); + if (typeof gBrowser === "undefined") { + return null; + } + if (gBrowser.isTabGroup(this.parentElement?.parentElement)) { + return this.parentElement.parentElement; + } + if (this.pinned && !this.hasAttribute('zen-essential')) { + let collapsiblePins = gZenWorkspaces.workspaceElement(this.getAttribute('zen-workspace-id'))?.collapsiblePins; + if (collapsiblePins?.collapsed) { + return collapsiblePins; + } + } } get splitview() { @@ -489,6 +515,8 @@ this.style.MozUserFocus = "ignore"; } else if ( event.target.classList.contains("tab-close-button") || + event.target.classList.contains("tab-reset-button") || + event.target.classList.contains("tab-reset-pin-button") || event.target.classList.contains("tab-icon-overlay") || event.target.classList.contains("tab-audio-button") ) { @@ -543,6 +571,10 @@ this.style.MozUserFocus = ""; } + get glanceTab() { + return this.querySelector("tab[zen-glance-tab]"); + } + on_click(event) { if (event.button != 0) { return; @@ -603,6 +635,14 @@ // (see tabbrowser-tabs 'click' handler). gBrowser.tabContainer._blockDblClick = true; } + + if (event.target.classList.contains("tab-reset-pin-button")) { + gZenPinnedTabManager._onTabResetPinButton(event, this, 'reset'); + gBrowser.tabContainer._blockDblClick = true; + } else if (event.target.classList.contains("tab-reset-button")) { + gZenPinnedTabManager.onCloseTabShortcut(event, this); + gBrowser.tabContainer._blockDblClick = true; + } } on_dblclick(event) { @@ -626,6 +666,8 @@ animate: true, triggeringEvent: event, }); + } else if (this.hasAttribute('zen-essential') && !event.target.classList.contains("tab-icon-overlay")) { + gZenPinnedTabManager._onTabResetPinButton(event, this, 'reset'); } }