Subject: [PATCH 2/2] Bug 1539075 - Register .jxl extension in Firefox. r?tnikkel,saschanaz

From: Robert-André Mauchin <[email-masked]>
Date: Fri, 10 May 2024 16:18:12 +0200

---
 browser/components/BrowserContentHandler.sys.mjs           | 1 +
 browser/installer/windows/msix/AppxManifest.xml.in         | 1 +
 browser/installer/windows/nsis/shared.nsh                  | 7 ++++++-
 browser/installer/windows/nsis/uninstaller.nsi             | 1 +
 third_party/rust/mime_guess/src/mime_types.rs              | 6 ++++++
 toolkit/components/downloads/DownloadList.sys.mjs          | 1 +
 toolkit/components/extensions/parent/ext-downloads.js      | 2 ++
 toolkit/content/filepicker.properties                      | 2 +-
 .../chrome/mozapps/downloads/unknownContentType.properties | 1 +
 widget/gtk/nsAppShell.cpp                                  | 5 +++++
 14 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/browser/components/BrowserContentHandler.sys.mjs b/browser/components/BrowserContentHandler.sys.mjs
index 6c156d170069b..8133cb28cb37c 100644
--- a/browser/components/BrowserContentHandler.sys.mjs
+++ b/browser/components/BrowserContentHandler.sys.mjs
@@ -1174,6 +1174,7 @@ function maybeRecordToHandleTelemetry(ur
       ".avif",
       ".htm",
       ".html",
+      ".jxl",
       ".pdf",
       ".shtml",
       ".xht",
diff --git a/browser/installer/windows/msix/AppxManifest.xml.in b/browser/installer/windows/msix/AppxManifest.xml.in
index 2e11b5d34bf03..68d40ec4735c2 100644
--- a/browser/installer/windows/msix/AppxManifest.xml.in
+++ b/browser/installer/windows/msix/AppxManifest.xml.in
@@ -60,6 +60,7 @@
               <uap:FileType>.avif</uap:FileType>
               <uap:FileType>.htm</uap:FileType>
               <uap:FileType>.html</uap:FileType>
+              <uap:FileType>.jxl</uap:FileType>
               <uap:FileType>.pdf</uap:FileType>
               <uap:FileType>.shtml</uap:FileType>
               <uap:FileType>.xht</uap:FileType>
diff --git a/browser/installer/windows/nsis/shared.nsh b/browser/installer/windows/nsis/shared.nsh
index ccad601abeee8..0c7488417423a 100755
--- a/browser/installer/windows/nsis/shared.nsh
+++ b/browser/installer/windows/nsis/shared.nsh
@@ -505,6 +505,7 @@ ${RemoveDefaultBrowserAgentShortcut}
   ${AddAssociationIfNoneExist} ".svg" "FirefoxHTML$5"
   ${AddAssociationIfNoneExist} ".webp"  "FirefoxHTML$5"
   ${AddAssociationIfNoneExist} ".avif" "FirefoxHTML$5"
+  ${AddAssociationIfNoneExist} ".jxl" "FirefoxHTML$5"
 
   ${AddAssociationIfNoneExist} ".pdf" "FirefoxPDF$5"
 
@@ -601,6 +602,7 @@ ${RemoveDefaultBrowserAgentShortcut}
   WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".svg"   "FirefoxHTML$2"
   WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".webp"  "FirefoxHTML$2"
   WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".avif"  "FirefoxHTML$2"
+  WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".jxl"  "FirefoxHTML$2"
 
   WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".pdf"   "FirefoxPDF$2"
 
@@ -647,6 +649,7 @@ ${RemoveDefaultBrowserAgentShortcut}
     ; in Firefox, basically meaning that plain text file types were left out,
     ; but not JSON or XML types because we have specific viewers for those.
     ${WriteApplicationsSupportedType} ${RegKey} ".apng"
+    ${WriteApplicationsSupportedType} ${RegKey} ".avif"
     ${WriteApplicationsSupportedType} ${RegKey} ".bmp"
     ${WriteApplicationsSupportedType} ${RegKey} ".flac"
     ${WriteApplicationsSupportedType} ${RegKey} ".gif"
@@ -657,6 +660,7 @@ ${RemoveDefaultBrowserAgentShortcut}
     ${WriteApplicationsSupportedType} ${RegKey} ".jpeg"
     ${WriteApplicationsSupportedType} ${RegKey} ".jpg"
     ${WriteApplicationsSupportedType} ${RegKey} ".json"
+    ${WriteApplicationsSupportedType} ${RegKey} ".jxl"
     ${WriteApplicationsSupportedType} ${RegKey} ".m4a"
     ${WriteApplicationsSupportedType} ${RegKey} ".mp3"
     ${WriteApplicationsSupportedType} ${RegKey} ".oga"
@@ -672,7 +676,6 @@ ${RemoveDefaultBrowserAgentShortcut}
     ${WriteApplicationsSupportedType} ${RegKey} ".svg"
     ${WriteApplicationsSupportedType} ${RegKey} ".webm"
     ${WriteApplicationsSupportedType} ${RegKey} ".webp"
-    ${WriteApplicationsSupportedType} ${RegKey} ".avif"
     ${WriteApplicationsSupportedType} ${RegKey} ".xht"
     ${WriteApplicationsSupportedType} ${RegKey} ".xhtml"
     ${WriteApplicationsSupportedType} ${RegKey} ".xml"
@@ -1717,6 +1720,8 @@ Function SetAsDefaultAppUserHKCU
     Pop $0
     AppAssocReg::SetAppAsDefault "$R9" ".avif" "file"
     Pop $0
+    AppAssocReg::SetAppAsDefault "$R9" ".jxl" "file"
+    Pop $0
     AppAssocReg::SetAppAsDefault "$R9" ".xht" "file"
     Pop $0
     AppAssocReg::SetAppAsDefault "$R9" ".xhtml" "file"
diff --git a/browser/installer/windows/nsis/uninstaller.nsi b/browser/installer/windows/nsis/uninstaller.nsi
index 31bd9920474e0..680f1ec07b796 100755
--- a/browser/installer/windows/nsis/uninstaller.nsi
+++ b/browser/installer/windows/nsis/uninstaller.nsi
@@ -504,6 +504,7 @@ Section "Uninstall"
   ${un.RegCleanFileHandler}  ".svg"   "FirefoxHTML-$AppUserModelID"
   ${un.RegCleanFileHandler}  ".webp"  "FirefoxHTML-$AppUserModelID"
   ${un.RegCleanFileHandler}  ".avif"  "FirefoxHTML-$AppUserModelID"
+  ${un.RegCleanFileHandler}  ".jxl"   "FirefoxHTML-$AppUserModelID"
 
   ${un.RegCleanFileHandler}  ".pdf"   "FirefoxPDF-$AppUserModelID"
 
diff --git a/third_party/rust/mime_guess/src/mime_types.rs b/third_party/rust/mime_guess/src/mime_types.rs
index 13c91b7bee77a..1521cd729ec78 100644
--- a/third_party/rust/mime_guess/src/mime_types.rs
+++ b/third_party/rust/mime_guess/src/mime_types.rs
@@ -103,6 +103,7 @@ pub static MIME_TYPES: &[(&str, &[&str])
     ("au", &["audio/basic"]),
     ("avi", &["video/x-msvideo"]),
     ("avif", &["image/avif"]),
+    ("avifs", &["image/avif-sequence"]),
     ("aw", &["application/applixware"]),
     ("axa", &["audio/annodex"]),
     ("axs", &["application/olescript"]),
@@ -449,6 +450,10 @@ pub static MIME_TYPES: &[(&str, &[&str])
     ("hdf", &["application/x-hdf"]),
     ("hdml", &["text/x-hdml"]),
     ("hdr", &["image/vnd.radiance"]),
+    ("heic", &["image/heic"]),
+    ("heics", &["image/heic-sequence"]),
+    ("heif", &["image/heif"]),
+    ("heifs", &["image/heif-sequence"]),
     ("hh", &["text/plain"]),
     ("hhc", &["application/x-oleobject"]),
     ("hhk", &["application/octet-stream"]),
@@ -567,6 +572,7 @@ pub static MIME_TYPES: &[(&str, &[&str])
     ("jsonml", &["application/jsonml+json"]),
     ("jsx", &["text/jscript"]),
     ("jsxbin", &["text/plain"]),
+    ("jxl", &["image/jxl"]),
     ("kar", &["audio/midi"]),
     ("karbon", &["application/vnd.kde.karbon"]),
     ("kfo", &["application/vnd.kde.kformula"]),
diff --git a/toolkit/components/downloads/DownloadList.sys.mjs b/toolkit/components/downloads/DownloadList.sys.mjs
index b042ca20e97e2..550df53ec0aa4 100644
--- a/toolkit/components/downloads/DownloadList.sys.mjs
+++ b/toolkit/components/downloads/DownloadList.sys.mjs
@@ -50,6 +50,7 @@ const FILE_EXTENSIONS = [
   "jpg",
   "jpeg",
   "json",
+  "jxl",
   "m4a",
   "mdb",
   "mid",
diff --git a/toolkit/components/extensions/parent/ext-downloads.js b/toolkit/components/extensions/parent/ext-downloads.js
index 02af2d1076dbf..0f0a3e9df7c1c 100644
--- a/toolkit/components/extensions/parent/ext-downloads.js
+++ b/toolkit/components/extensions/parent/ext-downloads.js
@@ -104,6 +104,8 @@ const FILTER_IMAGES_EXTENSIONS = [
   "raw",
   "webp",
   "heic",
+  "avif",
+  "jxl",
 ];
 
 const FILTER_XML_EXTENSIONS = ["xml"];
diff --git a/toolkit/content/filepicker.properties b/toolkit/content/filepicker.properties
index 03daec114c288..b6bd09c3c5625 100644
--- a/toolkit/content/filepicker.properties
+++ b/toolkit/content/filepicker.properties
@@ -5,7 +5,7 @@
 allFilter=*
 htmlFilter=*.html; *.htm; *.shtml; *.xhtml
 textFilter=*.txt; *.text
-imageFilter=*.jpe; *.jpg; *.jpeg; *.gif; *.png; *.bmp; *.ico; *.svg; *.svgz; *.tif; *.tiff; *.ai; *.drw; *.pct; *.psp; *.xcf; *.psd; *.raw; *.webp; *.heic
+imageFilter=*.jpe; *.jpg; *.jpeg; *.gif; *.png; *.bmp; *.ico; *.svg; *.svgz; *.tif; *.tiff; *.ai; *.drw; *.pct; *.psp; *.xcf; *.psd; *.raw; *.webp; *.heic; *.avif; *.jxl
 xmlFilter=*.xml
 xulFilter=*.xul
 audioFilter=*.aac; *.aif; *.flac; *.iff; *.m4a; *.m4b; *.mid; *.midi; *.mp3; *.mpa; *.mpc; *.oga; *.ogg; *.opus; *.ra; *.ram; *.snd; *.wav; *.wma
diff --git a/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties b/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties
index fa3c5e389bad5..1bb1f48c4d396 100644
--- a/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties
+++ b/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties
@@ -17,6 +17,7 @@ fileType=%S file
 # LOCALIZATION NOTE (orderedFileSizeWithType): first %S is type, second %S is size, and third %S is unit
 orderedFileSizeWithType=%1$S (%2$S %3$S)
 avifExtHandlerDescription=AV1 Image File (AVIF)
+jxlExtHandlerDescription=JPEG XL Image (JXL)
 pdfExtHandlerDescription=Portable Document Format (PDF)
 svgExtHandlerDescription=Scalable Vector Graphics (SVG)
 webpExtHandlerDescription=WebP Image
diff --git a/widget/gtk/nsAppShell.cpp b/widget/gtk/nsAppShell.cpp
index 652801fe696f1..08a3c45aa170d 100644
--- a/widget/gtk/nsAppShell.cpp
+++ b/widget/gtk/nsAppShell.cpp
@@ -419,7 +419,12 @@ nsresult nsAppShell::Init() {
     gchar* name = gdk_pixbuf_format_get_name(format);
     if (strcmp(name, "jpeg") && strcmp(name, "png") && strcmp(name, "gif") &&
         strcmp(name, "bmp") && strcmp(name, "ico") && strcmp(name, "xpm") &&
+#ifdef MOZ_JXL
+        strcmp(name, "svg") && strcmp(name, "webp") && strcmp(name, "avif") &&
+        strcmp(name, "jxl")) {
+#else
         strcmp(name, "svg") && strcmp(name, "webp") && strcmp(name, "avif")) {
+#endif
       gdk_pixbuf_format_set_disabled(format, TRUE);
     }
     g_free(name);
-- 
2.44.0