From 308e670b46ac27a4b41bd4f27dc14a9087adf07c Mon Sep 17 00:00:00 2001 From: noaione Date: Sun, 23 Feb 2025 22:21:25 +0700 Subject: [PATCH] Recognizes `.jxl` as a proper image type Based on: https://src.fedoraproject.org/fork/eclipseo/rpms/firefox/blob/90702891fefc97ff9e347dbab0091136822a0f3b/f/0002-Bug-1539075-Register-.jxl-extension-in-Firefox.-r-tn.patch --- src/Cargo-lock.patch | 13 ++++++ src/Cargo-toml.patch | 14 ++++++ .../BrowserContentHandler-sys-mjs.patch | 12 +++++ .../windows/msix/AppxManifest-xml-in.patch | 12 +++++ .../installer/windows/nsis/shared-nsh.patch | 46 +++++++++++++++++++ .../windows/nsis/uninstaller-nsi.patch | 12 +++++ .../rust/mime_guess/src/mime_types-rs.patch | 31 +++++++++++++ .../downloads/DownloadList-sys-mjs.patch | 12 +++++ .../extensions/parent/ext-downloads-js.patch | 20 ++++++++ .../pdfjs/content/build/pdf-mjs.patch | 37 +++++++++++++++ .../content/filepicker-properties.patch | 13 ++++++ .../unknownContentType-properties.patch | 12 +++++ src/widget/gtk/nsAppShell-cpp.patch | 14 ++++++ 13 files changed, 248 insertions(+) create mode 100644 src/Cargo-lock.patch create mode 100644 src/Cargo-toml.patch create mode 100644 src/browser/components/BrowserContentHandler-sys-mjs.patch create mode 100644 src/browser/installer/windows/msix/AppxManifest-xml-in.patch create mode 100644 src/browser/installer/windows/nsis/shared-nsh.patch create mode 100644 src/browser/installer/windows/nsis/uninstaller-nsi.patch create mode 100644 src/third_party/rust/mime_guess/src/mime_types-rs.patch create mode 100644 src/toolkit/components/downloads/DownloadList-sys-mjs.patch create mode 100644 src/toolkit/components/extensions/parent/ext-downloads-js.patch create mode 100644 src/toolkit/components/pdfjs/content/build/pdf-mjs.patch create mode 100644 src/toolkit/content/filepicker-properties.patch create mode 100644 src/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType-properties.patch create mode 100644 src/widget/gtk/nsAppShell-cpp.patch diff --git a/src/Cargo-lock.patch b/src/Cargo-lock.patch new file mode 100644 index 000000000..fe2a60421 --- /dev/null +++ b/src/Cargo-lock.patch @@ -0,0 +1,13 @@ +diff --git a/Cargo.lock b/Cargo.lock +index 0609d96f01ded85dccf2c931d3c553be61432e6a..8ce4374dd31b4ce818c8bb548fbfb2669014b05b 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -3919,8 +3919,6 @@ dependencies = [ + [[package]] + name = "mime_guess" + version = "2.0.4" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" + dependencies = [ + "mime", + "unicase", diff --git a/src/Cargo-toml.patch b/src/Cargo-toml.patch new file mode 100644 index 000000000..298cb4263 --- /dev/null +++ b/src/Cargo-toml.patch @@ -0,0 +1,14 @@ +diff --git a/Cargo.toml b/Cargo.toml +index 29942b65f62497b80d63675501ae063c393943a7..a9aa4641421038fbe5b0ecd9b7353611eecefffe 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -198,6 +198,9 @@ rure = { path = "third_party/rust/rure" } + # Patch `plist` to work with `indexmap` 2.* + plist = { path = "third_party/rust/plist" } + ++# Patch mime_guess to add missing mime types ++mime_guess = { path = "third_party/rust/mime_guess" } ++ + # To-be-published changes. + unicode-bidi = { git = "https://github.com/servo/unicode-bidi", rev = "ca612daf1c08c53abe07327cb3e6ef6e0a760f0c" } + nss-gk-api = { git = "https://github.com/beurdouche/nss-gk-api", rev = "e48a946811ffd64abc78de3ee284957d8d1c0d63" } diff --git a/src/browser/components/BrowserContentHandler-sys-mjs.patch b/src/browser/components/BrowserContentHandler-sys-mjs.patch new file mode 100644 index 000000000..b69095199 --- /dev/null +++ b/src/browser/components/BrowserContentHandler-sys-mjs.patch @@ -0,0 +1,12 @@ +diff --git a/browser/components/BrowserContentHandler.sys.mjs b/browser/components/BrowserContentHandler.sys.mjs +index 7aef091c0be1cb0ea0be52268949db17032f96d9..5e9105fa671d1b1979f204fc8d3be22771998ad7 100644 +--- a/browser/components/BrowserContentHandler.sys.mjs ++++ b/browser/components/BrowserContentHandler.sys.mjs +@@ -1278,6 +1278,7 @@ function maybeRecordToHandleTelemetry(uri, isLaunch) { + ".avif", + ".htm", + ".html", ++ ".jxl", + ".pdf", + ".shtml", + ".xht", diff --git a/src/browser/installer/windows/msix/AppxManifest-xml-in.patch b/src/browser/installer/windows/msix/AppxManifest-xml-in.patch new file mode 100644 index 000000000..1c638f2df --- /dev/null +++ b/src/browser/installer/windows/msix/AppxManifest-xml-in.patch @@ -0,0 +1,12 @@ +diff --git a/browser/installer/windows/msix/AppxManifest.xml.in b/browser/installer/windows/msix/AppxManifest.xml.in +index b81a73518a183b7b1d178793886c66f44651058d..89690a4177229b70013bcf35ec1d805fff7e1b26 100644 +--- a/browser/installer/windows/msix/AppxManifest.xml.in ++++ b/browser/installer/windows/msix/AppxManifest.xml.in +@@ -61,6 +61,7 @@ + .avif + .htm + .html ++ .jxl + .pdf + .shtml + .xht diff --git a/src/browser/installer/windows/nsis/shared-nsh.patch b/src/browser/installer/windows/nsis/shared-nsh.patch new file mode 100644 index 000000000..f8da06cfe --- /dev/null +++ b/src/browser/installer/windows/nsis/shared-nsh.patch @@ -0,0 +1,46 @@ +diff --git a/browser/installer/windows/nsis/shared.nsh b/browser/installer/windows/nsis/shared.nsh +index b7f8e1453089ab5f1945e1a65f038e17b5273571..5297f5ed70fe3446e55be37df486fb4ad791a446 100644 +--- a/browser/installer/windows/nsis/shared.nsh ++++ b/browser/installer/windows/nsis/shared.nsh +@@ -513,6 +513,7 @@ ${RemoveDefaultBrowserAgentShortcut} + ${AddAssociationIfNoneExist} ".svg" "FirefoxHTML$5" + ${AddAssociationIfNoneExist} ".webp" "FirefoxHTML$5" + ${AddAssociationIfNoneExist} ".avif" "FirefoxHTML$5" ++ ${AddAssociationIfNoneExist} ".jxl" "FirefoxHTML$5" + + ${AddAssociationIfNoneExist} ".pdf" "FirefoxPDF$5" + +@@ -609,6 +610,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" + +@@ -681,6 +683,7 @@ ${RemoveDefaultBrowserAgentShortcut} + ${WriteApplicationsSupportedType} ${RegKey} ".webm" + ${WriteApplicationsSupportedType} ${RegKey} ".webp" + ${WriteApplicationsSupportedType} ${RegKey} ".avif" ++ ${WriteApplicationsSupportedType} ${RegKey} ".jxl" + ${WriteApplicationsSupportedType} ${RegKey} ".xht" + ${WriteApplicationsSupportedType} ${RegKey} ".xhtml" + ${WriteApplicationsSupportedType} ${RegKey} ".xml" +@@ -1728,6 +1731,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" +@@ -1857,7 +1862,7 @@ FunctionEnd + ; uninstalled. + + ; Do all of that twice, once for the local machine and once for the current user +- ++ + ; Remove protocol handlers + ClearErrors + ReadRegStr $0 HKLM "Software\Classes\${_PROTOCOL}\DefaultIcon" "" diff --git a/src/browser/installer/windows/nsis/uninstaller-nsi.patch b/src/browser/installer/windows/nsis/uninstaller-nsi.patch new file mode 100644 index 000000000..b2de9cb9a --- /dev/null +++ b/src/browser/installer/windows/nsis/uninstaller-nsi.patch @@ -0,0 +1,12 @@ +diff --git a/browser/installer/windows/nsis/uninstaller.nsi b/browser/installer/windows/nsis/uninstaller.nsi +index 559c8b46ee06bc42c91da49b5d9e397fe8ff6126..62094a5d98712a41a607ba01ca2adfa1e4f51ccd 100644 +--- a/browser/installer/windows/nsis/uninstaller.nsi ++++ b/browser/installer/windows/nsis/uninstaller.nsi +@@ -507,6 +507,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/src/third_party/rust/mime_guess/src/mime_types-rs.patch b/src/third_party/rust/mime_guess/src/mime_types-rs.patch new file mode 100644 index 000000000..9568fa141 --- /dev/null +++ b/src/third_party/rust/mime_guess/src/mime_types-rs.patch @@ -0,0 +1,31 @@ +diff --git a/third_party/rust/mime_guess/src/mime_types.rs b/third_party/rust/mime_guess/src/mime_types.rs +index 13c91b7bee77a0c0a4b45b8e05a25bb89daac66e..1521cd729ec78dbc51b86cf04546c4cd4ceb1163 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/src/toolkit/components/downloads/DownloadList-sys-mjs.patch b/src/toolkit/components/downloads/DownloadList-sys-mjs.patch new file mode 100644 index 000000000..f27368c52 --- /dev/null +++ b/src/toolkit/components/downloads/DownloadList-sys-mjs.patch @@ -0,0 +1,12 @@ +diff --git a/toolkit/components/downloads/DownloadList.sys.mjs b/toolkit/components/downloads/DownloadList.sys.mjs +index c4e5776940c4cdca731a82ba91d41620c4c7b75a..d580d193bda5e932cebc849c4487de504f17b6fe 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/src/toolkit/components/extensions/parent/ext-downloads-js.patch b/src/toolkit/components/extensions/parent/ext-downloads-js.patch new file mode 100644 index 000000000..f867d171d --- /dev/null +++ b/src/toolkit/components/extensions/parent/ext-downloads-js.patch @@ -0,0 +1,20 @@ +diff --git a/toolkit/components/extensions/parent/ext-downloads.js b/toolkit/components/extensions/parent/ext-downloads.js +index ea6929d23d432958def5be46e42e329bc224d3aa..942cfddc090399ef239cc34ab47682cab6a33cd4 100644 +--- a/toolkit/components/extensions/parent/ext-downloads.js ++++ b/toolkit/components/extensions/parent/ext-downloads.js +@@ -87,6 +87,7 @@ const FILTER_IMAGES_EXTENSIONS = [ + "jpe", + "jpg", + "jpeg", ++ "jxl", + "gif", + "png", + "bmp", +@@ -104,6 +105,7 @@ const FILTER_IMAGES_EXTENSIONS = [ + "raw", + "webp", + "heic", ++ "avif", + ]; + + const FILTER_XML_EXTENSIONS = ["xml"]; diff --git a/src/toolkit/components/pdfjs/content/build/pdf-mjs.patch b/src/toolkit/components/pdfjs/content/build/pdf-mjs.patch new file mode 100644 index 000000000..be90bf533 --- /dev/null +++ b/src/toolkit/components/pdfjs/content/build/pdf-mjs.patch @@ -0,0 +1,37 @@ +diff --git a/toolkit/components/pdfjs/content/build/pdf.mjs b/toolkit/components/pdfjs/content/build/pdf.mjs +index 9798d4f8f9473eac434ff1a521b3728bea436723..144d42b2830a7d9eb345db18a018cd8741753c3c 100644 +--- a/toolkit/components/pdfjs/content/build/pdf.mjs ++++ b/toolkit/components/pdfjs/content/build/pdf.mjs +@@ -22,7 +22,7 @@ + + /******/ // The require scope + /******/ var __webpack_require__ = {}; +-/******/ ++/******/ + /************************************************************************/ + /******/ /* webpack/runtime/define property getters */ + /******/ (() => { +@@ -35,12 +35,12 @@ + /******/ } + /******/ }; + /******/ })(); +-/******/ ++/******/ + /******/ /* webpack/runtime/hasOwnProperty shorthand */ + /******/ (() => { + /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) + /******/ })(); +-/******/ ++/******/ + /************************************************************************/ + var __webpack_exports__ = globalThis.pdfjsLib = {}; + +@@ -18593,7 +18593,7 @@ class StampEditor extends AnnotationEditor { + AnnotationEditor.initialize(l10n, uiManager); + } + static get supportedTypes() { +- const types = ["apng", "avif", "bmp", "gif", "jpeg", "png", "svg+xml", "webp", "x-icon"]; ++ const types = ["apng", "avif", "bmp", "gif", "jpeg", "jxl", "png", "svg+xml", "webp", "x-icon"]; + return shadow(this, "supportedTypes", types.map(type => `image/${type}`)); + } + static get supportedTypesStr() { diff --git a/src/toolkit/content/filepicker-properties.patch b/src/toolkit/content/filepicker-properties.patch new file mode 100644 index 000000000..c3abaca23 --- /dev/null +++ b/src/toolkit/content/filepicker-properties.patch @@ -0,0 +1,13 @@ +diff --git a/toolkit/content/filepicker.properties b/toolkit/content/filepicker.properties +index 03daec114c2882ed5ab7899b9b435d1cce936838..b6bd09c3c5625a1649b31dc99935bc90773d4133 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/src/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType-properties.patch b/src/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType-properties.patch new file mode 100644 index 000000000..c8c23196b --- /dev/null +++ b/src/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType-properties.patch @@ -0,0 +1,12 @@ +diff --git a/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties b/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties +index fa3c5e389bad5abb05c86a3cb08d6c7abf34166c..1bb1f48c4d3964e4637462bb0b3d4a1e965ca5ec 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/src/widget/gtk/nsAppShell-cpp.patch b/src/widget/gtk/nsAppShell-cpp.patch new file mode 100644 index 000000000..5e170a9db --- /dev/null +++ b/src/widget/gtk/nsAppShell-cpp.patch @@ -0,0 +1,14 @@ +diff --git a/widget/gtk/nsAppShell.cpp b/widget/gtk/nsAppShell.cpp +index eef6e76a26341d30748c6c4f054092ba0bfdd865..65b6e2583e6e6891dcbf9faeeefed21cc2d40d15 100644 +--- a/widget/gtk/nsAppShell.cpp ++++ b/widget/gtk/nsAppShell.cpp +@@ -419,7 +419,8 @@ 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") && +- strcmp(name, "svg") && strcmp(name, "webp") && strcmp(name, "avif")) { ++ strcmp(name, "svg") && strcmp(name, "webp") && strcmp(name, "avif") && ++ strcmp(name, "jxl")) { + gdk_pixbuf_format_set_disabled(format, TRUE); + } + g_free(name);