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