[Basilisk] ported PM version of tab caption fading to here

This commit is contained in:
roytam1 2023-03-09 16:31:24 +08:00
commit 2a32b18f46
4 changed files with 36 additions and 3 deletions

View file

@ -418,6 +418,10 @@ pref("browser.tabs.dontfocusfordialogs", true);
// 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.ctrlTab.previews", false);
// By default, do not export HTML at shutdown.

View file

@ -187,6 +187,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);
}
}
.new-tab-popup,
#alltabs-popup {
-moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-alltabs-popup");

View file

@ -1400,7 +1400,11 @@
<body>
<![CDATA[
aTab.label = this.mStringBundle.getString("tabs.connecting");
aTab.crop = "end";
if (Services.prefs.getBoolPref("browser.tabs.fadeLabels")) {
aTab.crop = "clip";
} else {
aTab.crop = "end";
}
this._tabAttrModified(aTab, ["label", "crop"]);
]]>
</body>
@ -1445,6 +1449,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;
@ -2151,7 +2159,11 @@
ContextualIdentityService.setTabStyle(t);
}
t.setAttribute("crop", "end");
if (Services.prefs.getBoolPref("browser.tabs.fadeLabels")) {
t.setAttribute("crop", "clip");
} else {
t.setAttribute("crop", "end");
}
t.setAttribute("onerror", "this.removeAttribute('image');");
if (aSkipBackgroundNotify) {
@ -5243,7 +5255,11 @@
var tab = this.firstChild;
tab.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');");
window.addEventListener("resize", this, false);

View file

@ -849,6 +849,9 @@ var SessionStoreInternal = {
tab.label = activePageData.url;
tab.crop = "center";
}
if (this._prefBranch.getBoolPref("tabs.fadeLabels")) {
tab.crop = "clip";
}
} else if (tab.hasAttribute("customizemode")) {
win.gCustomizeMode.setTab(tab);
}