diff --git a/b2g/confvars.sh b/b2g/confvars.sh index a52b30d2c884..adf21aa7af59 100755 --- a/b2g/confvars.sh +++ b/b2g/confvars.sh @@ -55,3 +55,4 @@ MOZ_TOOLKIT_SEARCH= MOZ_PLACES= MOZ_B2G=1 MOZ_FOLD_LIBS=1 +MOZ_WBMP=1 diff --git a/configure.in b/configure.in index 6fd442d68892..179dd4320009 100644 --- a/configure.in +++ b/configure.in @@ -8525,6 +8525,12 @@ if test -n "$MOZ_CAPTIVEDETECT"; then AC_DEFINE(MOZ_CAPTIVEDETECT) fi +dnl Build WBMP decoder if required +AC_SUBST(MOZ_WBMP) +if test -n "$MOZ_WBMP"; then + AC_DEFINE(MOZ_WBMP) +fi + dnl ======================================================== if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS= diff --git a/image/build/nsImageModule.cpp b/image/build/nsImageModule.cpp index a0037adbe881..a35512ce367e 100644 --- a/image/build/nsImageModule.cpp +++ b/image/build/nsImageModule.cpp @@ -81,7 +81,9 @@ static const mozilla::Module::CategoryEntry kImageCategories[] = { { "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_X_PNG, "@mozilla.org/content/document-loader-factory;1" }, +#ifdef MOZ_WBMP { "Gecko-Content-Viewers", IMAGE_WBMP, "@mozilla.org/content/document-loader-factory;1" }, +#endif { "content-sniffing-services", "@mozilla.org/image/loader;1", "@mozilla.org/image/loader;1" }, { NULL } }; diff --git a/image/decoders/Makefile.in b/image/decoders/Makefile.in index 102705f35766..866a68745ace 100644 --- a/image/decoders/Makefile.in +++ b/image/decoders/Makefile.in @@ -21,9 +21,12 @@ endif # !_MSC_VER CPPSRCS = nsPNGDecoder.cpp nsJPEGDecoder.cpp nsGIFDecoder2.cpp \ nsBMPDecoder.cpp nsICODecoder.cpp nsIconDecoder.cpp \ - nsWBMPDecoder.cpp \ $(NULL) +ifdef MOZ_WBMP +CPPSRCS += nsWBMPDecoder.cpp +endif + CSRCS = iccjpeg.c \ $(NULL) diff --git a/image/src/Image.cpp b/image/src/Image.cpp index 5f24997d0e7f..aa0bd8bd2d81 100644 --- a/image/src/Image.cpp +++ b/image/src/Image.cpp @@ -86,9 +86,11 @@ Image::GetDecoderType(const char *aMimeType) else if (!strcmp(aMimeType, IMAGE_ICON_MS)) rv = eDecoderType_icon; +#ifdef MOZ_WBMP // WBMP else if (!strcmp(aMimeType, IMAGE_WBMP)) rv = eDecoderType_wbmp; +#endif return rv; } diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index 6ca0e55bc59a..f9068cf462b8 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -31,7 +31,10 @@ #include "nsBMPDecoder.h" #include "nsICODecoder.h" #include "nsIconDecoder.h" + +#ifdef MOZ_WBMP #include "nsWBMPDecoder.h" +#endif #include "gfxContext.h" @@ -2592,9 +2595,11 @@ RasterImage::InitDecoder(bool aDoSizeDecode, bool aIsSynchronous /* = false */) case eDecoderType_icon: mDecoder = new nsIconDecoder(*this); break; +#ifdef MOZ_WBMP case eDecoderType_wbmp: mDecoder = new nsWBMPDecoder(*this); break; +#endif default: NS_ABORT_IF_FALSE(0, "Shouldn't get here!"); } diff --git a/image/src/imgLoader.cpp b/image/src/imgLoader.cpp index 3965564e73de..4f12140bc6bb 100644 --- a/image/src/imgLoader.cpp +++ b/image/src/imgLoader.cpp @@ -2046,6 +2046,7 @@ nsresult imgLoader::GetMimeTypeFromContent(const char* aContents, uint32_t aLeng aContentType.AssignLiteral(IMAGE_ICO); } +#ifdef MOZ_WBMP // A well-defined type 0 WBMP file starts with an "0000 0000b" byte followed // by an "0xx0 0000b" byte (x = don't care). else if (aLength >= 2 && (static_cast(aContents[0]) == 0x00 && @@ -2053,6 +2054,7 @@ nsresult imgLoader::GetMimeTypeFromContent(const char* aContents, uint32_t aLeng { aContentType.AssignLiteral(IMAGE_WBMP); } +#endif else { /* none of the above? I give up */ diff --git a/image/src/imgRequest.cpp b/image/src/imgRequest.cpp index 8e8740328df1..d8a7a03790f5 100644 --- a/image/src/imgRequest.cpp +++ b/image/src/imgRequest.cpp @@ -725,6 +725,17 @@ imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt, LOG_MSG(GetImgLog(), "imgRequest::OnDataAvailable", "Got content type from the channel"); } +#ifdef MOZ_WBMP +#ifdef MOZ_WIDGET_GONK + // Only support WBMP in privileged app and certified app, do not support in browser app. + if (newType.EqualsLiteral(IMAGE_WBMP) && + (!mLoadingPrincipal || mLoadingPrincipal->GetAppStatus() < nsIPrincipal::APP_STATUS_PRIVILEGED)) { + this->Cancel(NS_ERROR_FAILURE); + return NS_BINDING_ABORTED; + } +#endif +#endif + // If we're a regular image and this is the first call to OnDataAvailable, // this will always be true. If we've resniffed our MIME type (i.e. we're a // multipart/x-mixed-replace image), we have to be able to switch our image diff --git a/image/test/reftest/reftest.list b/image/test/reftest/reftest.list index 63632365dbd6..250fcb2d7916 100644 --- a/image/test/reftest/reftest.list +++ b/image/test/reftest/reftest.list @@ -47,4 +47,4 @@ include color-management/reftest.list skip-if(Android||B2G) include encoders-lossless/reftest.list # bug 783621 # WBMP tests -skip-if(Android) include wbmp/reftest.list +#skip-if(!B2G) include wbmp/reftest.list # bug 852053 diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 7398319d81fa..cc8d5c45cc35 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -478,7 +478,9 @@ static nsExtraMimeTypeEntry extraMimeEntries [] = { IMAGE_PNG, "png", "PNG Image" }, { IMAGE_TIFF, "tiff,tif", "TIFF Image" }, { IMAGE_XBM, "xbm", "XBM Image" }, +#ifdef MOZ_WBMP { IMAGE_WBMP, "wbmp", "WBMP Image" }, +#endif { "image/svg+xml", "svg", "Scalable Vector Graphics" }, { MESSAGE_RFC822, "eml", "RFC-822 data" }, { TEXT_PLAIN, "txt,text", "Text File" },