image/src/ImageWrapper.h

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:8d4ba485a7ba
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/. */
5
6 #ifndef MOZILLA_IMAGELIB_IMAGEWRAPPER_H_
7 #define MOZILLA_IMAGELIB_IMAGEWRAPPER_H_
8
9 #include "mozilla/MemoryReporting.h"
10 #include "Image.h"
11
12 namespace mozilla {
13 namespace image {
14
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
23
24 virtual ~ImageWrapper() { }
25
26 // Inherited methods from Image.
27 virtual nsresult Init(const char* aMimeType, uint32_t aFlags) MOZ_OVERRIDE;
28
29 virtual already_AddRefed<imgStatusTracker> GetStatusTracker() MOZ_OVERRIDE;
30 virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
31
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;
37
38 virtual void IncrementAnimationConsumers() MOZ_OVERRIDE;
39 virtual void DecrementAnimationConsumers() MOZ_OVERRIDE;
40 #ifdef DEBUG
41 virtual uint32_t GetAnimationConsumers() MOZ_OVERRIDE;
42 #endif
43
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;
54
55 virtual void SetInnerWindowID(uint64_t aInnerWindowId) MOZ_OVERRIDE;
56 virtual uint64_t InnerWindowID() const MOZ_OVERRIDE;
57
58 virtual bool HasError() MOZ_OVERRIDE;
59 virtual void SetHasError() MOZ_OVERRIDE;
60
61 virtual ImageURL* GetURI() MOZ_OVERRIDE;
62
63 protected:
64 ImageWrapper(Image* aInnerImage)
65 : mInnerImage(aInnerImage)
66 {
67 NS_ABORT_IF_FALSE(aInnerImage, "Cannot wrap a null image");
68 }
69
70 /**
71 * Returns a weak reference to the inner image wrapped by this ImageWrapper.
72 */
73 Image* InnerImage() { return mInnerImage.get(); }
74
75 private:
76 nsRefPtr<Image> mInnerImage;
77 };
78
79 } // namespace image
80 } // namespace mozilla
81
82 #endif // MOZILLA_IMAGELIB_IMAGEWRAPPER_H_

mercurial