Bug 1839316: part 5) Guard the "fetchpriority" attribute behind a pref. r=kershaw...
[gecko.git] / widget / ScreenManager.h
blob5fda2a29befac0388b1cc53082442dcd35dfa951
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 #ifndef mozilla_widget_ScreenManager_h
8 #define mozilla_widget_ScreenManager_h
10 #include "nsIScreenManager.h"
12 #include "mozilla/RefPtr.h"
13 #include "mozilla/UniquePtr.h"
14 #include "mozilla/widget/Screen.h"
15 #include "nsTArray.h"
17 namespace mozilla {
18 namespace dom {
19 class ContentParent;
20 class ScreenDetails;
21 } // namespace dom
22 } // namespace mozilla
24 namespace mozilla {
25 namespace widget {
27 class ScreenManager final : public nsIScreenManager {
28 public:
29 class Helper {
30 public:
31 virtual ~Helper() = default;
34 public:
35 NS_DECL_ISUPPORTS
36 NS_DECL_NSISCREENMANAGER
38 static ScreenManager& GetSingleton();
39 static already_AddRefed<ScreenManager> GetAddRefedSingleton();
41 void SetHelper(UniquePtr<Helper> aHelper);
42 static void Refresh(nsTArray<RefPtr<Screen>>&& aScreens);
43 void Refresh(nsTArray<mozilla::dom::ScreenDetails>&& aScreens);
44 void CopyScreensToRemote(mozilla::dom::ContentParent* aContentParent);
45 already_AddRefed<Screen> GetPrimaryScreen();
46 already_AddRefed<Screen> ScreenForRect(const DesktopIntRect& aRect);
48 const nsTArray<RefPtr<Screen>>& CurrentScreenList() const {
49 return mScreenList;
52 private:
53 ScreenManager();
54 virtual ~ScreenManager();
56 void RefreshInternal(nsTArray<RefPtr<Screen>>&& aScreens);
57 template <class Range>
58 void CopyScreensToRemoteRange(Range aRemoteRange);
59 void CopyScreensToAllRemotesIfIsParent();
61 AutoTArray<RefPtr<Screen>, 4> mScreenList;
62 UniquePtr<Helper> mHelper;
65 } // namespace widget
66 } // namespace mozilla
68 #endif // mozilla_widget_ScreenManager_h