From 7c000b0ddf0bd6312ab31f13a727318ae1477184 Mon Sep 17 00:00:00 2001 From: "YUKI \"Piro\" Hiroshi" Date: Tue, 19 Mar 2024 12:46:04 +0900 Subject: [PATCH] Add an option to expose hidden tabs #3495 --- webextensions/common/Tab.js | 11 +++++++++++ webextensions/common/common.js | 1 + webextensions/common/tabs-store.js | 5 ++++- webextensions/sidebar/sidebar-tabs.js | 11 +++++++++++ webextensions/sidebar/styles/base.css | 4 +--- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/webextensions/common/Tab.js b/webextensions/common/Tab.js index 8f86c3a15..07b74e8a4 100644 --- a/webextensions/common/Tab.js +++ b/webextensions/common/Tab.js @@ -2534,6 +2534,17 @@ Tab.getVisibleTabs = (windowId = null, options = {}) => { // visible, not-collap }); }; +Tab.getHiddenTabs = (windowId = null, options = {}) => { + return TabsStore.queryAll({ + windowId, + tabs: TabsStore.getTabsMap(TabsStore.livingTabsInWindow, windowId), + living: true, + ordered: true, + hidden: true, + ...options + }); +}; + Tab.getPinnedTabs = (windowId = null, options = {}) => { // visible, pinned return TabsStore.queryAll({ windowId, diff --git a/webextensions/common/common.js b/webextensions/common/common.js index 6ddc08f2d..69df10fd0 100644 --- a/webextensions/common/common.js +++ b/webextensions/common/common.js @@ -419,6 +419,7 @@ export const configs = new Configs({ provressiveHighlightingStep: Number.MAX_SAFE_INTEGER, progressievHighlightingInterval: 100, outOfScreenTabsRenderingPages: 1, + renderHiddenTabs: false, generatedTabElementsPoolLifetimeMsec: 5 * 1000, undoMultipleTabsClose: true, allowDragNewTabButton: true, diff --git a/webextensions/common/tabs-store.js b/webextensions/common/tabs-store.js index 16abfec7c..3e0b04278 100644 --- a/webextensions/common/tabs-store.js +++ b/webextensions/common/tabs-store.js @@ -228,6 +228,9 @@ function matchedWithQuery(tab, query) { tab.hidden || tabStates.has(Constants.kTAB_STATE_SHOWING))) return false; + if (query.hidden && + !tab.hidden) + return false; if (query.controllable && (tab.hidden || tabStates.has(Constants.kTAB_STATE_SHOWING))) @@ -489,7 +492,7 @@ export function updateIndexesForTab(tab) { export function updateVirtualScrollRenderabilityIndexForTab(tab) { if (tab.pinned || - tab.hidden || + (tab.hidden && !configs.renderHiddenTabs) || tab.$TST.states.has(Constants.kTAB_STATE_COLLAPSED_DONE)) removeVirtualScrollRenderableTab(tab); else diff --git a/webextensions/sidebar/sidebar-tabs.js b/webextensions/sidebar/sidebar-tabs.js index 9ee800d34..663b2f66a 100644 --- a/webextensions/sidebar/sidebar-tabs.js +++ b/webextensions/sidebar/sidebar-tabs.js @@ -442,6 +442,17 @@ configs.$addObserver(async changedKey => { case 'labelOverflowStyle': document.documentElement.setAttribute(Constants.kLABEL_OVERFLOW, configs.labelOverflowStyle); break; + + case 'renderHiddenTabs': { + let hasNormalTab = false; + for (const tab of Tab.getHiddenTabs(TabsStore.getCurrentWindowId(), { iterator: true })) { + TabsStore.updateVirtualScrollRenderabilityIndexForTab(tab); + if (!tab.pinned) + hasNormalTab = true; + } + if (hasNormalTab) + onNormalTabsChanged.dispatch(); + }; break; } }); diff --git a/webextensions/sidebar/styles/base.css b/webextensions/sidebar/styles/base.css index faf7fc8a4..2b5706775 100644 --- a/webextensions/sidebar/styles/base.css +++ b/webextensions/sidebar/styles/base.css @@ -491,9 +491,7 @@ tab-item tab-favicon { } tab-item.hidden { - pointer-events: none; - position: fixed; - visibility: collapse; + opacity: 0.6; } :root.animation:not(.minimized) tab-item.animation-ready,