Bug 852053 - Support WBMP on FirefoxOS only. r=joe
authorShih-Chiang Chien <schien@mozilla.com>
Wed, 20 Mar 2013 14:03:07 +0800
changeset 136815 fdfe97b3caafbdd943463b6ec65d89ca5e9d51f1
parent 136814 9e6a306cbc51bb8c0f8e23a4be75a7188c49901c
child 136816 50027b0a1ed6c9d4b50d8aa9a2a56dbda5f272f3
push id2452
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 16:59:38 +0000
treeherdermozilla-beta@d4b152d29d8d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs852053
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 852053 - Support WBMP on FirefoxOS only. r=joe
b2g/confvars.sh
configure.in
image/build/nsImageModule.cpp
image/decoders/Makefile.in
image/src/Image.cpp
image/src/RasterImage.cpp
image/src/imgLoader.cpp
image/src/imgRequest.cpp
image/test/reftest/reftest.list
uriloader/exthandler/nsExternalHelperAppService.cpp
--- a/b2g/confvars.sh
+++ b/b2g/confvars.sh
@@ -50,8 +50,9 @@ MOZ_SYS_MSG=1
 MOZ_TIME_MANAGER=1
 
 MOZ_B2G_CERTDATA=1
 MOZ_PAY=1
 MOZ_TOOLKIT_SEARCH=
 MOZ_PLACES=
 MOZ_B2G=1
 MOZ_FOLD_LIBS=1
+MOZ_WBMP=1
--- a/configure.in
+++ b/configure.in
@@ -8520,16 +8520,22 @@ if test -n "$MOZ_SERVICES_SYNC"; then
 fi
 
 dnl Build Captive Portal Detector if required
 AC_SUBST(MOZ_CAPTIVEDETECT)
 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=
 fi
 
 if test "$MOZ_APP_COMPONENT_INCLUDE"; then
   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
 fi
--- a/image/build/nsImageModule.cpp
+++ b/image/build/nsImageModule.cpp
@@ -76,17 +76,19 @@ static const mozilla::Module::CategoryEn
   { "Gecko-Content-Viewers", IMAGE_JPG, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_ICO, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_ICO_MS, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_BMP, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_BMP_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_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 }
 };
 
 static nsresult
 imglib_Initialize()
 {
   mozilla::image::DiscardTracker::Initialize();
--- a/image/decoders/Makefile.in
+++ b/image/decoders/Makefile.in
@@ -16,19 +16,22 @@ MODULE_NAME = nsDecodersModule
 LIBXUL_LIBRARY  = 1
 ifndef _MSC_VER
 FAIL_ON_WARNINGS = 1
 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)
 
 # Decoders need RasterImage.h
 LOCAL_INCLUDES += -I$(topsrcdir)/image/src/
 
 # PNG read/write stuff
 DEFINES		+= -DMOZ_PNG_WRITE \
--- a/image/src/Image.cpp
+++ b/image/src/Image.cpp
@@ -81,19 +81,21 @@ Image::GetDecoderType(const char *aMimeT
     rv = eDecoderType_ico;
   else if (!strcmp(aMimeType, IMAGE_ICO_MS))
     rv = eDecoderType_ico;
 
   // Icon
   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;
 }
 
 void
 ImageResource::IncrementAnimationConsumers()
 {
   mAnimationConsumers++;
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -26,17 +26,20 @@
 #include "nsIObserverService.h"
 
 #include "nsPNGDecoder.h"
 #include "nsGIFDecoder2.h"
 #include "nsJPEGDecoder.h"
 #include "nsBMPDecoder.h"
 #include "nsICODecoder.h"
 #include "nsIconDecoder.h"
+
+#ifdef MOZ_WBMP
 #include "nsWBMPDecoder.h"
+#endif
 
 #include "gfxContext.h"
 
 #include "mozilla/Services.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/StandardInteger.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
@@ -2587,19 +2590,21 @@ RasterImage::InitDecoder(bool aDoSizeDec
       mDecoder = new nsBMPDecoder(*this);
       break;
     case eDecoderType_ico:
       mDecoder = new nsICODecoder(*this);
       break;
     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!");
   }
 
   // If we already have frames, we're probably in the multipart/x-mixed-replace
   // case. Regardless, we need to lock the last frame. Our invariant is that,
   // while we have a decoder open, the last frame is always locked.
   if (mFrames.Length() > 0) {
--- a/image/src/imgLoader.cpp
+++ b/image/src/imgLoader.cpp
@@ -2041,23 +2041,25 @@ nsresult imgLoader::GetMimeTypeFromConte
 
   // ICOs always begin with a 2-byte 0 followed by a 2-byte 1.
   // CURs begin with 2-byte 0 followed by 2-byte 2.
   else if (aLength >= 4 && (!memcmp(aContents, "\000\000\001\000", 4) ||
                             !memcmp(aContents, "\000\000\002\000", 4))) {
     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<unsigned char>(aContents[0]) == 0x00 &&
                             (static_cast<unsigned char>(aContents[1]) & 0x9F) == 0x00))
   {
     aContentType.AssignLiteral(IMAGE_WBMP);
   }
+#endif
 
   else {
     /* none of the above?  I give up */
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   return NS_OK;
 }
--- a/image/src/imgRequest.cpp
+++ b/image/src/imgRequest.cpp
@@ -720,16 +720,27 @@ imgRequest::OnDataAvailable(nsIRequest *
         this->Cancel(NS_IMAGELIB_ERROR_FAILURE);
 
         return NS_BINDING_ABORTED;
       }
 
       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
     // type and decoder.
     // We always reinitialize for SVGs, because they have no way of
     // reinitializing themselves.
     if (mContentType != newType || newType.EqualsLiteral(IMAGE_SVG_XML)) {
       mContentType = newType;
--- a/image/test/reftest/reftest.list
+++ b/image/test/reftest/reftest.list
@@ -42,9 +42,9 @@ include generic/reftest.list
 
 # Color management test
 include color-management/reftest.list
 
 # Lossless encoders
 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
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -473,17 +473,19 @@ static nsExtraMimeTypeEntry extraMimeEnt
   { IMAGE_ART, "art", "ART Image" },
   { IMAGE_BMP, "bmp", "BMP Image" },
   { IMAGE_GIF, "gif", "GIF Image" },
   { IMAGE_ICO, "ico,cur", "ICO Image" },
   { IMAGE_JPEG, "jpeg,jpg,jfif,pjpeg,pjp", "JPEG Image" },
   { 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" },
   { TEXT_HTML, "html,htm,shtml,ehtml", "HyperText Markup Language" },
   { "application/xhtml+xml", "xhtml,xht", "Extensible HyperText Markup Language" },
   { APPLICATION_MATHML_XML, "mml", "Mathematical Markup Language" },
   { APPLICATION_RDF, "rdf", "Resource Description Framework" },
   { TEXT_XUL, "xul", "XML-Based User Interface Language" },