Bug 1707590 - Part 4: Add image/jxl to Accept header and DownloadsViewableInternally r=necko-reviewers,dragana

Depends on D113360

Differential Revision: https://phabricator.services.mozilla.com/D113688
This commit is contained in:
Kagami Sascha Rosylight 2021-05-06 02:00:58 +00:00
Родитель cd4260e05a
Коммит 20c1c01092
4 изменённых файлов: 22 добавлений и 1 удалений

Просмотреть файл

@ -452,7 +452,7 @@ pref("browser.download.alwaysOpenInSystemViewerContextMenuItem", true);
// Open downloaded file types internally for the given types. // Open downloaded file types internally for the given types.
// This is a comma-separated list, the empty string ("") means no types are // This is a comma-separated list, the empty string ("") means no types are
// viewable internally. // viewable internally.
pref("browser.download.viewableInternally.enabledTypes", "xml,svg,webp,avif"); pref("browser.download.viewableInternally.enabledTypes", "xml,svg,webp,avif,jxl");
// This controls whether the button is automatically shown/hidden depending // This controls whether the button is automatically shown/hidden depending

Просмотреть файл

@ -161,6 +161,20 @@ let DownloadsViewableInternally = {
}, },
// available getter is set by initAvailable() // available getter is set by initAvailable()
}, },
{
extension: "jxl",
mimeTypes: ["image/jxl"],
initAvailable() {
XPCOMUtils.defineLazyPreferenceGetter(
this,
"available",
"image.jxl.enabled",
false,
() => DownloadsViewableInternally._updateHandler(this)
);
},
// available getter is set by initAvailable()
},
{ {
extension: "pdf", extension: "pdf",
mimeTypes: ["application/pdf"], mimeTypes: ["application/pdf"],

Просмотреть файл

@ -50,6 +50,7 @@ function expectedImageAcceptHeader() {
return ( return (
(Services.prefs.getBoolPref("image.avif.enabled") ? "image/avif," : "") + (Services.prefs.getBoolPref("image.avif.enabled") ? "image/avif," : "") +
(Services.prefs.getBoolPref("image.jxl.enabled") ? "image/jxl," : "") +
(Services.prefs.getBoolPref("image.webp.enabled") ? "image/webp," : "") + (Services.prefs.getBoolPref("image.webp.enabled") ? "image/webp," : "") +
"*/*" "*/*"
); );

Просмотреть файл

@ -188,6 +188,10 @@ static nsCString ImageAcceptHeader() {
mimeTypes.Append("image/avif,"); mimeTypes.Append("image/avif,");
} }
if (mozilla::StaticPrefs::image_jxl_enabled()) {
mimeTypes.Append("image/jxl,");
}
if (mozilla::StaticPrefs::image_webp_enabled()) { if (mozilla::StaticPrefs::image_webp_enabled()) {
mimeTypes.Append("image/webp,"); mimeTypes.Append("image/webp,");
} }
@ -355,6 +359,7 @@ static const char* gCallbackPrefs[] = {
DOM_SECURITY_PREFIX, DOM_SECURITY_PREFIX,
"image.http.accept", "image.http.accept",
"image.avif.enabled", "image.avif.enabled",
"image.jxl.enabled",
"image.webp.enabled", "image.webp.enabled",
nullptr, nullptr,
}; };
@ -1831,6 +1836,7 @@ void nsHttpHandler::PrefsChanged(const char* pref) {
const bool imageAcceptPrefChanged = PREF_CHANGED("image.http.accept") || const bool imageAcceptPrefChanged = PREF_CHANGED("image.http.accept") ||
PREF_CHANGED("image.avif.enabled") || PREF_CHANGED("image.avif.enabled") ||
PREF_CHANGED("image.jxl.enabled") ||
PREF_CHANGED("image.webp.enabled"); PREF_CHANGED("image.webp.enabled");
if (imageAcceptPrefChanged) { if (imageAcceptPrefChanged) {