Bug 803349 - Restore NS_DECL_IMGICONTAINER to VectorImage / RasterImage. r=joe
authorSeth Fowler <seth@mozilla.com>
Fri, 19 Oct 2012 13:27:11 -0700
changeset 118750 b47dfc639029e7b6b2aab2b923822641e665d001
parent 118749 fcc8dc83fa784c64f6a22be4ae609e0e7523556d
child 118751 49bf10b166f9acf1722fa3fa73d21c7ae0e77d1f
push id1997
push userakeybl@mozilla.com
push dateMon, 07 Jan 2013 21:25:26 +0000
treeherdermozilla-beta@4baf45cdcf21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs803349
milestone19.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 803349 - Restore NS_DECL_IMGICONTAINER to VectorImage / RasterImage. r=joe
image/src/Image.cpp
image/src/Image.h
image/src/RasterImage.h
image/src/VectorImage.cpp
image/src/VectorImage.h
--- a/image/src/Image.cpp
+++ b/image/src/Image.cpp
@@ -96,43 +96,39 @@ Image::IncrementAnimationConsumers()
 void
 Image::DecrementAnimationConsumers()
 {
   NS_ABORT_IF_FALSE(mAnimationConsumers >= 1, "Invalid no. of animation consumers!");
   mAnimationConsumers--;
   EvaluateAnimation();
 }
 
-//******************************************************************************
-/* attribute unsigned short animationMode; */
-NS_IMETHODIMP
-Image::GetAnimationMode(uint16_t* aAnimationMode)
+nsresult
+Image::GetAnimationModeInternal(uint16_t* aAnimationMode)
 {
   if (mError)
     return NS_ERROR_FAILURE;
 
   NS_ENSURE_ARG_POINTER(aAnimationMode);
-  
+
   *aAnimationMode = mAnimationMode;
   return NS_OK;
 }
 
-//******************************************************************************
-/* attribute unsigned short animationMode; */
-NS_IMETHODIMP
-Image::SetAnimationMode(uint16_t aAnimationMode)
+nsresult
+Image::SetAnimationModeInternal(uint16_t aAnimationMode)
 {
   if (mError)
     return NS_ERROR_FAILURE;
 
   NS_ASSERTION(aAnimationMode == kNormalAnimMode ||
                aAnimationMode == kDontAnimMode ||
                aAnimationMode == kLoopOnceAnimMode,
                "Wrong Animation Mode is being set!");
-  
+
   mAnimationMode = aAnimationMode;
 
   EvaluateAnimation();
 
   return NS_OK;
 }
 
 void
--- a/image/src/Image.h
+++ b/image/src/Image.h
@@ -10,20 +10,16 @@
 #include "imgStatusTracker.h"
 
 namespace mozilla {
 namespace image {
 
 class Image : public imgIContainer
 {
 public:
-  // From NS_DECL_IMGICONTAINER:
-  NS_IMETHOD GetAnimationMode(uint16_t *aAnimationMode);
-  NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode);
-
   imgStatusTracker& GetStatusTracker() { return *mStatusTracker; }
 
   /**
    * Flags for Image initialization.
    *
    * Meanings:
    *
    * INIT_FLAG_NONE: Lack of flags
@@ -97,16 +93,21 @@ public:
   }
   uint64_t InnerWindowID() const { return mInnerWindowId; }
 
   bool HasError() { return mError; }
 
 protected:
   Image(imgStatusTracker* aStatusTracker);
 
+  // Shared functionality for implementors of imgIContainer. Every
+  // implementation of attribute animationMode should forward here.
+  nsresult GetAnimationModeInternal(uint16_t *aAnimationMode);
+  nsresult SetAnimationModeInternal(uint16_t aAnimationMode);
+
   /**
    * Decides whether animation should or should not be happening,
    * and makes sure the right thing is being done.
    */
   virtual void EvaluateAnimation();
 
   virtual nsresult StartAnimation() = 0;
   virtual nsresult StopAnimation() = 0;
--- a/image/src/RasterImage.h
+++ b/image/src/RasterImage.h
@@ -142,43 +142,21 @@ class RasterImage : public Image
                   , public SupportsWeakPtr<RasterImage>
 #ifdef DEBUG
                   , public imgIContainerDebug
 #endif
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPROPERTIES
+  NS_DECL_IMGICONTAINER
 #ifdef DEBUG
   NS_DECL_IMGICONTAINERDEBUG
 #endif
 
-  // BEGIN NS_DECL_IMGICONTAINER (minus GetAnimationMode/SetAnimationMode)
-  // ** Don't edit this chunk except to mirror changes in imgIContainer.idl **
-  NS_IMETHOD GetWidth(int32_t *aWidth);
-  NS_IMETHOD GetHeight(int32_t *aHeight);
-  NS_IMETHOD GetType(uint16_t *aType);
-  NS_IMETHOD_(uint16_t) GetType(void);
-  NS_IMETHOD GetAnimated(bool *aAnimated);
-  NS_IMETHOD GetCurrentFrameIsOpaque(bool *aCurrentFrameIsOpaque);
-  NS_IMETHOD GetFrame(uint32_t aWhichFrame, uint32_t aFlags, gfxASurface **_retval);
-  NS_IMETHOD GetImageContainer(mozilla::layers::ImageContainer **_retval);
-  NS_IMETHOD CopyFrame(uint32_t aWhichFrame, uint32_t aFlags, gfxImageSurface **_retval);
-  NS_IMETHOD ExtractFrame(uint32_t aWhichFrame, const nsIntRect & aRect, uint32_t aFlags, imgIContainer **_retval);
-  NS_IMETHOD Draw(gfxContext *aContext, gfxPattern::GraphicsFilter aFilter, const gfxMatrix & aUserSpaceToImageSpace, const gfxRect & aFill, const nsIntRect & aSubimage, const nsIntSize & aViewportSize, uint32_t aFlags);
-  NS_IMETHOD_(nsIFrame *) GetRootLayoutFrame(void);
-  NS_IMETHOD RequestDecode();
-  NS_IMETHOD StartDecoding();
-  NS_IMETHOD LockImage(void);
-  NS_IMETHOD UnlockImage(void);
-  NS_IMETHOD RequestDiscard(void);
-  NS_IMETHOD ResetAnimation(void);
-  NS_IMETHOD_(void) RequestRefresh(const mozilla::TimeStamp& aTime);
-  // END NS_DECL_IMGICONTAINER
-
   RasterImage(imgStatusTracker* aStatusTracker = nullptr);
   virtual ~RasterImage();
 
   virtual nsresult StartAnimation();
   virtual nsresult StopAnimation();
 
   // Methods inherited from Image
   nsresult Init(imgIDecoderObserver* aObserver,
@@ -747,16 +725,24 @@ private: // data
   bool CanForciblyDiscard();
   bool DiscardingActive();
   bool StoringSourceData() const;
 
 protected:
   bool ShouldAnimate();
 };
 
+inline NS_IMETHODIMP RasterImage::GetAnimationMode(uint16_t *aAnimationMode) {
+  return GetAnimationModeInternal(aAnimationMode);
+}
+
+inline NS_IMETHODIMP RasterImage::SetAnimationMode(uint16_t aAnimationMode) {
+  return SetAnimationModeInternal(aAnimationMode);
+}
+
 // Asynchronous Decode Requestor
 //
 // 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
 {
--- a/image/src/VectorImage.cpp
+++ b/image/src/VectorImage.cpp
@@ -377,16 +377,25 @@ VectorImage::GetFrame(uint32_t aWhichFra
   nsresult rv = CopyFrame(aWhichFrame, aFlags, getter_AddRefs(surface));
   if (NS_SUCCEEDED(rv)) {
     *_retval = surface.forget().get();
   }
   return rv;
 }
 
 //******************************************************************************
+/* [noscript] ImageContainer getImageContainer(); */
+NS_IMETHODIMP
+VectorImage::GetImageContainer(mozilla::layers::ImageContainer** _retval)
+{
+  *_retval = nullptr;
+  return NS_OK;
+}
+
+//******************************************************************************
 /* [noscript] gfxImageSurface copyFrame(in uint32_t aWhichFrame,
  *                                      in uint32_t aFlags); */
 NS_IMETHODIMP
 VectorImage::CopyFrame(uint32_t aWhichFrame,
                        uint32_t aFlags,
                        gfxImageSurface** _retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
--- a/image/src/VectorImage.h
+++ b/image/src/VectorImage.h
@@ -25,39 +25,17 @@ class SVGRootRenderingObserver;
 
 class VectorImage : public Image,
                     public nsIStreamListener
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
-
-  // BEGIN NS_DECL_IMGICONTAINER (minus GetAnimationMode/SetAnimationMode)
-  // ** Don't edit this chunk except to mirror changes in imgIContainer.idl **
-  NS_IMETHOD GetWidth(int32_t *aWidth);
-  NS_IMETHOD GetHeight(int32_t *aHeight);
-  NS_IMETHOD GetType(uint16_t *aType);
-  NS_IMETHOD_(uint16_t) GetType(void);
-  NS_IMETHOD GetAnimated(bool *aAnimated);
-  NS_IMETHOD GetCurrentFrameIsOpaque(bool *aCurrentFrameIsOpaque);
-  NS_IMETHOD GetFrame(uint32_t aWhichFrame, uint32_t aFlags, gfxASurface **_retval);
-  NS_IMETHOD GetImageContainer(mozilla::layers::ImageContainer **_retval) { *_retval = NULL; return NS_OK; }
-  NS_IMETHOD CopyFrame(uint32_t aWhichFrame, uint32_t aFlags, gfxImageSurface **_retval);
-  NS_IMETHOD ExtractFrame(uint32_t aWhichFrame, const nsIntRect & aRect, uint32_t aFlags, imgIContainer **_retval);
-  NS_IMETHOD Draw(gfxContext *aContext, gfxPattern::GraphicsFilter aFilter, const gfxMatrix & aUserSpaceToImageSpace, const gfxRect & aFill, const nsIntRect & aSubimage, const nsIntSize & aViewportSize, uint32_t aFlags);
-  NS_IMETHOD_(nsIFrame *) GetRootLayoutFrame(void);
-  NS_IMETHOD RequestDecode();
-  NS_IMETHOD StartDecoding();
-  NS_IMETHOD LockImage(void);
-  NS_IMETHOD UnlockImage(void);
-  NS_IMETHOD RequestDiscard(void);
-  NS_IMETHOD ResetAnimation(void);
-  NS_IMETHOD_(void) RequestRefresh(const mozilla::TimeStamp& aTime);
-  // END NS_DECL_IMGICONTAINER
+  NS_DECL_IMGICONTAINER
 
   VectorImage(imgStatusTracker* aStatusTracker = nullptr);
   virtual ~VectorImage();
 
   // Methods inherited from Image
   nsresult Init(imgIDecoderObserver* aObserver,
                 const char* aMimeType,
                 const char* aURIString,
@@ -96,12 +74,20 @@ private:
   bool           mIsFullyLoaded:1;        // Has OnStopRequest been called?
   bool           mIsDrawing:1;            // Are we currently drawing?
   bool           mHaveAnimations:1;       // Is our SVG content SMIL-animated?
                                           // (Only set after mIsFullyLoaded.)
   bool           mHaveRestrictedRegion:1; // Are we a restricted-region clone
                                           // created via ExtractFrame?
 };
 
+inline NS_IMETHODIMP VectorImage::GetAnimationMode(uint16_t *aAnimationMode) {
+  return GetAnimationModeInternal(aAnimationMode);
+}
+
+inline NS_IMETHODIMP VectorImage::SetAnimationMode(uint16_t aAnimationMode) {
+  return SetAnimationModeInternal(aAnimationMode);
+}
+
 } // namespace image
 } // namespace mozilla
 
 #endif // mozilla_imagelib_VectorImage_h_