Bug 905002: backout bug 879717 until we can fix the mac-only regression rs=roc
[gecko.git] / image / src / ImageWrapper.h
blob4283d4f99ab8b2d63b431d3558ec1192e1dbe013
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.
18 class ImageWrapper : public Image
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 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 nsIURI* GetURI() MOZ_OVERRIDE;
63 protected:
64 ImageWrapper(Image* aInnerImage)
65 : mInnerImage(aInnerImage)
67 NS_ABORT_IF_FALSE(aInnerImage, "Cannot wrap a null image");
70 /**
71 * Returns a weak reference to the inner image wrapped by this ImageWrapper.
73 Image* InnerImage() { return mInnerImage.get(); }
75 private:
76 nsRefPtr<Image> mInnerImage;
79 } // namespace image
80 } // namespace mozilla
82 #endif // MOZILLA_IMAGELIB_IMAGEWRAPPER_H_