Backed out 2 changesets (bug 1821884) for causing bc failures on browser_pointerlock_...
[gecko.git] / image / MultipartImage.h
blobd4dbb845c07d18426cf57cdf67c8e8a3910b0224
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_MultipartImage_h
7 #define mozilla_image_MultipartImage_h
9 #include "ImageWrapper.h"
10 #include "IProgressObserver.h"
11 #include "ProgressTracker.h"
13 namespace mozilla {
14 namespace image {
16 class NextPartObserver;
18 /**
19 * An Image wrapper that implements support for multipart/x-mixed-replace
20 * images.
22 class MultipartImage : public ImageWrapper, public IProgressObserver {
23 public:
24 MOZ_DECLARE_REFCOUNTED_TYPENAME(MultipartImage)
25 // We need to always declare refcounting here, because
26 // IProgressObserver has pure-virtual refcounting.
27 NS_DECL_ISUPPORTS_INHERITED
29 void BeginTransitionToPart(Image* aNextPart);
31 // Overridden ImageWrapper methods:
32 virtual already_AddRefed<imgIContainer> Unwrap() override;
33 virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
34 virtual void SetProgressTracker(ProgressTracker* aTracker) override;
35 virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
36 nsIInputStream* aInStr,
37 uint64_t aSourceOffset,
38 uint32_t aCount) override;
39 virtual nsresult OnImageDataComplete(nsIRequest* aRequest, nsresult aStatus,
40 bool aLastPart) override;
42 // We don't support locking or track animation consumers for individual parts,
43 // so we override these methods to do nothing.
44 NS_IMETHOD LockImage() override { return NS_OK; }
45 NS_IMETHOD UnlockImage() override { return NS_OK; }
46 virtual void IncrementAnimationConsumers() override {}
47 virtual void DecrementAnimationConsumers() override {}
48 #ifdef DEBUG
49 virtual uint32_t GetAnimationConsumers() override { return 1; }
50 #endif
52 // Overridden IProgressObserver methods:
53 virtual void Notify(int32_t aType, const nsIntRect* aRect = nullptr) override;
54 virtual void OnLoadComplete(bool aLastPart) override;
55 virtual void SetHasImage() override;
56 virtual bool NotificationsDeferred() const override;
57 virtual void MarkPendingNotify() override;
58 virtual void ClearPendingNotify() override;
60 protected:
61 virtual ~MultipartImage();
63 private:
64 friend class ImageFactory;
65 friend class NextPartObserver;
67 explicit MultipartImage(Image* aFirstPart);
68 void Init();
70 void FinishTransition();
72 RefPtr<ProgressTracker> mTracker;
73 RefPtr<NextPartObserver> mNextPartObserver;
74 RefPtr<Image> mNextPart;
75 bool mPendingNotify : 1;
78 } // namespace image
79 } // namespace mozilla
81 #endif // mozilla_image_MultipartImage_h