From c47cb107c3772fdf0bf8a8738dd3c1348ac6991f Mon Sep 17 00:00:00 2001 From: Alex Kontos Date: Mon, 13 May 2024 13:43:57 +0100 Subject: [PATCH] Update Sidebar to 1.0.0.2. * Keep sidebar showing after leaving fullscreen mode. * Respect user's choice about browser.tabs.insertAfterCurrent and browser.tabs.insertRelatedAfterCurrent --- .../browser/components/WaterfoxGlue.sys.mjs | 2 +- .../sidebar/background/handle-new-tabs.js | 5 +++- .../components/sidebar/common/common.js | 4 ++- .../components/sidebar/experiments/prefs.js | 26 +++++++++++++++++++ .../sidebar/experiments/waterfoxBridge.js | 8 +++--- .../browser/components/sidebar/manifest.json | 2 +- .../sidebar/sidebar/styles/base.css | 2 +- 7 files changed, 41 insertions(+), 8 deletions(-) diff --git a/waterfox/browser/components/WaterfoxGlue.sys.mjs b/waterfox/browser/components/WaterfoxGlue.sys.mjs index 3ac2fc8ed826e..98c78bd6c2d84 100644 --- a/waterfox/browser/components/WaterfoxGlue.sys.mjs +++ b/waterfox/browser/components/WaterfoxGlue.sys.mjs @@ -316,7 +316,7 @@ export const WaterfoxGlue = { addon = (await lazy.AddonManager.maybeInstallBuiltinAddon( ID, - "1.0.0.1", + "1.0.0.2", "resource://builtin-addons/sidebar/" )) || addon; diff --git a/waterfox/browser/components/sidebar/background/handle-new-tabs.js b/waterfox/browser/components/sidebar/background/handle-new-tabs.js index 6523baf52a08f..9754075ceebf6 100644 --- a/waterfox/browser/components/sidebar/background/handle-new-tabs.js +++ b/waterfox/browser/components/sidebar/background/handle-new-tabs.js @@ -528,7 +528,10 @@ Tab.onUpdated.addListener((tab, changeInfo) => { const siteMatcher = /^\w+:\/\/([^\/]+)(?:$|\/.*$)/; const openerTabSite = possibleOpenerTab.url.match(siteMatcher); const newTabSite = tab.url.match(siteMatcher); - if (openerTabSite && newTabSite && openerTabSite[1] == newTabSite[1]) { + if (openerTabSite && + newTabSite && + tab.url != possibleOpenerTab.url && // It may be opened by "Duplciate Tab" or "Open in New Container Tab" if the URL is completely same. + openerTabSite[1] == newTabSite[1]) { log('behave as a tab opened from same site (delayed)'); tab.$TST.addState(Constants.kTAB_STATE_OPENED_FOR_SAME_WEBSITE); handleNewTabFromActiveTab(tab, { diff --git a/waterfox/browser/components/sidebar/common/common.js b/waterfox/browser/components/sidebar/common/common.js index 67fed33535374..40119b66c031e 100644 --- a/waterfox/browser/components/sidebar/common/common.js +++ b/waterfox/browser/components/sidebar/common/common.js @@ -34,7 +34,9 @@ const WATERFOX_SPECIFIC_VALUES = { syncParentTabAndOpenerTab: false, // don't attach tabs as children of the active tab by default if possible - autoAttachOnOpenedWithOwner: Constants.kNEWTAB_OPEN_AS_CHILD_NEXT_TO_LAST_RELATED_TAB, + autoAttachOnOpenedWithOwner: Constants.kNEWTAB_DO_NOTHING, + insertNewTabFromPinnedTabAt: Constants.kINSERT_NO_CONTROL, + insertNewTabFromFirefoxViewAt: Constants.kINSERT_NO_CONTROL, autoGroupNewTabsFromPinned: false, autoAttachOnNewTabButtonMiddleClick: Constants.kNEWTAB_OPEN_AS_NEXT_SIBLING, autoAttachSameSiteOrphan: Constants.kNEWTAB_OPEN_AS_NEXT_SIBLING, diff --git a/waterfox/browser/components/sidebar/experiments/prefs.js b/waterfox/browser/components/sidebar/experiments/prefs.js index 6a0678898b81a..7141a13dc7792 100644 --- a/waterfox/browser/components/sidebar/experiments/prefs.js +++ b/waterfox/browser/components/sidebar/experiments/prefs.js @@ -951,6 +951,31 @@ const AboutPreferencesWatcher = { case 'browser.tabs.searchclipboardfor.middleclick': Services.prefs.setBoolPref(`${this.BASE_PREF}middleClickPasteURLOnNewTabButton`, Services.prefs.getBoolPref(name)); break; + + case 'browser.tabs.insertAfterCurrent': + case 'browser.tabs.insertRelatedAfterCurrent': { + const insertAfterCurrent = Services.prefs.getBoolPref('browser.tabs.insertAfterCurrent'); + const insertRelatedAfterCurrent = Services.prefs.getBoolPref('browser.tabs.insertRelatedAfterCurrent'); + const useTree = ( + Services.prefs.getBoolPref(`${this.BASE_PREF}autoAttach`, false) && + Services.prefs.getBoolPref(`${this.BASE_PREF}syncParentTabAndOpenerTab`, false) + ); + Services.prefs.setStringPref(`${this.BASE_PREF}autoAttachOnOpenedWithOwner`, + !useTree ? -1 : + insertRelatedAfterCurrent ? 5 : + insertAfterCurrent ? 6 : + 0); + Services.prefs.setStringPref(`${this.BASE_PREF}insertNewTabFromPinnedTabAt`, + !useTree ? -1 : + insertRelatedAfterCurrent ? 3 : + insertAfterCurrent ? 0 : + 1); + Services.prefs.setStringPref(`${this.BASE_PREF}insertNewTabFromFirefoxViewAt`, + !useTree ? -1 : + insertRelatedAfterCurrent ? 3 : + insertAfterCurrent ? 0 : + 1); + }; break; } }, @@ -1081,6 +1106,7 @@ this.prefs = class extends ExtensionAPI { Services.prefs.setBoolPref(dest, Services.prefs.getBoolPref(source)); } Services.prefs.addObserver('browser.tabs.', AboutPreferencesWatcher); + AboutPreferencesWatcher.onPrefChanged('browser.tabs.insertAfterCurrent'); return { prefs: { diff --git a/waterfox/browser/components/sidebar/experiments/waterfoxBridge.js b/waterfox/browser/components/sidebar/experiments/waterfoxBridge.js index 69cef27a0097f..e7d216415897b 100644 --- a/waterfox/browser/components/sidebar/experiments/waterfoxBridge.js +++ b/waterfox/browser/components/sidebar/experiments/waterfoxBridge.js @@ -781,7 +781,7 @@ const BrowserWindowWatcher = { } } else { - FullScreen.__ws_sidebar.show(); + FullScreen.__ws_sidebar.show({ exitting: true }); FullScreen.__ws_sidebar.cleanup(); } @@ -830,12 +830,14 @@ const BrowserWindowWatcher = { this.startListenToShow(); }, - show() { + show({ exitting } = {}) { sidebarBox.removeAttribute('fullscreenShouldAnimate'); sidebarBox.style.marginLeft = sidebarBox.style.marginRight = ''; this.endListenToShow(); - this.updateMouseTargetRect(); + if (!exitting) { + this.updateMouseTargetRect(); + } }, cleanup() { diff --git a/waterfox/browser/components/sidebar/manifest.json b/waterfox/browser/components/sidebar/manifest.json index c53c93160ee73..f9b486c68365f 100644 --- a/waterfox/browser/components/sidebar/manifest.json +++ b/waterfox/browser/components/sidebar/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "__MSG_extensionName__", - "version": "1.0.0.1", + "version": "1.0.0.2", "author": "Waterfox", "hidden": true, "description": "__MSG_extensionDescription__", diff --git a/waterfox/browser/components/sidebar/sidebar/styles/base.css b/waterfox/browser/components/sidebar/sidebar/styles/base.css index 9b0cd2b2285d6..2328e653a8f75 100644 --- a/waterfox/browser/components/sidebar/sidebar/styles/base.css +++ b/waterfox/browser/components/sidebar/sidebar/styles/base.css @@ -921,7 +921,7 @@ tab-item:not(.collapsed) tab-closebox:active { /* contextual identity (aka Container Tab) */ .contextual-identity-marker { - --contextual-identity-marker-width: calc(var(--tab-current-size) / 12); + --contextual-identity-marker-width: calc(var(--favicon-size) / 5.5); position: absolute; z-index: var(--tab-ui-z-index); }