2015-01-07 12:37:20 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2015-05-15 06:52:05 +03:00
|
|
|
#ifndef mozilla_image_MultipartImage_h
|
|
|
|
#define mozilla_image_MultipartImage_h
|
2015-01-07 12:37:20 +03:00
|
|
|
|
|
|
|
#include "ImageWrapper.h"
|
|
|
|
#include "IProgressObserver.h"
|
|
|
|
#include "ProgressTracker.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace image {
|
|
|
|
|
|
|
|
class NextPartObserver;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An Image wrapper that implements support for multipart/x-mixed-replace
|
|
|
|
* images.
|
|
|
|
*/
|
|
|
|
class MultipartImage : public ImageWrapper, public IProgressObserver {
|
|
|
|
public:
|
|
|
|
MOZ_DECLARE_REFCOUNTED_TYPENAME(MultipartImage)
|
2018-02-12 23:44:40 +03:00
|
|
|
// We need to always declare refcounting here, because
|
|
|
|
// IProgressObserver has pure-virtual refcounting.
|
2015-07-07 15:10:00 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2015-01-07 12:37:20 +03:00
|
|
|
|
|
|
|
void BeginTransitionToPart(Image* aNextPart);
|
|
|
|
|
|
|
|
// Overridden ImageWrapper methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual already_AddRefed<imgIContainer> Unwrap() override;
|
|
|
|
virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
|
|
|
|
virtual void SetProgressTracker(ProgressTracker* aTracker) override;
|
2015-01-07 12:37:20 +03:00
|
|
|
virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
|
|
|
|
nsIInputStream* aInStr,
|
|
|
|
uint64_t aSourceOffset,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aCount) override;
|
2021-11-24 14:25:41 +03:00
|
|
|
virtual nsresult OnImageDataComplete(nsIRequest* aRequest, nsresult aStatus,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aLastPart) override;
|
2015-01-07 12:37:20 +03:00
|
|
|
|
|
|
|
// We don't support locking or track animation consumers for individual parts,
|
|
|
|
// so we override these methods to do nothing.
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD LockImage() override { return NS_OK; }
|
|
|
|
NS_IMETHOD UnlockImage() override { return NS_OK; }
|
|
|
|
virtual void IncrementAnimationConsumers() override {}
|
|
|
|
virtual void DecrementAnimationConsumers() override {}
|
2015-01-07 12:37:20 +03:00
|
|
|
#ifdef DEBUG
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint32_t GetAnimationConsumers() override { return 1; }
|
2015-01-07 12:37:20 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Overridden IProgressObserver methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Notify(int32_t aType, const nsIntRect* aRect = nullptr) override;
|
|
|
|
virtual void OnLoadComplete(bool aLastPart) override;
|
|
|
|
virtual void SetHasImage() override;
|
|
|
|
virtual bool NotificationsDeferred() const override;
|
2018-02-07 15:27:27 +03:00
|
|
|
virtual void MarkPendingNotify() override;
|
|
|
|
virtual void ClearPendingNotify() override;
|
2015-01-07 12:37:20 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~MultipartImage();
|
|
|
|
|
|
|
|
private:
|
2015-04-29 02:32:02 +03:00
|
|
|
friend class ImageFactory;
|
2015-01-07 12:37:20 +03:00
|
|
|
friend class NextPartObserver;
|
|
|
|
|
2015-04-29 02:32:02 +03:00
|
|
|
explicit MultipartImage(Image* aFirstPart);
|
|
|
|
void Init();
|
|
|
|
|
2015-01-07 12:37:20 +03:00
|
|
|
void FinishTransition();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ProgressTracker> mTracker;
|
|
|
|
RefPtr<NextPartObserver> mNextPartObserver;
|
|
|
|
RefPtr<Image> mNextPart;
|
2018-02-07 15:27:27 +03:00
|
|
|
bool mPendingNotify : 1;
|
2015-01-07 12:37:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-05-15 06:52:05 +03:00
|
|
|
#endif // mozilla_image_MultipartImage_h
|