#501: basic support (doesn't work yet, doesn't crash) from M1294490

This commit is contained in:
Cameron Kaiser 2019-02-06 06:54:39 -08:00
parent 09717d2708
commit 630d191905
13 changed files with 120 additions and 0 deletions

View File

@ -15,6 +15,7 @@ contract @mozilla.org/uriloader/content-handler;1?type=image/gif {5d0ce354-df01-
contract @mozilla.org/uriloader/content-handler;1?type=image/jpeg {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} contract @mozilla.org/uriloader/content-handler;1?type=image/jpeg {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
contract @mozilla.org/uriloader/content-handler;1?type=image/jpg {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} contract @mozilla.org/uriloader/content-handler;1?type=image/jpg {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
contract @mozilla.org/uriloader/content-handler;1?type=image/png {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} contract @mozilla.org/uriloader/content-handler;1?type=image/png {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
contract @mozilla.org/uriloader/content-handler;1?type=image/webp {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
contract @mozilla.org/uriloader/content-handler;1?type=image/bmp {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} contract @mozilla.org/uriloader/content-handler;1?type=image/bmp {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
contract @mozilla.org/uriloader/content-handler;1?type=image/x-icon {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} contract @mozilla.org/uriloader/content-handler;1?type=image/x-icon {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
contract @mozilla.org/uriloader/content-handler;1?type=image/vnd.microsoft.icon {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} contract @mozilla.org/uriloader/content-handler;1?type=image/vnd.microsoft.icon {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}

View File

@ -72,6 +72,7 @@ export:: $(export-preqs)
-DMOZ_NATIVE_JPEG=$(MOZ_NATIVE_JPEG) \ -DMOZ_NATIVE_JPEG=$(MOZ_NATIVE_JPEG) \
-DMOZ_NATIVE_LIBEVENT=$(MOZ_NATIVE_LIBEVENT) \ -DMOZ_NATIVE_LIBEVENT=$(MOZ_NATIVE_LIBEVENT) \
-DMOZ_NATIVE_LIBVPX=$(MOZ_NATIVE_LIBVPX) \ -DMOZ_NATIVE_LIBVPX=$(MOZ_NATIVE_LIBVPX) \
-DMOZ_NATIVE_LIBWEBP=$(MOZ_NATIVE_LIBWEBP) \
-DMOZ_NATIVE_ICU=$(MOZ_NATIVE_ICU) \ -DMOZ_NATIVE_ICU=$(MOZ_NATIVE_ICU) \
$(srcdir)/system-headers | $(PERL) $(topsrcdir)/nsprpub/config/make-system-wrappers.pl system_wrappers $(srcdir)/system-headers | $(PERL) $(topsrcdir)/nsprpub/config/make-system-wrappers.pl system_wrappers
$(INSTALL) system_wrappers $(DIST) $(INSTALL) system_wrappers $(DIST)

View File

@ -301,6 +301,7 @@ OS_INCLUDES := \
$(NSPR_CFLAGS) $(NSS_CFLAGS) \ $(NSPR_CFLAGS) $(NSS_CFLAGS) \
$(MOZ_JPEG_CFLAGS) \ $(MOZ_JPEG_CFLAGS) \
$(MOZ_PNG_CFLAGS) \ $(MOZ_PNG_CFLAGS) \
$(MOZ_WEBP_CFLAGS) \
$(MOZ_ZLIB_CFLAGS) \ $(MOZ_ZLIB_CFLAGS) \
$(MOZ_PIXMAN_CFLAGS) \ $(MOZ_PIXMAN_CFLAGS) \
$(NULL) $(NULL)

View File

@ -36,6 +36,9 @@ if CONFIG['MOZ_WEBM_ENCODER']:
if CONFIG['MOZ_VPX'] and not CONFIG['MOZ_NATIVE_LIBVPX']: if CONFIG['MOZ_VPX'] and not CONFIG['MOZ_NATIVE_LIBVPX']:
external_dirs += ['media/libvpx'] external_dirs += ['media/libvpx']
if CONFIG['MOZ_WEBP'] and not CONFIG['MOZ_NATIVE_WEBP']:
external_dirs += ['media/libwebp']
if not CONFIG['MOZ_NATIVE_PNG']: if not CONFIG['MOZ_NATIVE_PNG']:
external_dirs += ['media/libpng'] external_dirs += ['media/libpng']

View File

@ -52,6 +52,7 @@ dnl Set the version number of the libs included with mozilla
dnl ======================================================== dnl ========================================================
MOZJPEG=62 MOZJPEG=62
MOZPNG=10619 MOZPNG=10619
MOZWEBP=0x201
NSPR_VERSION=4 NSPR_VERSION=4
NSPR_MINVER=4.12 NSPR_MINVER=4.12
NSS_VERSION=3 NSS_VERSION=3
@ -3667,6 +3668,82 @@ fi # SKIP_LIBRARY_CHECKS
AC_SUBST(MOZ_PNG_ARM_NEON) AC_SUBST(MOZ_PNG_ARM_NEON)
dnl ========================================================
dnl system WEBP Support
dnl ========================================================
MOZ_ARG_WITH_STRING(system-webp,
[ --with-system-webp[=PFX]
Use system libwebp [installed at prefix PFX]],
WEBP_DIR=$withval)
_SAVE_CFLAGS=$CFLAGS
_SAVE_LDFLAGS=$LDFLAGS
_SAVE_LIBS=$LIBS
if test -n "${WEBP_DIR}" -a "${WEBP_DIR}" != "yes"; then
CFLAGS="-I${WEBP_DIR}/include $CFLAGS"
LDFLAGS="-L${WEBP_DIR}/lib $LDFLAGS"
fi
if test -z "$WEBP_DIR" -o "$WEBP_DIR" = no; then
MOZ_NATIVE_WEBP=
else
AC_CHECK_LIB(webp, WebPGetDecoderVersion, [MOZ_NATIVE_WEBP=1 MOZ_WEBP_LIBS="-lwebp"],
[MOZ_NATIVE_WEBP= MOZ_WEBP_CFLAGS= MOZ_WEBP_LIBS=])
fi
if test "$MOZ_NATIVE_WEBP" = 1; then
AC_TRY_COMPILE([ #include <webp/decode.h> ],
[ #if WEBP_DECODER_ABI_VERSION < $MOZWEBP
#error "Insufficient libwebp decoder version ($MOZWEBP required)."
#endif ],
MOZ_NATIVE_WEBP=1,
AC_MSG_ERROR([--with-system-webp requested but no working libwebp found]))
fi
CFLAGS=$_SAVE_CFLAGS
LDFLAGS=$_SAVE_LDFLAGS
LIBS=$_SAVE_LIBS
if test "${WEBP_DIR}" -a -d "${WEBP_DIR}" -a "$MOZ_NATIVE_WEBP" = 1; then
MOZ_WEBP_CFLAGS="-I${WEBP_DIR}/include"
MOZ_WEBP_LIBS="-L${WEBP_DIR}/lib ${MOZ_WEBP_LIBS}"
fi
dnl ========================================================
dnl system WEBP Support
dnl ========================================================
MOZ_ARG_WITH_STRING(system-webp,
[ --with-system-webp[=PFX]
Use system libwebp [installed at prefix PFX]],
WEBP_DIR=$withval)
_SAVE_CFLAGS=$CFLAGS
_SAVE_LDFLAGS=$LDFLAGS
_SAVE_LIBS=$LIBS
if test -n "${WEBP_DIR}" -a "${WEBP_DIR}" != "yes"; then
CFLAGS="-I${WEBP_DIR}/include $CFLAGS"
LDFLAGS="-L${WEBP_DIR}/lib $LDFLAGS"
fi
if test -z "$WEBP_DIR" -o "$WEBP_DIR" = no; then
MOZ_NATIVE_WEBP=
else
AC_CHECK_LIB(webp, WebPGetDecoderVersion, [MOZ_NATIVE_WEBP=1 MOZ_WEBP_LIBS="-lwebp"],
[MOZ_NATIVE_WEBP= MOZ_WEBP_CFLAGS= MOZ_WEBP_LIBS=])
fi
if test "$MOZ_NATIVE_WEBP" = 1; then
AC_TRY_COMPILE([ #include <webp/decode.h> ],
[ #if WEBP_DECODER_ABI_VERSION < $MOZWEBP
#error "Insufficient libwebp decoder version ($MOZWEBP required)."
#endif ],
MOZ_NATIVE_WEBP=1,
AC_MSG_ERROR([--with-system-webp requested but no working libwebp found]))
fi
CFLAGS=$_SAVE_CFLAGS
LDFLAGS=$_SAVE_LDFLAGS
LIBS=$_SAVE_LIBS
if test "${WEBP_DIR}" -a -d "${WEBP_DIR}" -a "$MOZ_NATIVE_WEBP" = 1; then
MOZ_WEBP_CFLAGS="-I${WEBP_DIR}/include"
MOZ_WEBP_LIBS="-L${WEBP_DIR}/lib ${MOZ_WEBP_LIBS}"
fi
dnl ======================================================== dnl ========================================================
dnl system HunSpell Support dnl system HunSpell Support
dnl ======================================================== dnl ========================================================
@ -3727,6 +3804,7 @@ MOZ_WAVE=1
MOZ_SAMPLE_TYPE_FLOAT32= MOZ_SAMPLE_TYPE_FLOAT32=
MOZ_SAMPLE_TYPE_S16= MOZ_SAMPLE_TYPE_S16=
MOZ_WEBM=1 MOZ_WEBM=1
MOZ_WEBP=1
MOZ_GSTREAMER= MOZ_GSTREAMER=
MOZ_DIRECTSHOW= MOZ_DIRECTSHOW=
MOZ_WMF= MOZ_WMF=
@ -5451,6 +5529,14 @@ AC_SUBST(MOZ_NATIVE_LIBVPX)
AC_SUBST_LIST(MOZ_LIBVPX_CFLAGS) AC_SUBST_LIST(MOZ_LIBVPX_CFLAGS)
AC_SUBST_LIST(MOZ_LIBVPX_LIBS) AC_SUBST_LIST(MOZ_LIBVPX_LIBS)
if test "$MOZ_WEBP"; then
AC_DEFINE(MOZ_WEBP)
fi
if test "$MOZ_WEBP"; then
AC_DEFINE(MOZ_WEBP)
fi
if test "$MOZ_WEBM"; then if test "$MOZ_WEBM"; then
if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then
MOZ_VORBIS=1 MOZ_VORBIS=1
@ -8926,6 +9012,7 @@ HOST_CXXFLAGS=`echo \
AC_SUBST(MOZ_NATIVE_JPEG) AC_SUBST(MOZ_NATIVE_JPEG)
AC_SUBST(MOZ_NATIVE_PNG) AC_SUBST(MOZ_NATIVE_PNG)
AC_SUBST(MOZ_NATIVE_WEBP)
AC_SUBST(MOZ_NATIVE_BZ2) AC_SUBST(MOZ_NATIVE_BZ2)
AC_SUBST_LIST(MOZ_JPEG_CFLAGS) AC_SUBST_LIST(MOZ_JPEG_CFLAGS)
@ -8934,6 +9021,8 @@ AC_SUBST_LIST(MOZ_BZ2_CFLAGS)
AC_SUBST_LIST(MOZ_BZ2_LIBS) AC_SUBST_LIST(MOZ_BZ2_LIBS)
AC_SUBST_LIST(MOZ_PNG_CFLAGS) AC_SUBST_LIST(MOZ_PNG_CFLAGS)
AC_SUBST_LIST(MOZ_PNG_LIBS) AC_SUBST_LIST(MOZ_PNG_LIBS)
AC_SUBST(MOZ_WEBP_CFLAGS)
AC_SUBST_LIST(MOZ_WEBP_LIBS)
if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_NUWA_PROCESS"; then if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_NUWA_PROCESS"; then
export MOZ_NUWA_PROCESS export MOZ_NUWA_PROCESS
@ -9031,6 +9120,7 @@ AC_SUBST(MOZ_WAVE)
AC_SUBST(MOZ_VORBIS) AC_SUBST(MOZ_VORBIS)
AC_SUBST(MOZ_TREMOR) AC_SUBST(MOZ_TREMOR)
AC_SUBST(MOZ_WEBM) AC_SUBST(MOZ_WEBM)
AC_SUBST(MOZ_WEBP)
AC_SUBST(MOZ_WMF) AC_SUBST(MOZ_WMF)
AC_SUBST(MOZ_FFMPEG) AC_SUBST(MOZ_FFMPEG)
AC_SUBST(MOZ_FMP4) AC_SUBST(MOZ_FMP4)

View File

@ -16,6 +16,7 @@
#include "nsBMPDecoder.h" #include "nsBMPDecoder.h"
#include "nsICODecoder.h" #include "nsICODecoder.h"
#include "nsIconDecoder.h" #include "nsIconDecoder.h"
#include "nsWEBPDecoder.h"
namespace mozilla { namespace mozilla {
@ -62,6 +63,10 @@ DecoderFactory::GetDecoderType(const char* aMimeType)
// Icon // Icon
} else if (!strcmp(aMimeType, IMAGE_ICON_MS)) { } else if (!strcmp(aMimeType, IMAGE_ICON_MS)) {
type = DecoderType::ICON; type = DecoderType::ICON;
// WEBP
} else if (!strcmp(aMimeType, IMAGE_WEBP)) {
type = DecoderType::WEBP;
} }
return type; return type;
@ -97,6 +102,9 @@ DecoderFactory::GetDecoder(DecoderType aType,
case DecoderType::ICON: case DecoderType::ICON:
decoder = new nsIconDecoder(aImage); decoder = new nsIconDecoder(aImage);
break; break;
case DecoderType::WEBP:
decoder = new nsWEBPDecoder(aImage);
break;
default: default:
MOZ_ASSERT_UNREACHABLE("Unknown decoder type"); MOZ_ASSERT_UNREACHABLE("Unknown decoder type");
} }

View File

@ -35,6 +35,7 @@ enum class DecoderType
BMP, BMP,
ICO, ICO,
ICON, ICON,
WEBP,
UNKNOWN UNKNOWN
}; };

View File

@ -78,6 +78,7 @@ static const mozilla::Module::CategoryEntry kImageCategories[] = {
{ "Gecko-Content-Viewers", IMAGE_ICON_MS, "@mozilla.org/content/document-loader-factory;1" }, { "Gecko-Content-Viewers", IMAGE_ICON_MS, "@mozilla.org/content/document-loader-factory;1" },
{ "Gecko-Content-Viewers", IMAGE_PNG, "@mozilla.org/content/document-loader-factory;1" }, { "Gecko-Content-Viewers", IMAGE_PNG, "@mozilla.org/content/document-loader-factory;1" },
{ "Gecko-Content-Viewers", IMAGE_X_PNG, "@mozilla.org/content/document-loader-factory;1" }, { "Gecko-Content-Viewers", IMAGE_X_PNG, "@mozilla.org/content/document-loader-factory;1" },
{ "Gecko-Content-Viewers", IMAGE_WEBP, "@mozilla.org/content/document-loader-factory;1" },
{ "content-sniffing-services", "@mozilla.org/image/loader;1", "@mozilla.org/image/loader;1" }, { "content-sniffing-services", "@mozilla.org/image/loader;1", "@mozilla.org/image/loader;1" },
{ nullptr } { nullptr }
}; };

View File

@ -30,6 +30,7 @@ UNIFIED_SOURCES += [
'nsIconDecoder.cpp', 'nsIconDecoder.cpp',
'nsJPEGDecoder.cpp', 'nsJPEGDecoder.cpp',
'nsPNGDecoder.cpp', 'nsPNGDecoder.cpp',
'nsWEBPDecoder.cpp',
] ]
# Decoders need RasterImage.h # Decoders need RasterImage.h

View File

@ -2585,6 +2585,11 @@ imgLoader::GetMimeTypeFromContent(const char* aContents,
!memcmp(aContents, "\000\000\002\000", 4))) { !memcmp(aContents, "\000\000\002\000", 4))) {
aContentType.AssignLiteral(IMAGE_ICO); aContentType.AssignLiteral(IMAGE_ICO);
// WebPs always begin with RIFF, a 32-bit length, and WEBP.
} else if (aLength >= 12 && !memcmp(aContents, "RIFF", 4) &&
!memcmp(aContents + 8, "WEBP", 4)) {
aContentType.AssignLiteral(IMAGE_WEBP);
} else { } else {
/* none of the above? I give up */ /* none of the above? I give up */
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;

View File

@ -100,6 +100,7 @@
#define IMAGE_XBM "image/x-xbitmap" #define IMAGE_XBM "image/x-xbitmap"
#define IMAGE_XBM2 "image/x-xbm" #define IMAGE_XBM2 "image/x-xbm"
#define IMAGE_XBM3 "image/xbm" #define IMAGE_XBM3 "image/xbm"
#define IMAGE_WEBP "image/webp"
#define IMAGE_ART "image/x-jg" #define IMAGE_ART "image/x-jg"
#define IMAGE_TIFF "image/tiff" #define IMAGE_TIFF "image/tiff"
#define IMAGE_BMP "image/bmp" #define IMAGE_BMP "image/bmp"

View File

@ -221,6 +221,9 @@ if CONFIG['MOZ_NATIVE_JPEG']:
if CONFIG['MOZ_NATIVE_PNG']: if CONFIG['MOZ_NATIVE_PNG']:
OS_LIBS += CONFIG['MOZ_PNG_LIBS'] OS_LIBS += CONFIG['MOZ_PNG_LIBS']
if CONFIG['MOZ_NATIVE_WEBP']:
OS_LIBS += CONFIG['MOZ_WEBP_LIBS']
if CONFIG['MOZ_NATIVE_HUNSPELL']: if CONFIG['MOZ_NATIVE_HUNSPELL']:
OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS'] OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS']

View File

@ -507,6 +507,9 @@ static nsDefaultMimeTypeEntry defaultMimeEntries [] =
{ IMAGE_JPEG, "jpeg" }, { IMAGE_JPEG, "jpeg" },
{ IMAGE_JPEG, "jpg" }, { IMAGE_JPEG, "jpg" },
{ IMAGE_SVG_XML, "svg" }, { IMAGE_SVG_XML, "svg" },
#ifdef MOZ_WEBP
{ IMAGE_WEBP, "webp" },
#endif
{ TEXT_HTML, "html" }, { TEXT_HTML, "html" },
{ TEXT_HTML, "htm" }, { TEXT_HTML, "htm" },
{ APPLICATION_XPINSTALL, "xpi" }, { APPLICATION_XPINSTALL, "xpi" },
@ -584,6 +587,7 @@ static nsExtraMimeTypeEntry extraMimeEntries [] =
{ IMAGE_TIFF, "tiff,tif", "TIFF Image" }, { IMAGE_TIFF, "tiff,tif", "TIFF Image" },
{ IMAGE_XBM, "xbm", "XBM Image" }, { IMAGE_XBM, "xbm", "XBM Image" },
{ IMAGE_SVG_XML, "svg", "Scalable Vector Graphics" }, { IMAGE_SVG_XML, "svg", "Scalable Vector Graphics" },
{ IMAGE_WEBP, "webp", "WebP Image" },
{ MESSAGE_RFC822, "eml", "RFC-822 data" }, { MESSAGE_RFC822, "eml", "RFC-822 data" },
{ TEXT_PLAIN, "txt,text", "Text File" }, { TEXT_PLAIN, "txt,text", "Text File" },
{ TEXT_HTML, "html,htm,shtml,ehtml", "HyperText Markup Language" }, { TEXT_HTML, "html,htm,shtml,ehtml", "HyperText Markup Language" },