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)
|
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,
|
|
|
|
nsISupports* aContext,
|
|
|
|
nsIInputStream* aInStr,
|
|
|
|
uint64_t aSourceOffset,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aCount) override;
|
2015-01-07 12:37:20 +03:00
|
|
|
virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
|
|
|
|
nsISupports* aContext,
|
|
|
|
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:
|
|
|
|
virtual void Notify(int32_t aType,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsIntRect* aRect = nullptr) override;
|
|
|
|
virtual void OnLoadComplete(bool aLastPart) override;
|
|
|
|
virtual void SetHasImage() override;
|
|
|
|
virtual bool NotificationsDeferred() const override;
|
|
|
|
virtual void SetNotificationsDeferred(bool aDeferNotifications) override;
|
2015-01-07 12:37:20 +03:00
|
|
|
|
|
|
|
// We don't allow multipart images to block onload, so we override these
|
|
|
|
// methods to do nothing.
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void BlockOnload() override { }
|
|
|
|
virtual void UnblockOnload() 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;
|
2015-01-07 12:37:20 +03:00
|
|
|
bool mDeferNotifications : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-05-15 06:52:05 +03:00
|
|
|
#endif // mozilla_image_MultipartImage_h
|