Bug 1700051: part 35) Reduce accessibility of `mSoftText.mDOMMapping` to `private...
[gecko.git] / dom / base / ImageTracker.h
blobca060d71a8467ee2d5b358570eeeba90cd7f82de
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* table of images used in a document, for batch locking/unlocking and
8 * animating */
10 #ifndef mozilla_dom_ImageTracker
11 #define mozilla_dom_ImageTracker
13 #include "nsTHashMap.h"
14 #include "nsHashKeys.h"
16 class imgIRequest;
17 namespace mozilla {
18 struct MediaFeatureChange;
21 namespace mozilla {
22 namespace dom {
25 * Image Tracking
27 * Style and content images register their imgIRequests with their document's
28 * image tracker, so that we can efficiently tell all descendant images when
29 * they are and are not visible. When an image is on-screen, we want to call
30 * LockImage() on it so that it doesn't do things like discarding frame data
31 * to save memory. The PresShell informs its document's image tracker whether
32 * its images should be locked or not via SetLockingState().
34 * See bug 512260.
36 class ImageTracker {
37 public:
38 ImageTracker();
39 ImageTracker(const ImageTracker&) = delete;
40 ImageTracker& operator=(const ImageTracker&) = delete;
42 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageTracker)
44 nsresult Add(imgIRequest* aImage);
46 enum { REQUEST_DISCARD = 0x1 };
47 nsresult Remove(imgIRequest* aImage, uint32_t aFlags = 0);
49 // Makes the images on this document locked/unlocked. By default, the locking
50 // state is unlocked/false.
51 nsresult SetLockingState(bool aLocked);
53 // Makes the images on this document capable of having their animation
54 // active or suspended. An Image will animate as long as at least one of its
55 // owning Documents needs it to animate; otherwise it can suspend.
56 void SetAnimatingState(bool aAnimating);
58 void RequestDiscardAll();
59 void MediaFeatureValuesChangedAllDocuments(const MediaFeatureChange&);
61 private:
62 ~ImageTracker();
64 nsTHashMap<nsPtrHashKey<imgIRequest>, uint32_t> mImages;
65 bool mLocking;
66 bool mAnimating;
69 } // namespace dom
70 } // namespace mozilla
72 #endif // mozilla_dom_ImageTracker