IProgressObserver.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #ifndef mozilla_image_IProgressObserver_h
  6. #define mozilla_image_IProgressObserver_h
  7. #include "mozilla/WeakPtr.h"
  8. #include "nsISupports.h"
  9. #include "nsRect.h"
  10. namespace mozilla {
  11. namespace image {
  12. /**
  13. * An interface for observing changes to image state, as reported by
  14. * ProgressTracker.
  15. *
  16. * This is the ImageLib-internal version of imgINotificationObserver,
  17. * essentially, with implementation details that code outside of ImageLib
  18. * shouldn't see.
  19. *
  20. * XXX(seth): It's preferable to avoid adding anything to this interface if
  21. * possible. In the long term, it would be ideal to get to a place where we can
  22. * just use the imgINotificationObserver interface internally as well.
  23. */
  24. class IProgressObserver : public SupportsWeakPtr<IProgressObserver>
  25. {
  26. public:
  27. MOZ_DECLARE_WEAKREFERENCE_TYPENAME(IProgressObserver)
  28. // Subclasses may or may not be XPCOM classes, so we just require that they
  29. // implement AddRef and Release.
  30. NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
  31. NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
  32. // imgINotificationObserver methods:
  33. virtual void Notify(int32_t aType, const nsIntRect* aRect = nullptr) = 0;
  34. virtual void OnLoadComplete(bool aLastPart) = 0;
  35. // imgIOnloadBlocker methods:
  36. virtual void BlockOnload() = 0;
  37. virtual void UnblockOnload() = 0;
  38. // Other, internal-only methods:
  39. virtual void SetHasImage() = 0;
  40. virtual bool NotificationsDeferred() const = 0;
  41. virtual void SetNotificationsDeferred(bool aDeferNotifications) = 0;
  42. protected:
  43. virtual ~IProgressObserver() { }
  44. };
  45. } // namespace image
  46. } // namespace mozilla
  47. #endif // mozilla_image_IProgressObserver_h