michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_IMAGELIB_IMAGEWRAPPER_H_ michael@0: #define MOZILLA_IMAGELIB_IMAGEWRAPPER_H_ michael@0: michael@0: #include "mozilla/MemoryReporting.h" michael@0: #include "Image.h" michael@0: michael@0: namespace mozilla { michael@0: namespace image { michael@0: michael@0: /** michael@0: * Abstract superclass for Images that wrap other Images. michael@0: */ michael@0: class ImageWrapper : public Image michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_IMGICONTAINER michael@0: michael@0: virtual ~ImageWrapper() { } michael@0: michael@0: // Inherited methods from Image. michael@0: virtual nsresult Init(const char* aMimeType, uint32_t aFlags) MOZ_OVERRIDE; michael@0: michael@0: virtual already_AddRefed GetStatusTracker() MOZ_OVERRIDE; michael@0: virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; michael@0: michael@0: virtual uint32_t SizeOfData() MOZ_OVERRIDE; michael@0: virtual size_t HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; michael@0: virtual size_t HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; michael@0: virtual size_t NonHeapSizeOfDecoded() const MOZ_OVERRIDE; michael@0: virtual size_t OutOfProcessSizeOfDecoded() const MOZ_OVERRIDE; michael@0: michael@0: virtual void IncrementAnimationConsumers() MOZ_OVERRIDE; michael@0: virtual void DecrementAnimationConsumers() MOZ_OVERRIDE; michael@0: #ifdef DEBUG michael@0: virtual uint32_t GetAnimationConsumers() MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: virtual nsresult OnImageDataAvailable(nsIRequest* aRequest, michael@0: nsISupports* aContext, michael@0: nsIInputStream* aInStr, michael@0: uint64_t aSourceOffset, michael@0: uint32_t aCount) MOZ_OVERRIDE; michael@0: virtual nsresult OnImageDataComplete(nsIRequest* aRequest, michael@0: nsISupports* aContext, michael@0: nsresult aStatus, michael@0: bool aLastPart) MOZ_OVERRIDE; michael@0: virtual nsresult OnNewSourceData() MOZ_OVERRIDE; michael@0: michael@0: virtual void SetInnerWindowID(uint64_t aInnerWindowId) MOZ_OVERRIDE; michael@0: virtual uint64_t InnerWindowID() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool HasError() MOZ_OVERRIDE; michael@0: virtual void SetHasError() MOZ_OVERRIDE; michael@0: michael@0: virtual ImageURL* GetURI() MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: ImageWrapper(Image* aInnerImage) michael@0: : mInnerImage(aInnerImage) michael@0: { michael@0: NS_ABORT_IF_FALSE(aInnerImage, "Cannot wrap a null image"); michael@0: } michael@0: michael@0: /** michael@0: * Returns a weak reference to the inner image wrapped by this ImageWrapper. michael@0: */ michael@0: Image* InnerImage() { return mInnerImage.get(); } michael@0: michael@0: private: michael@0: nsRefPtr mInnerImage; michael@0: }; michael@0: michael@0: } // namespace image michael@0: } // namespace mozilla michael@0: michael@0: #endif // MOZILLA_IMAGELIB_IMAGEWRAPPER_H_