Bug 1586038 [wpt PR 19492] - [LayoutNG] Account for relpos offset when adding layout...
[gecko.git] / image / ImageWrapper.h
blobc3de39441f5bc1e6a598cb91c72e34a4fbc182a9
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_image_ImageWrapper_h
7 #define mozilla_image_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 {
19 public:
20 NS_DECL_ISUPPORTS
21 NS_DECL_IMGICONTAINER
23 // Inherited methods from Image.
24 nsresult GetNativeSizes(nsTArray<gfx::IntSize>& aNativeSizes) const override;
25 size_t GetNativeSizesLength() const override;
26 virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
28 virtual size_t SizeOfSourceWithComputedFallback(
29 SizeOfState& aState) const override;
30 virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
31 MallocSizeOf aMallocSizeOf) const override;
33 virtual void IncrementAnimationConsumers() override;
34 virtual void DecrementAnimationConsumers() override;
35 #ifdef DEBUG
36 virtual uint32_t GetAnimationConsumers() override;
37 #endif
39 virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
40 nsISupports* aContext,
41 nsIInputStream* aInStr,
42 uint64_t aSourceOffset,
43 uint32_t aCount) override;
44 virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
45 nsISupports* aContext, nsresult aStatus,
46 bool aLastPart) override;
48 virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) override;
50 virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
51 virtual uint64_t InnerWindowID() const override;
53 virtual bool HasError() override;
54 virtual void SetHasError() override;
56 nsIURI* GetURI() const override;
58 protected:
59 explicit ImageWrapper(Image* aInnerImage) : mInnerImage(aInnerImage) {
60 MOZ_ASSERT(aInnerImage, "Need an image to wrap");
63 virtual ~ImageWrapper() {}
65 /**
66 * Returns a weak reference to the inner image wrapped by this ImageWrapper.
68 Image* InnerImage() const { return mInnerImage.get(); }
70 void SetInnerImage(Image* aInnerImage) {
71 MOZ_ASSERT(aInnerImage, "Need an image to wrap");
72 mInnerImage = aInnerImage;
75 private:
76 RefPtr<Image> mInnerImage;
79 } // namespace image
80 } // namespace mozilla
82 #endif // mozilla_image_ImageWrapper_h