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