commit b6ff77e3016b86a7fe71aea9e0c38691653f3375
parent caec489295d615e24e0fe997b66965175f8f0b1a
Author: Joe Cardoso <jow13_122@yahoo.com>
Date: Wed, 3 Dec 2025 13:07:44 +0000
Bug 1897620 - Remove image.avif.enabled pref r=necko-reviewers,jesup,tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D271784
Diffstat:
10 files changed, 36 insertions(+), 48 deletions(-)
diff --git a/browser/components/downloads/DownloadsViewableInternally.sys.mjs b/browser/components/downloads/DownloadsViewableInternally.sys.mjs
@@ -132,16 +132,8 @@ export let DownloadsViewableInternally = {
{
extension: "avif",
mimeTypes: ["image/avif"],
- initAvailable() {
- XPCOMUtils.defineLazyPreferenceGetter(
- this,
- "available",
- "image.avif.enabled",
- false,
- () => DownloadsViewableInternally._updateHandler(this)
- );
- },
- // available getter is set by initAvailable()
+ available: true,
+ managedElsewhere: false,
},
{
extension: "jxl",
diff --git a/browser/components/downloads/test/unit/test_DownloadsViewableInternally.js b/browser/components/downloads/test/unit/test_DownloadsViewableInternally.js
@@ -2,7 +2,6 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
const PREF_SVG_DISABLED = "svg.disabled";
-const PREF_AVIF_ENABLED = "image.avif.enabled";
const PDF_MIME = "application/pdf";
const OCTET_MIME = "application/octet-stream";
const XML_MIME = "text/xml";
@@ -82,7 +81,6 @@ function checkAll(mime, ext, expected) {
add_task(async function test_viewable_internally() {
Services.prefs.setCharPref(PREF_ENABLED_TYPES, "xml , svg,avif");
Services.prefs.setBoolPref(PREF_SVG_DISABLED, false);
- Services.prefs.setBoolPref(PREF_AVIF_ENABLED, true);
checkAll(XML_MIME, "xml", false);
checkAll(SVG_MIME, "svg", false);
diff --git a/dom/tests/browser/browser_persist_image_accept.js b/dom/tests/browser/browser_persist_image_accept.js
@@ -48,11 +48,23 @@ function expectedImageAcceptHeader() {
return Services.prefs.getCharPref("image.http.accept");
}
- return (
- (Services.prefs.getBoolPref("image.avif.enabled") ? "image/avif," : "") +
- (Services.prefs.getBoolPref("image.jxl.enabled") ? "image/jxl," : "") +
- "image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5"
- );
+ let header = "";
+
+ // Check if AVIF is supported (compiled with MOZ_AV1)
+ try {
+ Services.catMan.getCategoryEntry("Gecko-Content-Viewers", "image/avif");
+ header += "image/avif,";
+ } catch (e) {
+ // AVIF not registered, skip it
+ }
+
+ if (Services.prefs.getBoolPref("image.jxl.enabled")) {
+ header += "image/jxl,";
+ }
+
+ header += "image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5";
+
+ return header;
}
add_task(async function test_image_download() {
diff --git a/image/DecoderFactory.cpp b/image/DecoderFactory.cpp
@@ -88,8 +88,7 @@ DecoderType DecoderFactory::GetDecoderType(const char* aMimeType) {
// AVIF
}
#ifdef MOZ_AV1
- else if (!strcmp(aMimeType, IMAGE_AVIF) &&
- StaticPrefs::image_avif_enabled()) {
+ else if (!strcmp(aMimeType, IMAGE_AVIF)) {
type = DecoderType::AVIF;
}
#endif
diff --git a/image/build/nsImageModule.cpp b/image/build/nsImageModule.cpp
@@ -56,13 +56,9 @@ nsresult mozilla::image::EnsureModuleInitialized() {
return NS_OK;
}
- static ImageEnablementCookie kAVIFCookie = {
- mozilla::StaticPrefs::image_avif_enabled, "image/avif"_ns};
static ImageEnablementCookie kJXLCookie = {
mozilla::StaticPrefs::image_jxl_enabled, "image/jxl"_ns};
Preferences::RegisterCallbackAndCall(UpdateDocumentViewerRegistration,
- "image.avif.enabled", &kAVIFCookie);
- Preferences::RegisterCallbackAndCall(UpdateDocumentViewerRegistration,
"image.jxl.enabled", &kJXLCookie);
mozilla::image::ShutdownTracker::Initialize();
diff --git a/image/test/gtest/Common.cpp b/image/test/gtest/Common.cpp
@@ -39,10 +39,8 @@ AutoInitializeImageLib::AutoInitializeImageLib() {
EXPECT_TRUE(NS_IsMainThread());
sImageLibInitialized = true;
- // Ensure AVIF is enabled to run decoder tests.
- nsresult rv = Preferences::SetBool("image.avif.enabled", true);
- EXPECT_TRUE(rv == NS_OK);
- rv = Preferences::SetBool("image.avif.sequence.enabled", true);
+ // Ensure AVIF sequence is enabled to run decoder tests.
+ nsresult rv = Preferences::SetBool("image.avif.sequence.enabled", true);
EXPECT_TRUE(rv == NS_OK);
#ifdef MOZ_JXL
diff --git a/image/test/reftest/avif/reftest.list b/image/test/reftest/avif/reftest.list
@@ -1,4 +1,4 @@
-defaults pref(image.avif.enabled,true) pref(image.avif.apply_transforms,true)
+defaults pref(image.avif.apply_transforms,true)
== img_irot0_imir1.avif 2-flipped-horizontally.avif
== img_irot0_imir0.avif 4-flipped-vertically.avif
diff --git a/layout/build/components.conf b/layout/build/components.conf
@@ -42,6 +42,11 @@ content_types = [
'image/x-png',
]
+if defined('MOZ_AV1'):
+ content_types += [
+ 'image/avif',
+ ]
+
if defined('MOZ_WEBM'):
content_types += [
"audio/webm",
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
@@ -8487,16 +8487,6 @@
value: true
mirror: always
-# Whether we attempt to decode AVIF images or not.
-- name: image.avif.enabled
- type: RelaxedAtomicBool
-#if defined(MOZ_AV1)
- value: true
-#else
- value: false
-#endif
- mirror: always
-
# How strict we are in accepting/rejecting AVIF inputs according to whether they
# conform to the specification
# 0 = Permissive: accept whatever we can simply, unambiguously interpret
diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -214,9 +214,9 @@ already_AddRefed<nsHttpHandler> nsHttpHandler::GetInstance() {
static nsCString ImageAcceptHeader() {
nsCString mimeTypes;
- if (mozilla::StaticPrefs::image_avif_enabled()) {
- mimeTypes.Append("image/avif,");
- }
+#ifdef MOZ_AV1
+ mimeTypes.Append("image/avif,");
+#endif
if (mozilla::StaticPrefs::image_jxl_enabled()) {
mimeTypes.Append("image/jxl,");
@@ -239,9 +239,9 @@ static nsCString DocumentAcceptHeader() {
// we also insert all of the image formats before */* when the pref is set
if (mozilla::StaticPrefs::network_http_accept_include_images()) {
- if (mozilla::StaticPrefs::image_avif_enabled()) {
- mimeTypes.Append("image/avif,");
- }
+#ifdef MOZ_AV1
+ mimeTypes.Append("image/avif,");
+#endif
if (mozilla::StaticPrefs::image_jxl_enabled()) {
mimeTypes.Append("image/jxl,");
@@ -321,7 +321,6 @@ static const char* gCallbackPrefs[] = {
SECURITY_PREFIX,
DOM_SECURITY_PREFIX,
"image.http.accept",
- "image.avif.enabled",
"image.jxl.enabled",
nullptr,
};
@@ -1936,9 +1935,8 @@ void nsHttpHandler::PrefsChanged(const char* pref) {
}
}
- const bool imageAcceptPrefChanged = PREF_CHANGED("image.http.accept") ||
- PREF_CHANGED("image.avif.enabled") ||
- PREF_CHANGED("image.jxl.enabled");
+ const bool imageAcceptPrefChanged =
+ PREF_CHANGED("image.http.accept") || PREF_CHANGED("image.jxl.enabled");
if (imageAcceptPrefChanged) {
nsAutoCString userSetImageAcceptHeader;