From 21f0c3de63ffa8a97f526d45363659641f5fc6a7 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Sun, 5 Feb 2023 19:20:02 +0800 Subject: [PATCH] [Pale-Moon] Issue #1908 - Fade tab titles instead of using ellipses --- application/palemoon/app/profile/palemoon.js | 4 ++++ application/palemoon/base/content/browser.css | 10 +++++++++ .../palemoon/base/content/tabbrowser.xml | 22 ++++++++++++++++--- .../components/sessionstore/SessionStore.jsm | 3 +++ 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/application/palemoon/app/profile/palemoon.js b/application/palemoon/app/profile/palemoon.js index bde0a28dff..45f0e9925f 100644 --- a/application/palemoon/app/profile/palemoon.js +++ b/application/palemoon/app/profile/palemoon.js @@ -473,6 +473,10 @@ pref("browser.tabs.delayHidingAudioPlayingIconMS", 3000); // window is enabled. pref("browser.tabs.allowTabDetach", true); +// Whether to fade tab labels instead of using ellipses when cutting off +// long page titles. +pref("browser.tabs.fadeLabels", true); + pref("browser.allTabs.previews", true); pref("browser.allTabs.hidePinnedTabs", false); pref("browser.ctrlTab.previews", true); diff --git a/application/palemoon/base/content/browser.css b/application/palemoon/base/content/browser.css index af15a0e55f..9051d31f1b 100644 --- a/application/palemoon/base/content/browser.css +++ b/application/palemoon/base/content/browser.css @@ -82,6 +82,16 @@ tabbrowser { transition: transform 200ms ease-out; } +@supports -moz-bool-pref("browser.tabs.fadeLabels") { + .tabbrowser-tab .tab-text[_is_cropped] { + mask-image: linear-gradient(to left, transparent, black 2em); + } + + .tabbrowser-tab .tab-text[_is_cropped]:-moz-locale-dir(rtl) { + mask-image: linear-gradient(to right, transparent, black 2em); + } +} + #alltabs-popup { -moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-alltabs-popup"); } diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index f57ea14ab9..6bc5a33ce9 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -1258,7 +1258,11 @@ @@ -1298,6 +1302,10 @@ title = this.mStringBundle.getString("tabs.emptyTabTitle"); } + if (Services.prefs.getBoolPref("browser.tabs.fadeLabels")) { + crop = "clip"; + } + if (aTab.label == title && aTab.crop == crop) return false; @@ -1521,7 +1529,11 @@ else t.setAttribute("label", aURI); - t.setAttribute("crop", "end"); + if (Services.prefs.getBoolPref("browser.tabs.fadeLabels")) { + t.setAttribute("crop", "clip"); + } else { + t.setAttribute("crop", "end"); + } t.setAttribute("validate", "never"); //PMed t.setAttribute("onerror", "this.removeAttribute('image');"); @@ -3602,7 +3614,11 @@ var tab = this.firstChild; tab.setAttribute("label", this.tabbrowser.mStringBundle.getString("tabs.emptyTabTitle")); - tab.setAttribute("crop", "end"); + if (Services.prefs.getBoolPref("browser.tabs.fadeLabels")) { + tab.setAttribute("crop", "clip"); + } else { + tab.setAttribute("crop", "end"); + } tab.setAttribute("onerror", "this.removeAttribute('image');"); this.adjustTabstrip(); diff --git a/application/palemoon/components/sessionstore/SessionStore.jsm b/application/palemoon/components/sessionstore/SessionStore.jsm index 084af92240..3609037d93 100644 --- a/application/palemoon/components/sessionstore/SessionStore.jsm +++ b/application/palemoon/components/sessionstore/SessionStore.jsm @@ -3045,6 +3045,9 @@ var SessionStoreInternal = { tab.label = activePageData.url; tab.crop = "center"; } + if (this._prefBranch.getBoolPref("tabs.fadeLabels")) { + tab.crop = "clip"; + } } }