image/src/ImageWrapper.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef MOZILLA_IMAGELIB_IMAGEWRAPPER_H_
     7 #define MOZILLA_IMAGELIB_IMAGEWRAPPER_H_
     9 #include "mozilla/MemoryReporting.h"
    10 #include "Image.h"
    12 namespace mozilla {
    13 namespace image {
    15 /**
    16  * Abstract superclass for Images that wrap other Images.
    17  */
    18 class ImageWrapper : public Image
    19 {
    20 public:
    21   NS_DECL_ISUPPORTS
    22   NS_DECL_IMGICONTAINER
    24   virtual ~ImageWrapper() { }
    26   // Inherited methods from Image.
    27   virtual nsresult Init(const char* aMimeType, uint32_t aFlags) MOZ_OVERRIDE;
    29   virtual already_AddRefed<imgStatusTracker> GetStatusTracker() MOZ_OVERRIDE;
    30   virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
    32   virtual uint32_t SizeOfData() MOZ_OVERRIDE;
    33   virtual size_t HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
    34   virtual size_t HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
    35   virtual size_t NonHeapSizeOfDecoded() const MOZ_OVERRIDE;
    36   virtual size_t OutOfProcessSizeOfDecoded() const MOZ_OVERRIDE;
    38   virtual void IncrementAnimationConsumers() MOZ_OVERRIDE;
    39   virtual void DecrementAnimationConsumers() MOZ_OVERRIDE;
    40 #ifdef DEBUG
    41   virtual uint32_t GetAnimationConsumers() MOZ_OVERRIDE;
    42 #endif
    44   virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
    45                                         nsISupports* aContext,
    46                                         nsIInputStream* aInStr,
    47                                         uint64_t aSourceOffset,
    48                                         uint32_t aCount) MOZ_OVERRIDE;
    49   virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
    50                                        nsISupports* aContext,
    51                                        nsresult aStatus,
    52                                        bool aLastPart) MOZ_OVERRIDE;
    53   virtual nsresult OnNewSourceData() MOZ_OVERRIDE;
    55   virtual void SetInnerWindowID(uint64_t aInnerWindowId) MOZ_OVERRIDE;
    56   virtual uint64_t InnerWindowID() const MOZ_OVERRIDE;
    58   virtual bool HasError() MOZ_OVERRIDE;
    59   virtual void SetHasError() MOZ_OVERRIDE;
    61   virtual ImageURL* GetURI() MOZ_OVERRIDE;
    63 protected:
    64   ImageWrapper(Image* aInnerImage)
    65     : mInnerImage(aInnerImage)
    66   {
    67     NS_ABORT_IF_FALSE(aInnerImage, "Cannot wrap a null image");
    68   }
    70   /**
    71    * Returns a weak reference to the inner image wrapped by this ImageWrapper.
    72    */
    73   Image* InnerImage() { return mInnerImage.get(); }
    75 private:
    76   nsRefPtr<Image> mInnerImage;
    77 };
    79 } // namespace image
    80 } // namespace mozilla
    82 #endif // MOZILLA_IMAGELIB_IMAGEWRAPPER_H_

mercurial