--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -56,16 +56,17 @@
#include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/ContentProcessController.h"
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layout/RenderFrameChild.h"
#include "mozilla/net/NeckoChild.h"
#include "mozilla/net/CaptivePortalService.h"
#include "mozilla/plugins/PluginInstanceParent.h"
#include "mozilla/plugins/PluginModuleParent.h"
+#include "mozilla/widget/ScreenManager.h"
#include "mozilla/widget/WidgetMessageUtils.h"
#include "nsBaseDragService.h"
#include "mozilla/media/MediaChild.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/WebBrowserPersistDocumentChild.h"
#include "imgLoader.h"
#include "GMPServiceChild.h"
@@ -94,17 +95,16 @@
#include "nsIDragService.h"
#include "nsIIPCBackgroundChildCreateCallback.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIMemoryReporter.h"
#include "nsIMemoryInfoDumper.h"
#include "nsIMutable.h"
#include "nsIObserverService.h"
#include "nsIScriptSecurityManager.h"
-#include "nsScreenManagerProxy.h"
#include "nsMemoryInfoDumper.h"
#include "nsServiceManagerUtils.h"
#include "nsStyleSheetService.h"
#include "nsVariant.h"
#include "nsXULAppAPI.h"
#include "nsIScriptError.h"
#include "nsIConsoleService.h"
#include "nsJSEnvironment.h"
@@ -1743,37 +1743,16 @@ ContentChild::AllocPParentToChildStreamC
}
bool
ContentChild::DeallocPParentToChildStreamChild(PParentToChildStreamChild* aActor)
{
return nsIContentChild::DeallocPParentToChildStreamChild(aActor);
}
-PScreenManagerChild*
-ContentChild::AllocPScreenManagerChild(float* aSystemDefaultScale,
- bool* aSuccess)
-{
- // The ContentParent should never attempt to allocate the
- // nsScreenManagerProxy. Instead, the nsScreenManagerProxy
- // service is requested and instantiated via XPCOM, and the
- // constructor of nsScreenManagerProxy sets up the IPC connection.
- MOZ_CRASH("Should never get here!");
- return nullptr;
-}
-
-bool
-ContentChild::DeallocPScreenManagerChild(PScreenManagerChild* aService)
-{
- // nsScreenManagerProxy is AddRef'd in its constructor.
- nsScreenManagerProxy *child = static_cast<nsScreenManagerProxy*>(aService);
- child->Release();
- return true;
-}
-
PPSMContentDownloaderChild*
ContentChild::AllocPPSMContentDownloaderChild(const uint32_t& aCertType)
{
// NB: We don't need aCertType in the child actor.
RefPtr<PSMContentDownloaderChild> child = new PSMContentDownloaderChild();
return child.forget().take();
}
@@ -3262,14 +3241,21 @@ ContentChild::AsyncOpenAnonymousTemporar
mozilla::ipc::IPCResult
ContentChild::RecvSetPermissionsWithKey(const nsCString& aPermissionKey,
nsTArray<IPC::Permission>&& aPerms)
{
nsCOMPtr<nsIPermissionManager> permissionManager =
services::GetPermissionManager();
permissionManager->SetPermissionsWithKey(aPermissionKey, aPerms);
-
+ return IPC_OK();
+}
+
+mozilla::ipc::IPCResult
+ContentChild::RecvRefreshScreens(nsTArray<ScreenDetails>&& aScreens)
+{
+ ScreenManager& screenManager = ScreenManager::GetSingleton();
+ screenManager.Refresh(Move(aScreens));
return IPC_OK();
}
} // namespace dom
} // namespace mozilla
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -237,22 +237,16 @@ public:
SendPChildToParentStreamConstructor(PChildToParentStreamChild*) override;
virtual PChildToParentStreamChild* AllocPChildToParentStreamChild() override;
virtual bool DeallocPChildToParentStreamChild(PChildToParentStreamChild*) override;
virtual PParentToChildStreamChild* AllocPParentToChildStreamChild() override;
virtual bool DeallocPParentToChildStreamChild(PParentToChildStreamChild*) override;
- virtual PScreenManagerChild*
- AllocPScreenManagerChild(float* aSystemDefaultScale,
- bool* aSuccess) override;
-
- virtual bool DeallocPScreenManagerChild(PScreenManagerChild*) override;
-
virtual PPSMContentDownloaderChild*
AllocPPSMContentDownloaderChild( const uint32_t& aCertType) override;
virtual bool
DeallocPPSMContentDownloaderChild(PPSMContentDownloaderChild* aDownloader) override;
virtual PExternalHelperAppChild*
AllocPExternalHelperAppChild(const OptionalURIParams& uri,
@@ -471,16 +465,19 @@ public:
const IPC::Principal& aPrincipal) override;
virtual mozilla::ipc::IPCResult RecvActivate(PBrowserChild* aTab) override;
virtual mozilla::ipc::IPCResult RecvDeactivate(PBrowserChild* aTab) override;
virtual mozilla::ipc::IPCResult RecvParentActivated(PBrowserChild* aTab, const bool& aActivated) override;
+ mozilla::ipc::IPCResult
+ RecvRefreshScreens(nsTArray<ScreenDetails>&& aScreens) override;
+
// Get the directory for IndexedDB files. We query the parent for this and
// cache the value
nsString &GetIndexedDBPath();
ContentParentId GetID() const { return mID; }
#if defined(XP_WIN) && defined(ACCESSIBILITY)
uint32_t GetMsaaID() const { return mMsaaID; }
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -92,16 +92,17 @@
#include "mozilla/ProcessHangMonitor.h"
#include "mozilla/ProcessHangMonitorIPC.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TelemetryIPC.h"
#include "mozilla/WebBrowserPersistDocumentParent.h"
+#include "mozilla/widget/ScreenManager.h"
#include "mozilla/Unused.h"
#include "nsAnonymousTemporaryFile.h"
#include "nsAppRunner.h"
#include "nsCDefaultURIFixup.h"
#include "nsCExternalHandlerService.h"
#include "nsCOMPtr.h"
#include "nsChromeRegistryChrome.h"
#include "nsConsoleMessage.h"
@@ -157,17 +158,16 @@
#include "nsServiceManagerUtils.h"
#include "nsStyleSheetService.h"
#include "nsThreadUtils.h"
#include "nsToolkitCompsCID.h"
#include "nsWidgetsCID.h"
#include "PreallocatedProcessManager.h"
#include "ProcessPriorityManager.h"
#include "SandboxHal.h"
-#include "ScreenManagerParent.h"
#include "SourceSurfaceRawData.h"
#include "TabParent.h"
#include "URIUtils.h"
#include "nsIWebBrowserChrome.h"
#include "nsIDocShell.h"
#include "nsDocShell.h"
#include "nsOpenURIInFrameParams.h"
#include "mozilla/net/NeckoMessageUtils.h"
@@ -2228,16 +2228,19 @@ ContentParent::InitInternal(ProcessPrior
DataStorage::GetAllFileNames(storageFiles);
for (auto& file : storageFiles) {
dom::DataStorageEntry entry;
entry.filename() = file;
RefPtr<DataStorage> storage = DataStorage::Get(file);
storage->GetAll(&entry.items());
xpcomInit.dataStorage().AppendElement(Move(entry));
}
+ // Must send screen info before send initialData
+ ScreenManager& screenManager = ScreenManager::GetSingleton();
+ screenManager.CopyScreensToRemote(this);
Unused << SendSetXPCOMProcessAttributes(xpcomInit, initialData, lnfCache);
if (aSendRegisteredChrome) {
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
nsChromeRegistryChrome* chromeRegistry =
static_cast<nsChromeRegistryChrome*>(registrySvc.get());
chromeRegistry->SendRegisteredChrome(this);
@@ -3131,30 +3134,16 @@ ContentParent::AllocPParentToChildStream
}
bool
ContentParent::DeallocPParentToChildStreamParent(PParentToChildStreamParent* aActor)
{
return nsIContentParent::DeallocPParentToChildStreamParent(aActor);
}
-PScreenManagerParent*
-ContentParent::AllocPScreenManagerParent(float* aSystemDefaultScale,
- bool* aSuccess)
-{
- return new ScreenManagerParent(aSystemDefaultScale, aSuccess);
-}
-
-bool
-ContentParent::DeallocPScreenManagerParent(PScreenManagerParent* aActor)
-{
- delete aActor;
- return true;
-}
-
PPSMContentDownloaderParent*
ContentParent::AllocPPSMContentDownloaderParent(const uint32_t& aCertType)
{
RefPtr<PSMContentDownloaderParent> downloader =
new PSMContentDownloaderParent(aCertType);
return downloader.forget().take();
}
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -441,23 +441,16 @@ public:
virtual PFileDescriptorSetParent*
SendPFileDescriptorSetConstructor(const FileDescriptor&) override;
virtual PParentToChildStreamParent* AllocPParentToChildStreamParent() override;
virtual bool
DeallocPParentToChildStreamParent(PParentToChildStreamParent* aActor) override;
- virtual PScreenManagerParent*
- AllocPScreenManagerParent(float* aSystemDefaultScale,
- bool* aSuccess) override;
-
- virtual bool
- DeallocPScreenManagerParent(PScreenManagerParent* aActor) override;
-
virtual PHalParent* AllocPHalParent() override;
virtual mozilla::ipc::IPCResult RecvPHalConstructor(PHalParent* aActor) override
{
return PContentParent::RecvPHalConstructor(aActor);
}
virtual PHeapSnapshotTempFileHelperParent*
--- a/dom/ipc/DOMTypes.ipdlh
+++ b/dom/ipc/DOMTypes.ipdlh
@@ -11,16 +11,21 @@ include IPCStream;
include ProtocolTypes;
using struct mozilla::void_t
from "ipc/IPCMessageUtils.h";
using struct mozilla::SerializedStructuredCloneBuffer
from "ipc/IPCMessageUtils.h";
+using LayoutDeviceIntRect from "Units.h";
+using DesktopIntRect from "Units.h";
+using DesktopToLayoutDeviceScale from "Units.h";
+using CSSToLayoutDeviceScale from "Units.h";
+
namespace mozilla {
namespace dom {
struct MessagePortIdentifier
{
nsID uuid;
nsID destinationUuid;
uint32_t sequenceId;
@@ -173,10 +178,21 @@ struct IPCDataTransferItem
IPCDataTransferData data;
};
struct IPCDataTransfer
{
IPCDataTransferItem[] items;
};
+struct ScreenDetails {
+ LayoutDeviceIntRect rect;
+ DesktopIntRect rectDisplayPix;
+ LayoutDeviceIntRect availRect;
+ DesktopIntRect availRectDisplayPix;
+ int32_t pixelDepth;
+ int32_t colorDepth;
+ DesktopToLayoutDeviceScale contentsScaleFactor;
+ CSSToLayoutDeviceScale defaultCSSScaleFactor;
+};
+
} // namespace dom
} // namespace mozilla
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -23,17 +23,16 @@ include PPrintingTypes;
include PTabContext;
using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
using class mozilla::gfx::Matrix from "mozilla/gfx/Matrix.h";
using struct gfxSize from "gfxPoint.h";
using CSSRect from "Units.h";
using CSSSize from "Units.h";
-using mozilla::LayoutDeviceIntRect from "Units.h";
using mozilla::LayoutDeviceIntPoint from "Units.h";
using mozilla::LayoutDevicePoint from "Units.h";
using mozilla::ScreenIntPoint from "Units.h";
using ScreenIntSize from "Units.h";
using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
using struct mozilla::layers::ScrollableLayerGuid from "FrameMetrics.h";
using struct mozilla::layers::ZoomConstraints from "FrameMetrics.h";
using mozilla::layers::MaybeZoomConstraints from "FrameMetrics.h";
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -25,17 +25,16 @@ include protocol PGMPContent;
include protocol PGMPService;
include protocol PPluginModule;
include protocol PGMP;
include protocol PPrinting;
include protocol PChildToParentStream;
include protocol PParentToChildStream;
include protocol POfflineCacheUpdate;
include protocol PRenderFrame;
-include protocol PScreenManager;
include protocol PSpeechSynthesis;
include protocol PStorage;
include protocol PTestShell;
include protocol PJavaScript;
include protocol PRemoteSpellcheckEngine;
include protocol PWebBrowserPersistDocument;
include protocol PWebrtcGlobal;
include protocol PPresentation;
@@ -284,17 +283,16 @@ nested(upto inside_cpow) sync protocol P
manages PHandlerService;
manages PHeapSnapshotTempFileHelper;
manages PMedia;
manages PNecko;
manages POfflineCacheUpdate;
manages PPrinting;
manages PChildToParentStream;
manages PParentToChildStream;
- manages PScreenManager;
manages PSpeechSynthesis;
manages PStorage;
manages PTestShell;
manages PJavaScript;
manages PRemoteSpellcheckEngine;
manages PWebBrowserPersistDocument;
manages PWebrtcGlobal;
manages PPresentation;
@@ -590,16 +588,18 @@ child:
async ParentActivated(PBrowser aTab, bool aActivated);
async PParentToChildStream();
async ProvideAnonymousTemporaryFile(uint64_t aID, FileDescOrError aFD);
async SetPermissionsWithKey(nsCString aPermissionKey, Permission[] aPermissions);
+ async RefreshScreens(ScreenDetails[] aScreens);
+
parent:
async InitBackground(Endpoint<PBackgroundParent> aEndpoint);
sync CreateChildProcess(IPCTabContext context,
ProcessPriority priority,
TabId openerTabId)
returns (ContentParentId cpId, bool isForBrowser, TabId tabId);
sync BridgeToChildProcess(ContentParentId cpId)
@@ -706,20 +706,16 @@ parent:
async PHeapSnapshotTempFileHelper();
async PNecko();
async PPrinting();
async PChildToParentStream();
- nested(inside_sync) sync PScreenManager()
- returns (float systemDefaultScale,
- bool success);
-
async PSpeechSynthesis();
nested(inside_cpow) async PStorage();
async PMedia();
async PWebrtcGlobal();
deleted file mode 100644
--- a/dom/ipc/PScreenManager.ipdl
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
-/* 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/. */
-
-include protocol PBrowser;
-include protocol PContent;
-
-include "mozilla/GfxMessageUtils.h";
-
-using nsIntRect from "nsRect.h";
-using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
-
-namespace mozilla {
-namespace dom {
-
-struct ScreenDetails {
- uint32_t id;
- nsIntRect rect;
- nsIntRect rectDisplayPix;
- nsIntRect availRect;
- nsIntRect availRectDisplayPix;
- int32_t pixelDepth;
- int32_t colorDepth;
- double contentsScaleFactor;
- double defaultCSSScaleFactor;
-};
-
-nested(upto inside_cpow) sync protocol PScreenManager
-{
- manager PContent;
-
-parent:
- nested(inside_sync) sync Refresh()
- returns (float systemDefaultScale,
- bool success);
-
- nested(inside_cpow) sync ScreenRefresh(uint32_t aId)
- returns (ScreenDetails screen,
- bool success);
-
- nested(inside_sync) sync GetPrimaryScreen()
- returns (ScreenDetails screen,
- bool success);
-
- nested(inside_sync) sync ScreenForRect(int32_t aLeft,
- int32_t aTop,
- int32_t aWidth,
- int32_t aHeight)
- returns (ScreenDetails screen,
- bool success);
-
- nested(inside_cpow) sync ScreenForBrowser(TabId aTabId)
- returns (ScreenDetails screen,
- bool success);
-
-child:
- async __delete__();
-};
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/ipc/ScreenManagerParent.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#include "mozilla/dom/ContentParent.h"
-#include "mozilla/dom/TabParent.h"
-#include "mozilla/Unused.h"
-#include "nsIWidget.h"
-#include "nsServiceManagerUtils.h"
-#include "ScreenManagerParent.h"
-#include "ContentProcessManager.h"
-
-namespace mozilla {
-namespace dom {
-
-static const char *sScreenManagerContractID = "@mozilla.org/gfx/screenmanager;1";
-
-ScreenManagerParent::ScreenManagerParent(float* aSystemDefaultScale,
- bool* aSuccess)
-{
- mScreenMgr = do_GetService(sScreenManagerContractID);
- if (!mScreenMgr) {
- MOZ_CRASH("Couldn't get nsIScreenManager from ScreenManagerParent.");
- }
-
- Unused << RecvRefresh(aSystemDefaultScale, aSuccess);
-}
-
-mozilla::ipc::IPCResult
-ScreenManagerParent::RecvRefresh(float* aSystemDefaultScale,
- bool* aSuccess)
-{
- *aSuccess = false;
-
- nsresult rv = mScreenMgr->GetSystemDefaultScale(aSystemDefaultScale);
- if (NS_FAILED(rv)) {
- return IPC_OK();
- }
-
- *aSuccess = true;
- return IPC_OK();
-}
-
-mozilla::ipc::IPCResult
-ScreenManagerParent::RecvScreenRefresh(const uint32_t& aId,
- ScreenDetails* aRetVal,
- bool* aSuccess)
-{
- *aSuccess = false;
-
- nsCOMPtr<nsIScreen> screen;
- nsresult rv = mScreenMgr->ScreenForId(aId, getter_AddRefs(screen));
- if (NS_FAILED(rv)) {
- return IPC_OK();
- }
-
- ScreenDetails details;
- Unused << ExtractScreenDetails(screen, details);
-
- *aRetVal = details;
- *aSuccess = true;
- return IPC_OK();
-}
-
-mozilla::ipc::IPCResult
-ScreenManagerParent::RecvGetPrimaryScreen(ScreenDetails* aRetVal,
- bool* aSuccess)
-{
- *aSuccess = false;
-
- nsCOMPtr<nsIScreen> screen;
- nsresult rv = mScreenMgr->GetPrimaryScreen(getter_AddRefs(screen));
-
- NS_ENSURE_SUCCESS(rv, IPC_OK());
-
- ScreenDetails details;
- if (!ExtractScreenDetails(screen, details)) {
- return IPC_OK();
- }
-
- *aRetVal = details;
- *aSuccess = true;
- return IPC_OK();
-}
-
-mozilla::ipc::IPCResult
-ScreenManagerParent::RecvScreenForRect(const int32_t& aLeft,
- const int32_t& aTop,
- const int32_t& aWidth,
- const int32_t& aHeight,
- ScreenDetails* aRetVal,
- bool* aSuccess)
-{
- *aSuccess = false;
-
- nsCOMPtr<nsIScreen> screen;
- nsresult rv = mScreenMgr->ScreenForRect(aLeft, aTop, aWidth, aHeight, getter_AddRefs(screen));
-
- NS_ENSURE_SUCCESS(rv, IPC_OK());
-
- ScreenDetails details;
- if (!ExtractScreenDetails(screen, details)) {
- return IPC_OK();
- }
-
- *aRetVal = details;
- *aSuccess = true;
- return IPC_OK();
-}
-
-mozilla::ipc::IPCResult
-ScreenManagerParent::RecvScreenForBrowser(const TabId& aTabId,
- ScreenDetails* aRetVal,
- bool* aSuccess)
-{
- *aSuccess = false;
-#ifdef MOZ_VALGRIND
- // Zero this so that Valgrind doesn't complain when we send it to another
- // process.
- memset(aRetVal, 0, sizeof(ScreenDetails));
-#endif
-
- // Find the mWidget associated with the tabparent, and then return
- // the nsIScreen it's on.
- ContentParent* cp = static_cast<ContentParent*>(this->Manager());
- ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
- RefPtr<TabParent> tabParent =
- cpm->GetTopLevelTabParentByProcessAndTabId(cp->ChildID(), aTabId);
- if(!tabParent){
- return IPC_FAIL_NO_REASON(this);
- }
-
- nsCOMPtr<nsIWidget> widget = tabParent->GetWidget();
-
- nsCOMPtr<nsIScreen> screen;
- if (widget && widget->GetNativeData(NS_NATIVE_WINDOW)) {
- mScreenMgr->ScreenForNativeWidget(widget->GetNativeData(NS_NATIVE_WINDOW),
- getter_AddRefs(screen));
- } else {
- nsresult rv = mScreenMgr->GetPrimaryScreen(getter_AddRefs(screen));
- if (NS_WARN_IF(NS_FAILED(rv))) {
- return IPC_OK();
- }
- }
-
- NS_ENSURE_TRUE(screen, IPC_OK());
-
- ScreenDetails details;
- if (!ExtractScreenDetails(screen, details)) {
- return IPC_OK();
- }
-
- *aRetVal = details;
- *aSuccess = true;
- return IPC_OK();
-}
-
-bool
-ScreenManagerParent::ExtractScreenDetails(nsIScreen* aScreen, ScreenDetails &aDetails)
-{
- if (!aScreen) {
- return false;
- }
-
- uint32_t id;
- nsresult rv = aScreen->GetId(&id);
- NS_ENSURE_SUCCESS(rv, false);
- aDetails.id() = id;
-
- nsIntRect rect;
- rv = aScreen->GetRect(&rect.x, &rect.y, &rect.width, &rect.height);
- NS_ENSURE_SUCCESS(rv, false);
- aDetails.rect() = rect;
-
- nsIntRect rectDisplayPix;
- rv = aScreen->GetRectDisplayPix(&rectDisplayPix.x, &rectDisplayPix.y,
- &rectDisplayPix.width, &rectDisplayPix.height);
- NS_ENSURE_SUCCESS(rv, false);
- aDetails.rectDisplayPix() = rectDisplayPix;
-
- nsIntRect availRect;
- rv = aScreen->GetAvailRect(&availRect.x, &availRect.y, &availRect.width,
- &availRect.height);
- NS_ENSURE_SUCCESS(rv, false);
- aDetails.availRect() = availRect;
-
- nsIntRect availRectDisplayPix;
- rv = aScreen->GetAvailRectDisplayPix(&availRectDisplayPix.x,
- &availRectDisplayPix.y,
- &availRectDisplayPix.width,
- &availRectDisplayPix.height);
- NS_ENSURE_SUCCESS(rv, false);
- aDetails.availRectDisplayPix() = availRectDisplayPix;
-
- int32_t pixelDepth = 0;
- rv = aScreen->GetPixelDepth(&pixelDepth);
- NS_ENSURE_SUCCESS(rv, false);
- aDetails.pixelDepth() = pixelDepth;
-
- int32_t colorDepth = 0;
- rv = aScreen->GetColorDepth(&colorDepth);
- NS_ENSURE_SUCCESS(rv, false);
- aDetails.colorDepth() = colorDepth;
-
- double contentsScaleFactor = 1.0;
- rv = aScreen->GetContentsScaleFactor(&contentsScaleFactor);
- NS_ENSURE_SUCCESS(rv, false);
- aDetails.contentsScaleFactor() = contentsScaleFactor;
-
- double defaultCSSScaleFactor = 1.0;
- rv = aScreen->GetDefaultCSSScaleFactor(&defaultCSSScaleFactor);
- NS_ENSURE_SUCCESS(rv, false);
- aDetails.defaultCSSScaleFactor() = defaultCSSScaleFactor;
-
- return true;
-}
-
-void
-ScreenManagerParent::ActorDestroy(ActorDestroyReason why)
-{
-}
-
-} // namespace dom
-} // namespace mozilla
-
deleted file mode 100644
--- a/dom/ipc/ScreenManagerParent.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 mozilla_dom_ScreenManagerParent_h
-#define mozilla_dom_ScreenManagerParent_h
-
-#include "mozilla/dom/PScreenManagerParent.h"
-#include "nsIScreenManager.h"
-
-namespace mozilla {
-namespace dom {
-
-class ScreenManagerParent : public PScreenManagerParent
-{
- public:
- ScreenManagerParent(float* aSystemDefaultScale,
- bool* aSuccess);
- ~ScreenManagerParent() {};
-
- virtual mozilla::ipc::IPCResult RecvRefresh(float* aSystemDefaultScale,
- bool* aSuccess) override;
-
- virtual mozilla::ipc::IPCResult RecvScreenRefresh(const uint32_t& aId,
- ScreenDetails* aRetVal,
- bool* aSuccess) override;
-
- virtual void ActorDestroy(ActorDestroyReason aWhy) override;
-
- virtual mozilla::ipc::IPCResult RecvGetPrimaryScreen(ScreenDetails* aRetVal,
- bool* aSuccess) override;
-
- virtual mozilla::ipc::IPCResult RecvScreenForRect(const int32_t& aLeft,
- const int32_t& aTop,
- const int32_t& aWidth,
- const int32_t& aHeight,
- ScreenDetails* aRetVal,
- bool* aSuccess) override;
-
- virtual mozilla::ipc::IPCResult RecvScreenForBrowser(const TabId& aTabId,
- ScreenDetails* aRetVal,
- bool* aSuccess) override;
-
- private:
- bool ExtractScreenDetails(nsIScreen* aScreen, ScreenDetails &aDetails);
- nsCOMPtr<nsIScreenManager> mScreenMgr;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_ScreenManagerParent_h
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -60,17 +60,16 @@ UNIFIED_SOURCES += [
'ContentProcessManager.cpp',
'FilePickerParent.cpp',
'MemoryReportRequest.cpp',
'nsIContentChild.cpp',
'nsIContentParent.cpp',
'PermissionMessageUtils.cpp',
'PreallocatedProcessManager.cpp',
'ProcessPriorityManager.cpp',
- 'ScreenManagerParent.cpp',
'StructuredCloneData.cpp',
'TabChild.cpp',
'TabContext.cpp',
'TabMessageUtils.cpp',
'TabParent.cpp',
'TelemetryScrollProbe.cpp',
'URLClassifierChild.cpp',
'URLClassifierParent.cpp',
@@ -92,17 +91,16 @@ IPDL_SOURCES += [
'PContentBridge.ipdl',
'PContentPermission.ipdlh',
'PContentPermissionRequest.ipdl',
'PCycleCollectWithLogs.ipdl',
'PDocumentRenderer.ipdl',
'PFilePicker.ipdl',
'PPluginWidget.ipdl',
'PProcessHangMonitor.ipdl',
- 'PScreenManager.ipdl',
'PTabContext.ipdlh',
'PURLClassifier.ipdl',
'PURLClassifierInfo.ipdlh',
'ServiceWorkerConfiguration.ipdlh',
]
include('/ipc/chromium/chromium-config.mozbuild')
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -1167,22 +1167,17 @@ NPBool nsPluginInstanceOwner::ConvertPoi
}
return true;
}
nsPresContext* presContext = pluginFrame->PresContext();
double scaleFactor = double(nsPresContext::AppUnitsPerCSSPixel())/
presContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
- nsCOMPtr<nsIScreenManager> screenMgr = do_GetService("@mozilla.org/gfx/screenmanager;1");
- if (!screenMgr) {
- return false;
- }
- nsCOMPtr<nsIScreen> screen;
- screenMgr->ScreenForNativeWidget(widget->GetNativeData(NS_NATIVE_WINDOW), getter_AddRefs(screen));
+ nsCOMPtr<nsIScreen> screen = widget->GetWidgetScreen();
if (!screen) {
return false;
}
int32_t screenX, screenY, screenWidth, screenHeight;
screen->GetRect(&screenX, &screenY, &screenWidth, &screenHeight);
screenHeight /= scaleFactor;
--- a/gfx/src/nsDeviceContext.cpp
+++ b/gfx/src/nsDeviceContext.cpp
@@ -604,31 +604,18 @@ void
nsDeviceContext::FindScreen(nsIScreen** outScreen)
{
if (!mWidget || !mScreenManager) {
return;
}
CheckDPIChange();
- if (mWidget->GetOwningTabChild()) {
- mScreenManager->ScreenForNativeWidget((void *)mWidget->GetOwningTabChild(),
- outScreen);
- }
- else if (mWidget->GetNativeData(NS_NATIVE_WINDOW)) {
- mScreenManager->ScreenForNativeWidget(mWidget->GetNativeData(NS_NATIVE_WINDOW),
- outScreen);
- }
-
-#ifdef MOZ_WIDGET_ANDROID
- if (!(*outScreen)) {
- nsCOMPtr<nsIScreen> screen = mWidget->GetWidgetScreen();
- screen.forget(outScreen);
- }
-#endif
+ nsCOMPtr<nsIScreen> screen = mWidget->GetWidgetScreen();
+ screen.forget(outScreen);
if (!(*outScreen)) {
mScreenManager->GetPrimaryScreen(outScreen);
}
}
bool
nsDeviceContext::CalcPrintingSize()
--- a/ipc/ipdl/sync-messages.ini
+++ b/ipc/ipdl/sync-messages.ini
@@ -879,18 +879,16 @@ description =
[PContent::NSSU2FTokenIsRegistered]
description =
[PContent::NSSU2FTokenRegister]
description =
[PContent::NSSU2FTokenSign]
description =
[PContent::IsSecureURI]
description =
-[PContent::PScreenManager]
-description =
[PContent::PURLClassifier]
description =
[PContent::ClassifyLocal]
description =
[PContent::GetGfxVars]
description =
[PContent::ReadFontList]
description =
@@ -929,26 +927,16 @@ description =
[PContent::UngrabPointer]
description =
[PContent::RemovePermission]
description =
[PContent::GetA11yContentId]
description =
[PContentBridge::SyncMessage]
description =
-[PScreenManager::Refresh]
-description =
-[PScreenManager::ScreenRefresh]
-description =
-[PScreenManager::GetPrimaryScreen]
-description =
-[PScreenManager::ScreenForRect]
-description =
-[PScreenManager::ScreenForBrowser]
-description =
[PGMP::StartPlugin]
description =
[PGMPService::LaunchGMP]
description =
[PGMPService::LaunchGMPForNodeId]
description =
[PGMPService::GetGMPNodeId]
description =
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -1353,23 +1353,16 @@ ScreenConfig()
nsIntSize
PuppetWidget::GetScreenDimensions()
{
nsIntRect r = ScreenConfig().rect();
return nsIntSize(r.width, r.height);
}
NS_IMETHODIMP
-PuppetScreen::GetId(uint32_t *outId)
-{
- *outId = 1;
- return NS_OK;
-}
-
-NS_IMETHODIMP
PuppetScreen::GetRect(int32_t *outLeft, int32_t *outTop,
int32_t *outWidth, int32_t *outHeight)
{
nsIntRect r = ScreenConfig().rect();
*outLeft = r.x;
*outTop = r.y;
*outWidth = r.width;
*outHeight = r.height;
@@ -1404,24 +1397,16 @@ PuppetScreenManager::PuppetScreenManager
mOneScreen = new PuppetScreen(nullptr);
}
PuppetScreenManager::~PuppetScreenManager()
{
}
NS_IMETHODIMP
-PuppetScreenManager::ScreenForId(uint32_t aId,
- nsIScreen** outScreen)
-{
- NS_IF_ADDREF(*outScreen = mOneScreen.get());
- return NS_OK;
-}
-
-NS_IMETHODIMP
PuppetScreenManager::GetPrimaryScreen(nsIScreen** outScreen)
{
NS_IF_ADDREF(*outScreen = mOneScreen.get());
return NS_OK;
}
NS_IMETHODIMP
PuppetScreenManager::ScreenForRect(int32_t inLeft,
@@ -1429,23 +1414,16 @@ PuppetScreenManager::ScreenForRect(int32
int32_t inWidth,
int32_t inHeight,
nsIScreen** outScreen)
{
return GetPrimaryScreen(outScreen);
}
NS_IMETHODIMP
-PuppetScreenManager::ScreenForNativeWidget(void* aWidget,
- nsIScreen** outScreen)
-{
- return GetPrimaryScreen(outScreen);
-}
-
-NS_IMETHODIMP
PuppetScreenManager::GetSystemDefaultScale(float *aDefaultScale)
{
*aDefaultScale = 1.0f;
return NS_OK;
}
nsIWidgetListener*
PuppetWidget::GetCurrentWidgetListener()
--- a/widget/PuppetWidget.h
+++ b/widget/PuppetWidget.h
@@ -438,17 +438,16 @@ private:
};
class PuppetScreen : public nsBaseScreen
{
public:
explicit PuppetScreen(void* nativeScreen);
~PuppetScreen();
- NS_IMETHOD GetId(uint32_t* aId) override;
NS_IMETHOD GetRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight) override;
NS_IMETHOD GetAvailRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight) override;
NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth) override;
NS_IMETHOD GetColorDepth(int32_t* aColorDepth) override;
};
class PuppetScreenManager final : public nsIScreenManager
{
--- a/widget/Screen.cpp
+++ b/widget/Screen.cpp
@@ -1,57 +1,68 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* 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/. */
#include "Screen.h"
+#include "mozilla/dom/DOMTypes.h"
+
namespace mozilla {
namespace widget {
NS_IMPL_ISUPPORTS(Screen, nsIScreen)
-static uint32_t sScreenId = 0;
-
Screen::Screen(LayoutDeviceIntRect aRect, LayoutDeviceIntRect aAvailRect,
uint32_t aPixelDepth, uint32_t aColorDepth,
DesktopToLayoutDeviceScale aContentsScale,
CSSToLayoutDeviceScale aDefaultCssScale)
: mRect(aRect)
, mAvailRect(aAvailRect)
, mRectDisplayPix(RoundedToInt(aRect / aContentsScale))
, mAvailRectDisplayPix(RoundedToInt(aAvailRect / aContentsScale))
, mPixelDepth(aPixelDepth)
, mColorDepth(aColorDepth)
, mContentsScale(aContentsScale)
, mDefaultCssScale(aDefaultCssScale)
- , mId(++sScreenId)
+{
+}
+
+Screen::Screen(const mozilla::dom::ScreenDetails& aScreen)
+ : mRect(aScreen.rect())
+ , mAvailRect(aScreen.availRect())
+ , mRectDisplayPix(aScreen.rectDisplayPix())
+ , mAvailRectDisplayPix(aScreen.availRectDisplayPix())
+ , mPixelDepth(aScreen.pixelDepth())
+ , mColorDepth(aScreen.colorDepth())
+ , mContentsScale(aScreen.contentsScaleFactor())
+ , mDefaultCssScale(aScreen.defaultCSSScaleFactor())
{
}
Screen::Screen(const Screen& aOther)
: mRect(aOther.mRect)
, mAvailRect(aOther.mAvailRect)
, mRectDisplayPix(aOther.mRectDisplayPix)
, mAvailRectDisplayPix(aOther.mAvailRectDisplayPix)
, mPixelDepth(aOther.mPixelDepth)
, mColorDepth(aOther.mColorDepth)
, mContentsScale(aOther.mContentsScale)
, mDefaultCssScale(aOther.mDefaultCssScale)
- , mId(aOther.mId)
{
}
-NS_IMETHODIMP
-Screen::GetId(uint32_t* aOutId)
+mozilla::dom::ScreenDetails
+Screen::ToScreenDetails()
{
- *aOutId = mId;
- return NS_OK;
+ return mozilla::dom::ScreenDetails(
+ mRect, mRectDisplayPix, mAvailRect, mAvailRectDisplayPix,
+ mPixelDepth, mColorDepth, mContentsScale, mDefaultCssScale);
}
NS_IMETHODIMP
Screen::GetRect(int32_t* aOutLeft,
int32_t* aOutTop,
int32_t* aOutWidth,
int32_t* aOutHeight)
{
--- a/widget/Screen.h
+++ b/widget/Screen.h
@@ -7,41 +7,49 @@
#ifndef mozilla_widget_Screen_h
#define mozilla_widget_Screen_h
#include "nsIScreen.h"
#include "Units.h"
namespace mozilla {
+namespace dom {
+class ScreenDetails;
+} // namespace dom
+} // namespace mozilla
+
+namespace mozilla {
namespace widget {
class Screen final : public nsIScreen
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISCREEN
Screen(LayoutDeviceIntRect aRect, LayoutDeviceIntRect aAvailRect,
uint32_t aPixelDepth, uint32_t aColorDepth,
DesktopToLayoutDeviceScale aContentsScale,
CSSToLayoutDeviceScale aDefaultCssScale);
+ explicit Screen(const mozilla::dom::ScreenDetails& aScreenDetails);
Screen(const Screen& aOther);
+ mozilla::dom::ScreenDetails ToScreenDetails();
+
private:
virtual ~Screen() {}
LayoutDeviceIntRect mRect;
LayoutDeviceIntRect mAvailRect;
DesktopIntRect mRectDisplayPix;
DesktopIntRect mAvailRectDisplayPix;
uint32_t mPixelDepth;
uint32_t mColorDepth;
DesktopToLayoutDeviceScale mContentsScale;
CSSToLayoutDeviceScale mDefaultCssScale;
- uint32_t mId;
};
} // namespace widget
} // namespace mozilla
#endif
--- a/widget/ScreenManager.cpp
+++ b/widget/ScreenManager.cpp
@@ -2,16 +2,17 @@
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "ScreenManager.h"
#include "mozilla/ClearOnShutdown.h"
+#include "mozilla/dom/ContentParent.h"
#include "mozilla/Logging.h"
#include "mozilla/StaticPtr.h"
static LazyLogModule sScreenLog("WidgetScreen");
NS_IMPL_ISUPPORTS(ScreenManager, nsIScreenManager)
namespace mozilla {
@@ -48,36 +49,73 @@ void
ScreenManager::SetHelper(UniquePtr<Helper> aHelper)
{
mHelper = Move(aHelper);
}
void
ScreenManager::Refresh(nsTArray<RefPtr<Screen>>&& aScreens)
{
+ MOZ_LOG(sScreenLog, LogLevel::Debug, ("Refresh screens"));
+
mScreenList = Move(aScreens);
+
+ CopyScreensToAllRemotesIfIsParent();
+}
+
+void
+ScreenManager::Refresh(nsTArray<mozilla::dom::ScreenDetails>&& aScreens)
+{
+ MOZ_LOG(sScreenLog, LogLevel::Debug, ("Refresh screens from IPC"));
+
+ mScreenList.Clear();
+ for (auto& screen : aScreens) {
+ mScreenList.AppendElement(new Screen(screen));
+ }
+
+ CopyScreensToAllRemotesIfIsParent();
}
-NS_IMETHODIMP
-ScreenManager::ScreenForId(uint32_t aId, nsIScreen** aOutScreen)
+template<class Range>
+void
+ScreenManager::CopyScreensToRemoteRange(Range aRemoteRange)
{
- *aOutScreen = nullptr;
-
- nsresult rv;
+ AutoTArray<ScreenDetails, 4> screens;
for (auto& screen : mScreenList) {
- uint32_t id;
- rv = screen->GetId(&id);
- if (NS_SUCCEEDED(rv) && id == aId) {
- RefPtr<Screen> ret = screen;
- ret.forget(aOutScreen);
- return NS_OK;
+ screens.AppendElement(screen->ToScreenDetails());
+ }
+ for (auto cp : aRemoteRange) {
+ MOZ_LOG(sScreenLog, LogLevel::Debug, ("Send screens to [Pid %d]", cp->Pid()));
+ if (!cp->SendRefreshScreens(screens)) {
+ MOZ_LOG(sScreenLog, LogLevel::Error,
+ ("SendRefreshScreens to [Pid %d] failed", cp->Pid()));
}
}
+}
- return NS_ERROR_FAILURE;
+void
+ScreenManager::CopyScreensToRemote(ContentParent* aContentParent)
+{
+ MOZ_ASSERT(aContentParent);
+ MOZ_ASSERT(XRE_IsParentProcess());
+
+ auto range = { aContentParent };
+ CopyScreensToRemoteRange(range);
+}
+
+void
+ScreenManager::CopyScreensToAllRemotesIfIsParent()
+{
+ if (XRE_IsContentProcess()) {
+ return;
+ }
+
+ MOZ_LOG(sScreenLog, LogLevel::Debug, ("Refreshing all ContentParents"));
+
+ CopyScreensToRemoteRange(ContentParent::AllProcesses(ContentParent::eLive));
}
// Returns the screen that contains the rectangle. If the rect overlaps
// multiple screens, it picks the screen with the greatest area of intersection.
//
// The coordinates are in desktop pixels.
//
NS_IMETHODIMP
@@ -156,16 +194,10 @@ ScreenManager::GetSystemDefaultScale(flo
if (mHelper) {
*aDefaultScale = mHelper->GetSystemDefaultScale();
return NS_OK;
}
*aDefaultScale = 1;
return NS_OK;
}
-NS_IMETHODIMP
-ScreenManager::ScreenForNativeWidget(void* aWidget, nsIScreen** aOutScreen)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
} // namespace widget
} // namespace mozilla
--- a/widget/ScreenManager.h
+++ b/widget/ScreenManager.h
@@ -10,16 +10,23 @@
#include "nsIScreenManager.h"
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/widget/Screen.h"
#include "nsTArray.h"
namespace mozilla {
+namespace dom {
+class ContentParent;
+class ScreenDetails;
+}
+}
+
+namespace mozilla {
namespace widget {
class ScreenManager final : public nsIScreenManager
{
public:
class Helper
{
public:
@@ -31,21 +38,27 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSISCREENMANAGER
static ScreenManager& GetSingleton();
static already_AddRefed<ScreenManager> GetAddRefedSingleton();
void SetHelper(UniquePtr<Helper> aHelper);
void Refresh(nsTArray<RefPtr<Screen>>&& aScreens);
+ void Refresh(nsTArray<mozilla::dom::ScreenDetails>&& aScreens);
+ void CopyScreensToRemote(mozilla::dom::ContentParent* aContentParent);
private:
ScreenManager();
virtual ~ScreenManager();
+ template<class Range>
+ void CopyScreensToRemoteRange(Range aRemoteRange);
+ void CopyScreensToAllRemotesIfIsParent();
+
AutoTArray<RefPtr<Screen>, 4> mScreenList;
UniquePtr<Helper> mHelper;
};
} // namespace widget
} // namespace mozilla
deleted file mode 100644
--- a/widget/ScreenProxy.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*- */
-/* vim: set sw=4 ts=8 et tw=80 : */
-/* 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/. */
-
-#include "mozilla/Unused.h"
-#include "nsContentUtils.h"
-#include "nsIAppShell.h"
-#include "nsScreenManagerProxy.h"
-#include "nsServiceManagerUtils.h"
-#include "nsWidgetsCID.h"
-#include "ScreenProxy.h"
-
-namespace mozilla {
-namespace widget {
-
-using namespace mozilla::dom;
-
-static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
-
-ScreenProxy::ScreenProxy(nsScreenManagerProxy* aScreenManager, ScreenDetails aDetails)
- : mContentsScaleFactor(0)
- , mDefaultCSSScaleFactor(0)
- , mScreenManager(aScreenManager)
- , mId(0)
- , mPixelDepth(0)
- , mColorDepth(0)
- , mCacheValid(false)
- , mCacheWillInvalidate(false)
-{
- PopulateByDetails(aDetails);
-}
-
-NS_IMETHODIMP
-ScreenProxy::GetId(uint32_t *outId)
-{
- *outId = mId;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-ScreenProxy::GetRect(int32_t *outLeft,
- int32_t *outTop,
- int32_t *outWidth,
- int32_t *outHeight)
-{
- if (!EnsureCacheIsValid()) {
- return NS_ERROR_FAILURE;
- }
-
- *outLeft = mRect.x;
- *outTop = mRect.y;
- *outWidth = mRect.width;
- *outHeight = mRect.height;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-ScreenProxy::GetRectDisplayPix(int32_t *outLeft,
- int32_t *outTop,
- int32_t *outWidth,
- int32_t *outHeight)
-{
- if (!EnsureCacheIsValid()) {
- return NS_ERROR_FAILURE;
- }
-
- *outLeft = mRectDisplayPix.x;
- *outTop = mRectDisplayPix.y;
- *outWidth = mRectDisplayPix.width;
- *outHeight = mRectDisplayPix.height;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-ScreenProxy::GetAvailRect(int32_t *outLeft,
- int32_t *outTop,
- int32_t *outWidth,
- int32_t *outHeight)
-{
- if (!EnsureCacheIsValid()) {
- return NS_ERROR_FAILURE;
- }
-
- *outLeft = mAvailRect.x;
- *outTop = mAvailRect.y;
- *outWidth = mAvailRect.width;
- *outHeight = mAvailRect.height;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-ScreenProxy::GetAvailRectDisplayPix(int32_t *outLeft,
- int32_t *outTop,
- int32_t *outWidth,
- int32_t *outHeight)
-{
- if (!EnsureCacheIsValid()) {
- return NS_ERROR_FAILURE;
- }
-
- *outLeft = mAvailRectDisplayPix.x;
- *outTop = mAvailRectDisplayPix.y;
- *outWidth = mAvailRectDisplayPix.width;
- *outHeight = mAvailRectDisplayPix.height;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-ScreenProxy::GetPixelDepth(int32_t *aPixelDepth)
-{
- if (!EnsureCacheIsValid()) {
- return NS_ERROR_FAILURE;
- }
-
- *aPixelDepth = mPixelDepth;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-ScreenProxy::GetColorDepth(int32_t *aColorDepth)
-{
- if (!EnsureCacheIsValid()) {
- return NS_ERROR_FAILURE;
- }
-
- *aColorDepth = mColorDepth;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-ScreenProxy::GetContentsScaleFactor(double* aContentsScaleFactor)
-{
- if (!EnsureCacheIsValid()) {
- return NS_ERROR_FAILURE;
- }
-
- *aContentsScaleFactor = mContentsScaleFactor;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-ScreenProxy::GetDefaultCSSScaleFactor(double* aScaleFactor)
-{
- if (!EnsureCacheIsValid()) {
- return NS_ERROR_FAILURE;
- }
-
- *aScaleFactor = mDefaultCSSScaleFactor;
- return NS_OK;
-}
-
-void
-ScreenProxy::PopulateByDetails(ScreenDetails aDetails)
-{
- mId = aDetails.id();
- mRect = nsIntRect(aDetails.rect());
- mRectDisplayPix = nsIntRect(aDetails.rectDisplayPix());
- mAvailRect = nsIntRect(aDetails.availRect());
- mAvailRectDisplayPix = nsIntRect(aDetails.availRectDisplayPix());
- mPixelDepth = aDetails.pixelDepth();
- mColorDepth = aDetails.colorDepth();
- mContentsScaleFactor = aDetails.contentsScaleFactor();
- mDefaultCSSScaleFactor = aDetails.defaultCSSScaleFactor();
-}
-
-bool
-ScreenProxy::EnsureCacheIsValid()
-{
- if (mCacheValid) {
- return true;
- }
-
- bool success = false;
- // Kick off a synchronous IPC call to the parent to get the
- // most up-to-date information.
- ScreenDetails details;
- Unused << mScreenManager->SendScreenRefresh(mId, &details, &success);
- if (!success) {
- NS_WARNING("Updating a ScreenProxy in the child process failed on parent side.");
- return false;
- }
-
- PopulateByDetails(details);
- mCacheValid = true;
-
- InvalidateCacheOnNextTick();
- return true;
-}
-
-void
-ScreenProxy::InvalidateCacheOnNextTick()
-{
- if (mCacheWillInvalidate) {
- return;
- }
-
- mCacheWillInvalidate = true;
-
- nsContentUtils::RunInStableState(NewRunnableMethod(this, &ScreenProxy::InvalidateCache));
-}
-
-void
-ScreenProxy::InvalidateCache()
-{
- mCacheValid = false;
- mCacheWillInvalidate = false;
-}
-
-} // namespace widget
-} // namespace mozilla
-
deleted file mode 100644
--- a/widget/ScreenProxy.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*- */
-/* vim: set sw=4 ts=8 et tw=80 : */
-/* 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 mozilla_widget_ScreenProxy_h
-#define mozilla_widget_ScreenProxy_h
-
-#include "nsBaseScreen.h"
-#include "mozilla/dom/PScreenManagerChild.h"
-#include "mozilla/dom/TabChild.h"
-
-class nsScreenManagerProxy;
-
-namespace mozilla {
-namespace widget {
-
-class ScreenProxy : public nsBaseScreen
-{
-public:
- ScreenProxy(nsScreenManagerProxy* aScreenManager,
- mozilla::dom::ScreenDetails aDetails);
- ~ScreenProxy() {};
-
- NS_IMETHOD GetId(uint32_t* aId) override;
-
- NS_IMETHOD GetRect(int32_t* aLeft,
- int32_t* aTop,
- int32_t* aWidth,
- int32_t* aHeight) override;
- NS_IMETHOD GetRectDisplayPix(int32_t* aLeft,
- int32_t* aTop,
- int32_t* aWidth,
- int32_t* aHeight) override;
- NS_IMETHOD GetAvailRect(int32_t* aLeft,
- int32_t* aTop,
- int32_t* aWidth,
- int32_t* aHeight) override;
- NS_IMETHOD GetAvailRectDisplayPix(int32_t* aLeft,
- int32_t* aTop,
- int32_t* aWidth,
- int32_t* aHeight) override;
- NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth) override;
- NS_IMETHOD GetColorDepth(int32_t* aColorDepth) override;
-
- NS_IMETHOD GetContentsScaleFactor(double* aContentsScaleFactor) override;
- NS_IMETHOD GetDefaultCSSScaleFactor(double* aScaleFactor) override;
-
-private:
-
- void PopulateByDetails(mozilla::dom::ScreenDetails aDetails);
- bool EnsureCacheIsValid();
- void InvalidateCacheOnNextTick();
- void InvalidateCache();
-
- double mContentsScaleFactor;
- double mDefaultCSSScaleFactor;
- RefPtr<nsScreenManagerProxy> mScreenManager;
- uint32_t mId;
- int32_t mPixelDepth;
- int32_t mColorDepth;
- nsIntRect mRect;
- nsIntRect mRectDisplayPix;
- nsIntRect mAvailRect;
- nsIntRect mAvailRectDisplayPix;
- bool mCacheValid;
- bool mCacheWillInvalidate;
-};
-
-} // namespace widget
-} // namespace mozilla
-
-#endif
-
--- a/widget/android/nsScreenManagerAndroid.cpp
+++ b/widget/android/nsScreenManagerAndroid.cpp
@@ -206,23 +206,16 @@ nsScreenManagerAndroid::ScreenForRect(in
int32_t inHeight,
nsIScreen **outScreen)
{
// Not support to query non-primary screen with rect.
return GetPrimaryScreen(outScreen);
}
NS_IMETHODIMP
-nsScreenManagerAndroid::ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen)
-{
- // Not support to query non-primary screen with native widget.
- return GetPrimaryScreen(outScreen);
-}
-
-NS_IMETHODIMP
nsScreenManagerAndroid::GetSystemDefaultScale(float *aDefaultScale)
{
*aDefaultScale = 1.0f;
return NS_OK;
}
already_AddRefed<nsScreenAndroid>
nsScreenManagerAndroid::AddScreen(DisplayType aDisplayType, nsIntRect aRect)
--- a/widget/cocoa/nsScreenManagerCocoa.mm
+++ b/widget/cocoa/nsScreenManagerCocoa.mm
@@ -112,27 +112,8 @@ nsScreenManagerCocoa::GetPrimaryScreen (
}
NS_IMETHODIMP
nsScreenManagerCocoa::GetSystemDefaultScale(float *aDefaultScale)
{
*aDefaultScale = 1.0f;
return NS_OK;
}
-
-NS_IMETHODIMP
-nsScreenManagerCocoa::ScreenForNativeWidget (void *nativeWidget, nsIScreen **outScreen)
-{
- NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
-
- NSWindow *window = static_cast<NSWindow*>(nativeWidget);
- if (window) {
- nsIScreen *screen = ScreenForCocoaScreen([window screen]);
- *outScreen = screen;
- NS_ADDREF(*outScreen);
- return NS_OK;
- }
-
- *outScreen = nullptr;
- return NS_OK;
-
- NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
-}
--- a/widget/gonk/nsScreenManagerGonk.cpp
+++ b/widget/gonk/nsScreenManagerGonk.cpp
@@ -827,30 +827,16 @@ nsScreenManagerGonk::ScreenForRect(int32
nsIScreen **outScreen)
{
// Since all screens have independent coordinate system, we could
// only return the primary screen no matter what rect is given.
return GetPrimaryScreen(outScreen);
}
NS_IMETHODIMP
-nsScreenManagerGonk::ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen)
-{
- for (size_t i = 0; i < mScreens.Length(); i++) {
- if (aWidget == mScreens[i]->GetNativeWindow()) {
- NS_IF_ADDREF(*outScreen = mScreens[i].get());
- return NS_OK;
- }
- }
-
- *outScreen = nullptr;
- return NS_OK;
-}
-
-NS_IMETHODIMP
nsScreenManagerGonk::GetSystemDefaultScale(float *aDefaultScale)
{
*aDefaultScale = 1.0f;
return NS_OK;
}
void
nsScreenManagerGonk::VsyncControl(bool aEnabled)
--- a/widget/moz.build
+++ b/widget/moz.build
@@ -154,24 +154,22 @@ UNIFIED_SOURCES += [
'nsContentProcessWidgetFactory.cpp',
'nsDragServiceProxy.cpp',
'nsFilePickerProxy.cpp',
'nsHTMLFormatConverter.cpp',
'nsIdleService.cpp',
'nsIWidgetListener.cpp',
'nsPrimitiveHelpers.cpp',
'nsPrintSettingsImpl.cpp',
- 'nsScreenManagerProxy.cpp',
'nsTransferable.cpp',
'nsXPLookAndFeel.cpp',
'PuppetBidiKeyboard.cpp',
'PuppetWidget.cpp',
'Screen.cpp',
'ScreenManager.cpp',
- 'ScreenProxy.cpp',
'SharedWidgetUtils.cpp',
'TextEventDispatcher.cpp',
'VsyncDispatcher.cpp',
'WidgetEventImpl.cpp',
'WidgetUtils.cpp',
]
if CONFIG['OS_ARCH'] == 'Linux':
--- a/widget/nsContentProcessWidgetFactory.cpp
+++ b/widget/nsContentProcessWidgetFactory.cpp
@@ -6,30 +6,30 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ModuleUtils.h"
#include "nsWidgetsCID.h"
#include "nsClipboardProxy.h"
#include "nsColorPickerProxy.h"
#include "nsDragServiceProxy.h"
#include "nsFilePickerProxy.h"
-#include "nsScreenManagerProxy.h"
#include "mozilla/widget/PuppetBidiKeyboard.h"
+#include "mozilla/widget/ScreenManager.h"
using namespace mozilla;
using namespace mozilla::widget;
#ifndef MOZ_WIDGET_GONK
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardProxy)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsColorPickerProxy)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragServiceProxy)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePickerProxy)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerProxy)
NS_GENERIC_FACTORY_CONSTRUCTOR(PuppetBidiKeyboard)
+NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager, ScreenManager::GetAddRefedSingleton)
NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID);
NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID);
NS_DEFINE_NAMED_CID(PUPPETBIDIKEYBOARD_CID);
NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
@@ -37,20 +37,20 @@ static const mozilla::Module::CIDEntry k
{ &kNS_CLIPBOARD_CID, false, nullptr, nsClipboardProxyConstructor,
Module::CONTENT_PROCESS_ONLY },
{ &kNS_COLORPICKER_CID, false, nullptr, nsColorPickerProxyConstructor,
Module::CONTENT_PROCESS_ONLY },
{ &kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceProxyConstructor,
Module::CONTENT_PROCESS_ONLY },
{ &kNS_FILEPICKER_CID, false, nullptr, nsFilePickerProxyConstructor,
Module::CONTENT_PROCESS_ONLY },
- { &kNS_SCREENMANAGER_CID, false, nullptr, nsScreenManagerProxyConstructor,
+ { &kPUPPETBIDIKEYBOARD_CID, false, NULL, PuppetBidiKeyboardConstructor,
Module::CONTENT_PROCESS_ONLY },
- { &kPUPPETBIDIKEYBOARD_CID, false, NULL, PuppetBidiKeyboardConstructor,
- mozilla::Module::CONTENT_PROCESS_ONLY },
+ { &kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor,
+ Module::CONTENT_PROCESS_ONLY },
{ nullptr }
};
static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{ "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID, Module::CONTENT_PROCESS_ONLY },
{ "@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID, Module::CONTENT_PROCESS_ONLY },
{ "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID, Module::CONTENT_PROCESS_ONLY },
{ "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID, Module::CONTENT_PROCESS_ONLY },
--- a/widget/nsIScreen.idl
+++ b/widget/nsIScreen.idl
@@ -16,22 +16,16 @@ enum class DisplayType: int32_t {
DISPLAY_VIRTUAL // wireless displays, such as Chromecast, WiFi-Display, etc.
};
%}
[scriptable, uuid(826e80c8-d70f-42e2-8aa9-82c05f2a370a)]
interface nsIScreen : nsISupports
{
/**
- * A unique identifier for this device, useful for requerying
- * for it via nsIScreenManager.
- */
- readonly attribute unsigned long id;
-
- /**
* These report screen dimensions in (screen-specific) device pixels
*/
void GetRect(out long left, out long top, out long width, out long height);
void GetAvailRect(out long left, out long top, out long width, out long height);
/**
* And these report in desktop pixels
*/
--- a/widget/nsIScreenManager.idl
+++ b/widget/nsIScreenManager.idl
@@ -13,23 +13,16 @@ interface nsIScreenManager : nsISupports
//
// Returns the screen that contains the rectangle. If the rect overlaps
// multiple screens, it picks the screen with the greatest area of intersection.
//
// The coordinates are in pixels (not twips) and in screen coordinates.
//
nsIScreen screenForRect ( in long left, in long top, in long width, in long height ) ;
- //
- // Returns the screen corresponding to the id. If no such screen exists,
- // this will throw NS_ERROR_FAILURE. The id is a unique numeric value
- // assigned to each screen, and is an attribute available on the nsIScreen
- // interface.
- nsIScreen screenForId ( in unsigned long id ) ;
-
// The screen with the menubar/taskbar. This shouldn't be needed very
// often.
readonly attribute nsIScreen primaryScreen;
// The default DPI scaling factor of the screen environment (number of
// screen pixels corresponding to 1 CSS px, at the default zoom level).
//
// This is currently fixed at 1.0 on most platforms, but varies on Windows
@@ -43,19 +36,9 @@ interface nsIScreenManager : nsISupports
// Cocoa points remains 1:1, even on a Retina screen where one Cocoa point
// corresponds to two device pixels. (This is exposed via other APIs:
// see window.devicePixelRatio).
//
// NOTE also that on Linux, this does -not- currently reflect changes
// to the system-wide (X11 or Gtk2) DPI value, as Firefox does not yet
// honor these settings. See bug 798362 and bug 712898.
readonly attribute float systemDefaultScale;
-
- // Returns the nsIScreen instance for the given native widget pointer;
- // the pointer is specific to the particular widget implementation,
- // and is generally of the same type that NS_NATIVE_WINDOW is.
- [noscript] nsIScreen screenForNativeWidget ( in voidPtr nativeWidget );
};
-
-
-%{ C++
-
-%}
deleted file mode 100644
--- a/widget/nsScreenManagerProxy.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; 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/. */
-
-#include "mozilla/Unused.h"
-#include "mozilla/dom/ContentChild.h"
-#include "nsScreenManagerProxy.h"
-#include "nsServiceManagerUtils.h"
-#include "nsContentUtils.h"
-#include "nsIAppShell.h"
-#include "nsIScreen.h"
-#include "nsIScreenManager.h"
-#include "nsWidgetsCID.h"
-
-static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
-
-using namespace mozilla;
-using namespace mozilla::dom;
-using namespace mozilla::widget;
-
-NS_IMPL_ISUPPORTS(nsScreenManagerProxy, nsIScreenManager)
-
-nsScreenManagerProxy::nsScreenManagerProxy()
- : mSystemDefaultScale(1.0)
- , mCacheValid(true)
- , mCacheWillInvalidate(false)
-{
- bool success = false;
- Unused << ContentChild::GetSingleton()->SendPScreenManagerConstructor(
- this,
- &mSystemDefaultScale,
- &success);
-
- if (!success) {
- // We're in bad shape. We'll return the default values, but we'll basically
- // be lying.
- NS_WARNING("Setting up communications with the parent nsIScreenManager failed.");
- }
-
- InvalidateCacheOnNextTick();
-
- // nsScreenManagerProxy is a service, which will always have a reference
- // held to it by the Component Manager once the service is requested.
- // However, nsScreenManagerProxy also implements PScreenManagerChild, and
- // that means that the manager of the PScreenManager protocol (PContent
- // in this case) needs to know how to deallocate this actor. We AddRef here
- // so that in the event that PContent tries to deallocate us either before
- // or after process shutdown, we don't try to do a double-free.
- AddRef();
-}
-
-/**
- * nsIScreenManager
- **/
-
-NS_IMETHODIMP
-nsScreenManagerProxy::GetPrimaryScreen(nsIScreen** outScreen)
-{
- InvalidateCacheOnNextTick();
-
- if (!mPrimaryScreen) {
- ScreenDetails details;
- bool success = false;
- Unused << SendGetPrimaryScreen(&details, &success);
- if (!success) {
- return NS_ERROR_FAILURE;
- }
-
- mPrimaryScreen = new ScreenProxy(this, details);
- }
- NS_ADDREF(*outScreen = mPrimaryScreen);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsScreenManagerProxy::ScreenForId(uint32_t aId, nsIScreen** outScreen)
-{
- // At this time, there's no need for child processes to query for
- // screens by ID.
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-nsScreenManagerProxy::ScreenForRect(int32_t inLeft,
- int32_t inTop,
- int32_t inWidth,
- int32_t inHeight,
- nsIScreen** outScreen)
-{
- bool success = false;
- ScreenDetails details;
- Unused << SendScreenForRect(inLeft, inTop, inWidth, inHeight, &details, &success);
- if (!success) {
- return NS_ERROR_FAILURE;
- }
-
- RefPtr<ScreenProxy> screen = new ScreenProxy(this, details);
- NS_ADDREF(*outScreen = screen);
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsScreenManagerProxy::ScreenForNativeWidget(void* aWidget,
- nsIScreen** outScreen)
-{
- // Because ScreenForNativeWidget can be called numerous times
- // indirectly from content via the DOM Screen API, we cache the
- // results for this tick of the event loop.
- TabChild* tabChild = static_cast<TabChild*>(aWidget);
-
- // Enumerate the cached screen array, looking for one that has
- // the TabChild that we're looking for...
- for (uint32_t i = 0; i < mScreenCache.Length(); ++i) {
- ScreenCacheEntry& curr = mScreenCache[i];
- if (curr.mTabChild == aWidget) {
- NS_ADDREF(*outScreen = static_cast<nsIScreen*>(curr.mScreenProxy));
- return NS_OK;
- }
- }
-
- // Never cached this screen, so we have to ask the parent process
- // for it.
- bool success = false;
- ScreenDetails details;
- Unused << SendScreenForBrowser(tabChild->GetTabId(), &details, &success);
- if (!success) {
- return NS_ERROR_FAILURE;
- }
-
- ScreenCacheEntry newEntry;
- RefPtr<ScreenProxy> screen = new ScreenProxy(this, details);
-
- newEntry.mScreenProxy = screen;
- newEntry.mTabChild = tabChild;
-
- mScreenCache.AppendElement(newEntry);
-
- NS_ADDREF(*outScreen = screen);
-
- InvalidateCacheOnNextTick();
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsScreenManagerProxy::GetSystemDefaultScale(float *aSystemDefaultScale)
-{
- if (!EnsureCacheIsValid()) {
- return NS_ERROR_FAILURE;
- }
-
- *aSystemDefaultScale = mSystemDefaultScale;
- return NS_OK;
-}
-
-bool
-nsScreenManagerProxy::EnsureCacheIsValid()
-{
- if (mCacheValid) {
- return true;
- }
-
- bool success = false;
- // Kick off a synchronous IPC call to the parent to get the
- // most up-to-date information.
- Unused << SendRefresh(&mSystemDefaultScale, &success);
- if (!success) {
- NS_WARNING("Refreshing nsScreenManagerProxy failed in the parent process.");
- return false;
- }
-
- mCacheValid = true;
-
- InvalidateCacheOnNextTick();
- return true;
-}
-
-void
-nsScreenManagerProxy::InvalidateCacheOnNextTick()
-{
- if (mCacheWillInvalidate) {
- return;
- }
-
- mCacheWillInvalidate = true;
-
- nsContentUtils::RunInStableState(NewRunnableMethod(this, &nsScreenManagerProxy::InvalidateCache));
-}
-
-void
-nsScreenManagerProxy::InvalidateCache()
-{
- mCacheValid = false;
- mCacheWillInvalidate = false;
-
- if (mPrimaryScreen) {
- mPrimaryScreen = nullptr;
- }
- for (int32_t i = mScreenCache.Length() - 1; i >= 0; --i) {
- mScreenCache.RemoveElementAt(i);
- }
-}
-
deleted file mode 100644
--- a/widget/nsScreenManagerProxy.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- 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();
-
- 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
--- a/widget/uikit/nsScreenManager.mm
+++ b/widget/uikit/nsScreenManager.mm
@@ -113,26 +113,13 @@ UIKitScreenManager::ScreenForRect(int32_
int32_t inWidth,
int32_t inHeight,
nsIScreen** outScreen)
{
return GetPrimaryScreen(outScreen);
}
NS_IMETHODIMP
-UIKitScreenManager::ScreenForId(uint32_t id,
- nsIScreen** outScreen)
-{
- return GetPrimaryScreen(outScreen);
-}
-
-NS_IMETHODIMP
-UIKitScreenManager::ScreenForNativeWidget(void* aWidget, nsIScreen** outScreen)
-{
- return GetPrimaryScreen(outScreen);
-}
-
-NS_IMETHODIMP
UIKitScreenManager::GetSystemDefaultScale(float* aScale)
{
*aScale = [UIScreen mainScreen].scale;
return NS_OK;
}
--- a/widget/windows/nsScreenManagerWin.cpp
+++ b/widget/windows/nsScreenManagerWin.cpp
@@ -125,16 +125,8 @@ nsScreenManagerWin::GetPrimaryScreen(nsI
NS_IMETHODIMP
nsScreenManagerWin::GetSystemDefaultScale(float *aDefaultScale)
{
HMONITOR primary = widget::WinUtils::GetPrimaryMonitor();
*aDefaultScale = float(widget::WinUtils::LogToPhysFactor(primary));
return NS_OK;
}
-
-NS_IMETHODIMP
-nsScreenManagerWin::ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen)
-{
- HMONITOR mon = MonitorFromWindow((HWND) aWidget, MONITOR_DEFAULTTOPRIMARY);
- *outScreen = CreateNewScreenObject(mon);
- return NS_OK;
-}