Bug 1061047 - Fix some bad implicit constructors in imagelib; r=jrmuizel
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 02 Sep 2014 12:20:24 -0400
changeset 226309 2c760e1690b51802dca2c574fd304653d35f4007
parent 226308 1116b6fce5f523ba4a02fb8a4381e6bcacef48a1
child 226310 3805d7d9a02d34a604cbcb037a7df716ac173ecf
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1061047
milestone34.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 1061047 - Fix some bad implicit constructors in imagelib; r=jrmuizel
image/decoders/nsBMPDecoder.h
image/decoders/nsGIFDecoder2.h
image/decoders/nsICODecoder.h
image/decoders/nsIconDecoder.h
image/decoders/nsPNGDecoder.h
image/src/Decoder.h
image/src/DynamicImage.h
image/src/FrameBlender.h
image/src/FrozenImage.h
image/src/Image.h
image/src/ImageWrapper.h
image/src/OrientedImage.cpp
image/src/RasterImage.cpp
image/src/RasterImage.h
image/src/ScriptedNotificationObserver.h
image/src/VectorImage.h
image/src/imgFrame.h
image/src/imgRequest.cpp
image/src/imgRequestProxy.cpp
image/src/imgStatusTracker.cpp
image/src/imgStatusTracker.h
--- a/image/decoders/nsBMPDecoder.h
+++ b/image/decoders/nsBMPDecoder.h
@@ -19,17 +19,17 @@ class RasterImage;
 
 /**
  * Decoder for BMP-Files, as used by Windows and OS/2
  */
 class nsBMPDecoder : public Decoder
 {
 public:
 
-    nsBMPDecoder(RasterImage &aImage);
+    explicit nsBMPDecoder(RasterImage &aImage);
     ~nsBMPDecoder();
 
     // Specifies whether or not the BMP file will contain alpha data
     // If set to true and the BMP is 32BPP, the alpha data will be
     // retrieved from the 4th byte of image data per pixel 
     void SetUseAlphaData(bool useAlphaData);
     // Obtains the bits per pixel from the internal BIH header
     int32_t GetBitsPerPixel() const;
--- a/image/decoders/nsGIFDecoder2.h
+++ b/image/decoders/nsGIFDecoder2.h
@@ -18,17 +18,17 @@ class RasterImage;
 
 //////////////////////////////////////////////////////////////////////
 // nsGIFDecoder2 Definition
 
 class nsGIFDecoder2 : public Decoder
 {
 public:
 
-  nsGIFDecoder2(RasterImage &aImage);
+  explicit nsGIFDecoder2(RasterImage &aImage);
   ~nsGIFDecoder2();
 
   virtual void WriteInternal(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy);
   virtual void FinishInternal();
   virtual Telemetry::ID SpeedHistogram();
 
 private:
   /* These functions will be called when the decoder has a decoded row,
--- a/image/decoders/nsICODecoder.h
+++ b/image/decoders/nsICODecoder.h
@@ -17,17 +17,17 @@ namespace mozilla {
 namespace image {
 
 class RasterImage;
 
 class nsICODecoder : public Decoder
 {
 public:
 
-  nsICODecoder(RasterImage &aImage);
+  explicit nsICODecoder(RasterImage &aImage);
   virtual ~nsICODecoder();
 
   // Obtains the width of the icon directory entry
   uint32_t GetRealWidth() const
   {
     return mDirEntry.mWidth == 0 ? 256 : mDirEntry.mWidth; 
   }
 
--- a/image/decoders/nsIconDecoder.h
+++ b/image/decoders/nsIconDecoder.h
@@ -33,17 +33,17 @@ class RasterImage;
 //
 //
 //////////////////////////////////////////////////////////////////////////////////////////////
 
 class nsIconDecoder : public Decoder
 {
 public:
 
-  nsIconDecoder(RasterImage &aImage);
+  explicit nsIconDecoder(RasterImage &aImage);
   virtual ~nsIconDecoder();
 
   virtual void WriteInternal(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy);
 
   uint8_t mWidth;
   uint8_t mHeight;
   uint32_t mPixBytesRead;
   uint32_t mState;
--- a/image/decoders/nsPNGDecoder.h
+++ b/image/decoders/nsPNGDecoder.h
@@ -19,17 +19,17 @@
 
 namespace mozilla {
 namespace image {
 class RasterImage;
 
 class nsPNGDecoder : public Decoder
 {
 public:
-  nsPNGDecoder(RasterImage &aImage);
+  explicit nsPNGDecoder(RasterImage &aImage);
   virtual ~nsPNGDecoder();
 
   virtual void InitInternal();
   virtual void WriteInternal(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy);
   virtual Telemetry::ID SpeedHistogram();
 
   void CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset,
                    int32_t width, int32_t height,
--- a/image/src/Decoder.h
+++ b/image/src/Decoder.h
@@ -27,17 +27,17 @@ struct HasDangerousPublicDestructor<imag
 };
 
 namespace image {
 
 class Decoder
 {
 public:
 
-  Decoder(RasterImage& aImage);
+  explicit Decoder(RasterImage& aImage);
   virtual ~Decoder();
 
   /**
    * Initialize an image decoder. Decoders may not be re-initialized.
    *
    * Notifications Sent: TODO
    */
   void Init();
--- a/image/src/DynamicImage.h
+++ b/image/src/DynamicImage.h
@@ -20,17 +20,17 @@ namespace image {
  * ephemeral.
  */
 class DynamicImage : public Image
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_IMGICONTAINER
 
-  DynamicImage(gfxDrawable* aDrawable)
+  explicit DynamicImage(gfxDrawable* aDrawable)
     : mDrawable(aDrawable)
   {
     MOZ_ASSERT(aDrawable, "Must have a gfxDrawable to wrap");
   }
 
   // Inherited methods from Image.
   virtual nsresult Init(const char* aMimeType, uint32_t aFlags) MOZ_OVERRIDE;
 
--- a/image/src/FrameBlender.h
+++ b/image/src/FrameBlender.h
@@ -27,17 +27,17 @@ class FrameBlender
 {
 public:
 
   /**
    * Create a new FrameBlender with a given frame sequence.
    *
    * If aSequenceToUse is not specified, it will be allocated automatically.
    */
-  FrameBlender(FrameSequence* aSequenceToUse = nullptr);
+  explicit FrameBlender(FrameSequence* aSequenceToUse = nullptr);
   ~FrameBlender();
 
   bool DoBlend(nsIntRect* aDirtyRect, uint32_t aPrevFrameIndex,
                uint32_t aNextFrameIndex);
 
   already_AddRefed<FrameSequence> GetFrameSequence();
 
   /**
--- a/image/src/FrozenImage.h
+++ b/image/src/FrozenImage.h
@@ -50,17 +50,17 @@ public:
                   uint32_t aFlags) MOZ_OVERRIDE;
   NS_IMETHOD_(void) RequestRefresh(const TimeStamp& aTime) MOZ_OVERRIDE;
   NS_IMETHOD GetAnimationMode(uint16_t* aAnimationMode) MOZ_OVERRIDE;
   NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode) MOZ_OVERRIDE;
   NS_IMETHOD ResetAnimation() MOZ_OVERRIDE;
   NS_IMETHOD_(float) GetFrameIndex(uint32_t aWhichFrame) MOZ_OVERRIDE;
 
 protected:
-  FrozenImage(Image* aImage) : ImageWrapper(aImage) { }
+  explicit FrozenImage(Image* aImage) : ImageWrapper(aImage) { }
   virtual ~FrozenImage() { }
 
 private:
   friend class ImageOps;
 };
 
 } // namespace image
 } // namespace mozilla
--- a/image/src/Image.h
+++ b/image/src/Image.h
@@ -174,17 +174,17 @@ public:
 
   /*
    * Returns a non-AddRefed pointer to the URI associated with this image.
    * Illegal to use off-main-thread.
    */
   virtual ImageURL* GetURI() MOZ_OVERRIDE { return mURI.get(); }
 
 protected:
-  ImageResource(ImageURL* aURI);
+  explicit ImageResource(ImageURL* aURI);
 
   // Shared functionality for implementors of imgIContainer. Every
   // implementation of attribute animationMode should forward here.
   nsresult GetAnimationModeInternal(uint16_t *aAnimationMode);
   nsresult SetAnimationModeInternal(uint16_t aAnimationMode);
 
   /**
    * Helper for RequestRefresh.
--- a/image/src/ImageWrapper.h
+++ b/image/src/ImageWrapper.h
@@ -58,17 +58,17 @@ public:
   virtual uint64_t InnerWindowID() const MOZ_OVERRIDE;
 
   virtual bool HasError() MOZ_OVERRIDE;
   virtual void SetHasError() MOZ_OVERRIDE;
 
   virtual ImageURL* GetURI() MOZ_OVERRIDE;
 
 protected:
-  ImageWrapper(Image* aInnerImage)
+  explicit ImageWrapper(Image* aInnerImage)
     : mInnerImage(aInnerImage)
   {
     NS_ABORT_IF_FALSE(aInnerImage, "Cannot wrap a null image");
   }
 
   virtual ~ImageWrapper() { }
 
   /**
--- a/image/src/OrientedImage.cpp
+++ b/image/src/OrientedImage.cpp
@@ -159,17 +159,17 @@ OrientedImage::GetImageContainer(LayerMa
   }
 
   *_retval = nullptr;
   return NS_OK;
 }
 
 struct MatrixBuilder
 {
-  MatrixBuilder(bool aInvert) : mInvert(aInvert) { }
+  explicit MatrixBuilder(bool aInvert) : mInvert(aInvert) { }
 
   gfxMatrix Build() { return mMatrix; }
 
   void Scale(gfxFloat aX, gfxFloat aY) {
     if (mInvert) {
       mMatrix *= gfxMatrix::Scaling(1.0 / aX, 1.0 / aY);
     } else {
       mMatrix.Scale(aX, aY);
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -289,17 +289,17 @@ public:
   // That's safe because stopping a ScaleRequest is strictly an optimization;
   // if we're not cache-coherent, at worst we'll do extra work.
   bool stopped;
 };
 
 class DrawRunner : public nsRunnable
 {
 public:
-  DrawRunner(ScaleRequest* request)
+  explicit DrawRunner(ScaleRequest* request)
    : mScaleRequest(request)
   {}
 
   NS_IMETHOD Run()
   {
     // ScaleWorker is finished with this request, so we can unlock the data now.
     mScaleRequest->ReleaseSurfaces();
 
--- a/image/src/RasterImage.h
+++ b/image/src/RasterImage.h
@@ -345,17 +345,17 @@ private:
   nsresult OnImageDataCompleteCore(nsIRequest* aRequest, nsISupports*, nsresult aStatus);
 
   /**
    * Each RasterImage has a pointer to one or zero heap-allocated
    * DecodeRequests.
    */
   struct DecodeRequest
   {
-    DecodeRequest(RasterImage* aImage)
+    explicit DecodeRequest(RasterImage* aImage)
       : mImage(aImage)
       , mBytesToDecode(0)
       , mRequestStatus(REQUEST_INACTIVE)
       , mChunkCount(0)
       , mAllocatedNewFrame(false)
     {
       MOZ_ASSERT(aImage, "aImage cannot be null");
       MOZ_ASSERT(aImage->mStatusTracker,
@@ -541,17 +541,17 @@ private:
      * Dispatches an event to do so, which will further dispatch a
      * DecodeRequest event to continue decoding.
      */
     static void GetNewFrame(RasterImage* image);
 
     NS_IMETHOD Run();
 
   private: /* methods */
-    FrameNeededWorker(RasterImage* image);
+    explicit FrameNeededWorker(RasterImage* image);
 
   private: /* members */
 
     nsRefPtr<RasterImage> mImage;
   };
 
   nsresult FinishedSomeDecoding(eShutdownIntent intent = eShutdownIntent_Done,
                                 DecodeRequest* request = nullptr);
@@ -775,31 +775,31 @@ private: // data
      * be handled safely off-main-thread. Dispatches an event which reinvokes
      * DoError on the main thread if there isn't one already pending.
      */
     static void DispatchIfNeeded(RasterImage* aImage);
 
     NS_IMETHOD Run();
 
   private:
-    HandleErrorWorker(RasterImage* aImage);
+    explicit HandleErrorWorker(RasterImage* aImage);
 
     nsRefPtr<RasterImage> mImage;
   };
 
   // Helpers
   bool CanDiscard();
   bool CanForciblyDiscard();
   bool CanForciblyDiscardAndRedecode();
   bool DiscardingActive();
   bool StoringSourceData() const;
 
 protected:
-  RasterImage(imgStatusTracker* aStatusTracker = nullptr,
-              ImageURL* aURI = nullptr);
+  explicit RasterImage(imgStatusTracker* aStatusTracker = nullptr,
+                       ImageURL* aURI = nullptr);
 
   bool ShouldAnimate();
 
   friend class ImageFactory;
 };
 
 inline NS_IMETHODIMP RasterImage::GetAnimationMode(uint16_t *aAnimationMode) {
   return GetAnimationModeInternal(aAnimationMode);
@@ -809,17 +809,17 @@ inline NS_IMETHODIMP RasterImage::GetAni
 //
 // We use this class when someone calls requestDecode() from within a decode
 // notification. Since requestDecode() involves modifying the decoder's state
 // (for example, possibly shutting down a header-only decode and starting a
 // full decode), we don't want to do this from inside a decoder.
 class imgDecodeRequestor : public nsRunnable
 {
   public:
-    imgDecodeRequestor(RasterImage &aContainer) {
+    explicit imgDecodeRequestor(RasterImage &aContainer) {
       mContainer = &aContainer;
     }
     NS_IMETHOD Run() {
       if (mContainer)
         mContainer->StartDecoding();
       return NS_OK;
     }
 
--- a/image/src/ScriptedNotificationObserver.h
+++ b/image/src/ScriptedNotificationObserver.h
@@ -14,17 +14,17 @@
 class imgIScriptedNotificationObserver;
 
 namespace mozilla {
 namespace image {
 
 class ScriptedNotificationObserver : public imgINotificationObserver
 {
 public:
-  ScriptedNotificationObserver(imgIScriptedNotificationObserver* aInner);
+  explicit ScriptedNotificationObserver(imgIScriptedNotificationObserver* aInner);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_IMGINOTIFICATIONOBSERVER
   NS_DECL_CYCLE_COLLECTION_CLASS(ScriptedNotificationObserver)
 
 private:
   virtual ~ScriptedNotificationObserver() {}
   nsCOMPtr<imgIScriptedNotificationObserver> mInner;
--- a/image/src/VectorImage.h
+++ b/image/src/VectorImage.h
@@ -73,18 +73,18 @@ public:
   // Callback for SVGParseCompleteListener.
   void OnSVGDocumentParsed();
 
   // Callbacks for SVGLoadEventListener.
   void OnSVGDocumentLoaded();
   void OnSVGDocumentError();
 
 protected:
-  VectorImage(imgStatusTracker* aStatusTracker = nullptr,
-              ImageURL* aURI = nullptr);
+  explicit VectorImage(imgStatusTracker* aStatusTracker = nullptr,
+                       ImageURL* aURI = nullptr);
   virtual ~VectorImage();
 
   virtual nsresult StartAnimation();
   virtual nsresult StopAnimation();
   virtual bool     ShouldAnimate();
 
   void CreateDrawableAndShow(const SVGDrawingParameters& aParams);
   void Show(gfxDrawable* aDrawable, const SVGDrawingParameters& aParams);
--- a/image/src/imgFrame.h
+++ b/image/src/imgFrame.h
@@ -167,17 +167,17 @@ private: // data
   bool mInformedDiscardTracker;
 };
 
   // An RAII class to ensure it's easy to balance locks and unlocks on
   // imgFrames.
   class AutoFrameLocker
   {
   public:
-    AutoFrameLocker(imgFrame* frame)
+    explicit AutoFrameLocker(imgFrame* frame)
       : mFrame(frame)
       , mSucceeded(NS_SUCCEEDED(frame->LockImageData()))
     {}
 
     ~AutoFrameLocker()
     {
       if (mSucceeded) {
         mFrame->UnlockImageData();
--- a/image/src/imgRequest.cpp
+++ b/image/src/imgRequest.cpp
@@ -298,17 +298,17 @@ void imgRequest::ContinueCancel(nsresult
   if (mRequest && statusTracker->IsLoading()) {
      mRequest->Cancel(aStatus);
   }
 }
 
 class imgRequestMainThreadEvict : public nsRunnable
 {
 public:
-  imgRequestMainThreadEvict(imgRequest *aImgRequest)
+  explicit imgRequestMainThreadEvict(imgRequest *aImgRequest)
     : mImgRequest(aImgRequest)
   {
     MOZ_ASSERT(!NS_IsMainThread(), "Create me off main thread only!");
     MOZ_ASSERT(aImgRequest);
   }
 
   NS_IMETHOD Run()
   {
--- a/image/src/imgRequestProxy.cpp
+++ b/image/src/imgRequestProxy.cpp
@@ -1045,17 +1045,17 @@ imgRequestProxy::GetOwner() const
   return mBehaviour->GetOwner();
 }
 
 ////////////////// imgRequestProxyStatic methods
 
 class StaticBehaviour : public ProxyBehaviour
 {
 public:
-  StaticBehaviour(mozilla::image::Image* aImage) : mImage(aImage) {}
+  explicit StaticBehaviour(mozilla::image::Image* aImage) : mImage(aImage) {}
 
   virtual already_AddRefed<mozilla::image::Image>
   GetImage() const MOZ_OVERRIDE {
     nsRefPtr<mozilla::image::Image> image = mImage;
     return image.forget();
   }
 
   virtual bool HasImage() const MOZ_OVERRIDE {
--- a/image/src/imgStatusTracker.cpp
+++ b/image/src/imgStatusTracker.cpp
@@ -18,17 +18,17 @@
 #include "mozilla/Services.h"
 
 using namespace mozilla::image;
 using mozilla::WeakPtr;
 
 class imgStatusTrackerObserver : public imgDecoderObserver
 {
 public:
-  imgStatusTrackerObserver(imgStatusTracker* aTracker)
+  explicit imgStatusTrackerObserver(imgStatusTracker* aTracker)
   : mTracker(aTracker)
   {
     MOZ_ASSERT(aTracker);
   }
 
   void SetTracker(imgStatusTracker* aTracker)
   {
     MOZ_ASSERT(aTracker);
--- a/image/src/imgStatusTracker.h
+++ b/image/src/imgStatusTracker.h
@@ -112,17 +112,17 @@ class imgStatusTracker : public mozilla:
 
 public:
   MOZ_DECLARE_REFCOUNTED_TYPENAME(imgStatusTracker)
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(imgStatusTracker)
 
   // aImage is the image that this status tracker will pass to the
   // imgRequestProxys in SyncNotify() and EmulateRequestFinished(), and must be
   // alive as long as this instance is, because we hold a weak reference to it.
-  imgStatusTracker(mozilla::image::Image* aImage);
+  explicit imgStatusTracker(mozilla::image::Image* aImage);
 
   // Image-setter, for imgStatusTrackers created by imgRequest::Init, which
   // are created before their Image is created.  This method should only
   // be called once, and only on an imgStatusTracker that was initialized
   // without an image.
   void SetImage(mozilla::image::Image* aImage);
 
   // Image resetter, for when mImage is about to go out of scope. mImage is a