summaryrefslogtreecommitdiffstats
path: root/widget/nsScreenManagerProxy.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /widget/nsScreenManagerProxy.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'widget/nsScreenManagerProxy.h')
-rw-r--r--widget/nsScreenManagerProxy.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/widget/nsScreenManagerProxy.h b/widget/nsScreenManagerProxy.h
new file mode 100644
index 000000000..bcfa387a4
--- /dev/null
+++ b/widget/nsScreenManagerProxy.h
@@ -0,0 +1,67 @@
+/* -*- 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/. */
+
+#ifndef nsScreenManagerProxy_h
+#define nsScreenManagerProxy_h
+
+#include "nsIScreenManager.h"
+#include "mozilla/dom/PScreenManagerChild.h"
+#include "mozilla/dom/TabChild.h"
+#include "ScreenProxy.h"
+
+/**
+ * The nsScreenManagerProxy is used by the content process to get
+ * information about system screens. It uses the PScreenManager protocol
+ * to communicate with a PScreenManagerParent to get this information,
+ * and also caches the information it gets back.
+ *
+ * We cache both the system screen information that nsIScreenManagers
+ * provide, as well as the nsIScreens that callers can query for.
+ *
+ * Both of these caches are invalidated on the next tick of the event
+ * loop.
+ */
+class nsScreenManagerProxy final : public nsIScreenManager,
+ public mozilla::dom::PScreenManagerChild
+{
+public:
+ nsScreenManagerProxy();
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSISCREENMANAGER
+
+private:
+ ~nsScreenManagerProxy() {};
+
+ bool EnsureCacheIsValid();
+ void InvalidateCacheOnNextTick();
+ void InvalidateCache();
+
+ uint32_t mNumberOfScreens;
+ float mSystemDefaultScale;
+ bool mCacheValid;
+ bool mCacheWillInvalidate;
+
+ RefPtr<mozilla::widget::ScreenProxy> mPrimaryScreen;
+
+ // nsScreenManagerProxy caches the results to repeated calls to
+ // ScreenForNativeWidget, which can be triggered indirectly by
+ // web content using the DOM Screen API. This allows us to bypass
+ // a lot of IPC traffic.
+ //
+ // The cache stores ScreenProxy's mapped to the TabChild that
+ // asked for the ScreenForNativeWidget was called with via
+ // ScreenCacheEntry's. The cache is cleared on the next tick of
+ // the event loop.
+ struct ScreenCacheEntry
+ {
+ RefPtr<mozilla::widget::ScreenProxy> mScreenProxy;
+ RefPtr<mozilla::dom::TabChild> mTabChild;
+ };
+
+ nsTArray<ScreenCacheEntry> mScreenCache;
+};
+
+#endif // nsScreenManagerProxy_h