Bug 1194751 - Part 1. Remove nsIScreenManager::GetNumberOfScreens. r=jimm
authorKan-Ru Chen <kanru@kanru.info>
Thu, 09 Mar 2017 19:16:24 +0800
changeset 349750 57f989c1010f40a2b99ee89d61bd1621c633ab4a
parent 349749 e8a7790bd2685ca77713d2bf8b165e7e162a443d
child 349751 5df5fa8ee892ff9f893bf8ae15a66a89a1a72325
push id88491
push usercbook@mozilla.com
push dateMon, 27 Mar 2017 10:59:44 +0000
treeherdermozilla-inbound@7d3e8986a676 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1194751
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1194751 - Part 1. Remove nsIScreenManager::GetNumberOfScreens. r=jimm It's not used anywhere. Remove it will make removing PScreenManager easier. MozReview-Commit-ID: 5dn8kDhTZVl
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/ipc/PScreenManager.ipdl
dom/ipc/ScreenManagerParent.cpp
dom/ipc/ScreenManagerParent.h
widget/PuppetWidget.cpp
widget/android/nsScreenManagerAndroid.cpp
widget/cocoa/nsScreenManagerCocoa.mm
widget/gonk/nsScreenManagerGonk.cpp
widget/gtk/nsScreenManagerGtk.cpp
widget/nsIScreenManager.idl
widget/nsScreenManagerProxy.cpp
widget/nsScreenManagerProxy.h
widget/uikit/nsScreenManager.mm
widget/windows/nsScreenManagerWin.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1744,18 +1744,17 @@ ContentChild::AllocPParentToChildStreamC
 
 bool
 ContentChild::DeallocPParentToChildStreamChild(PParentToChildStreamChild* aActor)
 {
   return nsIContentChild::DeallocPParentToChildStreamChild(aActor);
 }
 
 PScreenManagerChild*
-ContentChild::AllocPScreenManagerChild(uint32_t* aNumberOfScreens,
-                                       float* aSystemDefaultScale,
+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;
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -238,18 +238,17 @@ public:
 
   virtual PChildToParentStreamChild* AllocPChildToParentStreamChild() override;
   virtual bool DeallocPChildToParentStreamChild(PChildToParentStreamChild*) override;
 
   virtual PParentToChildStreamChild* AllocPParentToChildStreamChild() override;
   virtual bool DeallocPParentToChildStreamChild(PParentToChildStreamChild*) override;
 
   virtual PScreenManagerChild*
-  AllocPScreenManagerChild(uint32_t* aNumberOfScreens,
-                           float* aSystemDefaultScale,
+  AllocPScreenManagerChild(float* aSystemDefaultScale,
                            bool* aSuccess) override;
 
   virtual bool DeallocPScreenManagerChild(PScreenManagerChild*) override;
 
   virtual PPSMContentDownloaderChild*
   AllocPPSMContentDownloaderChild( const uint32_t& aCertType) override;
 
   virtual bool
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -3132,21 +3132,20 @@ ContentParent::AllocPParentToChildStream
 
 bool
 ContentParent::DeallocPParentToChildStreamParent(PParentToChildStreamParent* aActor)
 {
   return nsIContentParent::DeallocPParentToChildStreamParent(aActor);
 }
 
 PScreenManagerParent*
-ContentParent::AllocPScreenManagerParent(uint32_t* aNumberOfScreens,
-                                         float* aSystemDefaultScale,
+ContentParent::AllocPScreenManagerParent(float* aSystemDefaultScale,
                                          bool* aSuccess)
 {
-  return new ScreenManagerParent(aNumberOfScreens, aSystemDefaultScale, aSuccess);
+  return new ScreenManagerParent(aSystemDefaultScale, aSuccess);
 }
 
 bool
 ContentParent::DeallocPScreenManagerParent(PScreenManagerParent* aActor)
 {
   delete aActor;
   return true;
 }
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -442,18 +442,17 @@ public:
   virtual PFileDescriptorSetParent*
   SendPFileDescriptorSetConstructor(const FileDescriptor&) override;
 
   virtual PParentToChildStreamParent* AllocPParentToChildStreamParent() override;
   virtual bool
   DeallocPParentToChildStreamParent(PParentToChildStreamParent* aActor) override;
 
   virtual PScreenManagerParent*
-  AllocPScreenManagerParent(uint32_t* aNumberOfScreens,
-                            float* aSystemDefaultScale,
+  AllocPScreenManagerParent(float* aSystemDefaultScale,
                             bool* aSuccess) override;
 
   virtual bool
   DeallocPScreenManagerParent(PScreenManagerParent* aActor) override;
 
   virtual PHalParent* AllocPHalParent() override;
 
   virtual mozilla::ipc::IPCResult RecvPHalConstructor(PHalParent* aActor) override
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -707,18 +707,17 @@ parent:
 
     async PNecko();
 
     async PPrinting();
 
     async PChildToParentStream();
 
     nested(inside_sync) sync PScreenManager()
-        returns (uint32_t numberOfScreens,
-                 float systemDefaultScale,
+        returns (float systemDefaultScale,
                  bool success);
 
     async PSpeechSynthesis();
 
     nested(inside_cpow) async PStorage();
 
     async PMedia();
 
--- a/dom/ipc/PScreenManager.ipdl
+++ b/dom/ipc/PScreenManager.ipdl
@@ -27,18 +27,17 @@ struct ScreenDetails {
 };
 
 nested(upto inside_cpow) sync protocol PScreenManager
 {
   manager PContent;
 
 parent:
     nested(inside_sync) sync Refresh()
-      returns (uint32_t numberOfScreens,
-               float systemDefaultScale,
+      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,
--- a/dom/ipc/ScreenManagerParent.cpp
+++ b/dom/ipc/ScreenManagerParent.cpp
@@ -12,41 +12,34 @@
 #include "ScreenManagerParent.h"
 #include "ContentProcessManager.h"
 
 namespace mozilla {
 namespace dom {
 
 static const char *sScreenManagerContractID = "@mozilla.org/gfx/screenmanager;1";
 
-ScreenManagerParent::ScreenManagerParent(uint32_t* aNumberOfScreens,
-                                         float* aSystemDefaultScale,
+ScreenManagerParent::ScreenManagerParent(float* aSystemDefaultScale,
                                          bool* aSuccess)
 {
   mScreenMgr = do_GetService(sScreenManagerContractID);
   if (!mScreenMgr) {
     MOZ_CRASH("Couldn't get nsIScreenManager from ScreenManagerParent.");
   }
 
-  Unused << RecvRefresh(aNumberOfScreens, aSystemDefaultScale, aSuccess);
+  Unused << RecvRefresh(aSystemDefaultScale, aSuccess);
 }
 
 mozilla::ipc::IPCResult
-ScreenManagerParent::RecvRefresh(uint32_t* aNumberOfScreens,
-                                 float* aSystemDefaultScale,
+ScreenManagerParent::RecvRefresh(float* aSystemDefaultScale,
                                  bool* aSuccess)
 {
   *aSuccess = false;
 
-  nsresult rv = mScreenMgr->GetNumberOfScreens(aNumberOfScreens);
-  if (NS_FAILED(rv)) {
-    return IPC_OK();
-  }
-
-  rv = mScreenMgr->GetSystemDefaultScale(aSystemDefaultScale);
+  nsresult rv = mScreenMgr->GetSystemDefaultScale(aSystemDefaultScale);
   if (NS_FAILED(rv)) {
     return IPC_OK();
   }
 
   *aSuccess = true;
   return IPC_OK();
 }
 
--- a/dom/ipc/ScreenManagerParent.h
+++ b/dom/ipc/ScreenManagerParent.h
@@ -11,23 +11,21 @@
 #include "nsIScreenManager.h"
 
 namespace mozilla {
 namespace dom {
 
 class ScreenManagerParent : public PScreenManagerParent
 {
  public:
-  ScreenManagerParent(uint32_t* aNumberOfScreens,
-                      float* aSystemDefaultScale,
+  ScreenManagerParent(float* aSystemDefaultScale,
                       bool* aSuccess);
   ~ScreenManagerParent() {};
 
-  virtual mozilla::ipc::IPCResult RecvRefresh(uint32_t* aNumberOfScreens,
-                                              float* aSystemDefaultScale,
+  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;
 
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -1450,23 +1450,16 @@ PuppetScreenManager::ScreenForRect(int32
 NS_IMETHODIMP
 PuppetScreenManager::ScreenForNativeWidget(void* aWidget,
                                            nsIScreen** outScreen)
 {
   return GetPrimaryScreen(outScreen);
 }
 
 NS_IMETHODIMP
-PuppetScreenManager::GetNumberOfScreens(uint32_t* aNumberOfScreens)
-{
-  *aNumberOfScreens = 1;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 PuppetScreenManager::GetSystemDefaultScale(float *aDefaultScale)
 {
   *aDefaultScale = 1.0f;
   return NS_OK;
 }
 
 nsIWidgetListener*
 PuppetWidget::GetCurrentWidgetListener()
--- a/widget/android/nsScreenManagerAndroid.cpp
+++ b/widget/android/nsScreenManagerAndroid.cpp
@@ -223,23 +223,16 @@ nsScreenManagerAndroid::ScreenForRect(in
 NS_IMETHODIMP
 nsScreenManagerAndroid::ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen)
 {
     // Not support to query non-primary screen with native widget.
     return GetPrimaryScreen(outScreen);
 }
 
 NS_IMETHODIMP
-nsScreenManagerAndroid::GetNumberOfScreens(uint32_t *aNumberOfScreens)
-{
-    *aNumberOfScreens = mScreens.Length();
-    return NS_OK;
-}
-
-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
@@ -107,30 +107,16 @@ nsScreenManagerCocoa::GetPrimaryScreen (
     NS_ADDREF(*outScreen);
 
     return NS_OK;
 
     NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP
-nsScreenManagerCocoa::GetNumberOfScreens (uint32_t *aNumberOfScreens)
-{
-    NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
-
-    NSArray *ss = [NSScreen screens];
-
-    *aNumberOfScreens = [ss count];
-
-    return NS_OK;
-
-    NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
-}
-
-NS_IMETHODIMP
 nsScreenManagerCocoa::GetSystemDefaultScale(float *aDefaultScale)
 {
     *aDefaultScale = 1.0f;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsScreenManagerCocoa::ScreenForNativeWidget (void *nativeWidget, nsIScreen **outScreen)
--- a/widget/gonk/nsScreenManagerGonk.cpp
+++ b/widget/gonk/nsScreenManagerGonk.cpp
@@ -881,23 +881,16 @@ nsScreenManagerGonk::ScreenForNativeWidg
         }
     }
 
     *outScreen = nullptr;
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsScreenManagerGonk::GetNumberOfScreens(uint32_t *aNumberOfScreens)
-{
-    *aNumberOfScreens = mScreens.Length();
-    return NS_OK;
-}
-
-NS_IMETHODIMP
 nsScreenManagerGonk::GetSystemDefaultScale(float *aDefaultScale)
 {
     *aDefaultScale = 1.0f;
     return NS_OK;
 }
 
 void
 nsScreenManagerGonk::VsyncControl(bool aEnabled)
--- a/widget/gtk/nsScreenManagerGtk.cpp
+++ b/widget/gtk/nsScreenManagerGtk.cpp
@@ -299,36 +299,16 @@ nsScreenManagerGtk :: GetPrimaryScreen(n
     return rv;
   }
   *aPrimaryScreen = mCachedScreenArray.SafeObjectAt(0);
   NS_IF_ADDREF(*aPrimaryScreen);
   return NS_OK;
 
 } // GetPrimaryScreen
 
-
-//
-// GetNumberOfScreens
-//
-// Returns how many physical screens are available.
-//
-NS_IMETHODIMP
-nsScreenManagerGtk :: GetNumberOfScreens(uint32_t *aNumberOfScreens)
-{
-  nsresult rv;
-  rv = EnsureInit();
-  if (NS_FAILED(rv)) {
-    NS_ERROR("nsScreenManagerGtk::EnsureInit() failed from GetNumberOfScreens");
-    return rv;
-  }
-  *aNumberOfScreens = mCachedScreenArray.Count();
-  return NS_OK;
-
-} // GetNumberOfScreens
-
 NS_IMETHODIMP
 nsScreenManagerGtk::GetSystemDefaultScale(float *aDefaultScale)
 {
   *aDefaultScale = nsScreenGtk::GetDPIScale();
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/widget/nsIScreenManager.idl
+++ b/widget/nsIScreenManager.idl
@@ -24,19 +24,16 @@ interface nsIScreenManager : nsISupports
     // 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;
 
-    // Holds the number of screens that are available
-  readonly attribute unsigned long numberOfScreens;
-
     // 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
     // if the "logical DPI" scaling option in the Display control panel is set
     // to a value other than 100% (e.g. 125% or 150% are increasingly common
     // defaults on laptops with high-dpi screens). See bug 851520.
     //
--- a/widget/nsScreenManagerProxy.cpp
+++ b/widget/nsScreenManagerProxy.cpp
@@ -18,25 +18,23 @@ static NS_DEFINE_CID(kAppShellCID, NS_AP
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::widget;
 
 NS_IMPL_ISUPPORTS(nsScreenManagerProxy, nsIScreenManager)
 
 nsScreenManagerProxy::nsScreenManagerProxy()
-  : mNumberOfScreens(-1)
-  , mSystemDefaultScale(1.0)
+  : mSystemDefaultScale(1.0)
   , mCacheValid(true)
   , mCacheWillInvalidate(false)
 {
   bool success = false;
   Unused << ContentChild::GetSingleton()->SendPScreenManagerConstructor(
                                             this,
-                                            &mNumberOfScreens,
                                             &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.");
   }
@@ -142,27 +140,16 @@ nsScreenManagerProxy::ScreenForNativeWid
 
   NS_ADDREF(*outScreen = screen);
 
   InvalidateCacheOnNextTick();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsScreenManagerProxy::GetNumberOfScreens(uint32_t* aNumberOfScreens)
-{
-  if (!EnsureCacheIsValid()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  *aNumberOfScreens = mNumberOfScreens;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 nsScreenManagerProxy::GetSystemDefaultScale(float *aSystemDefaultScale)
 {
   if (!EnsureCacheIsValid()) {
     return NS_ERROR_FAILURE;
   }
 
   *aSystemDefaultScale = mSystemDefaultScale;
   return NS_OK;
@@ -173,17 +160,17 @@ 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(&mNumberOfScreens, &mSystemDefaultScale, &success);
+  Unused << SendRefresh(&mSystemDefaultScale, &success);
   if (!success) {
     NS_WARNING("Refreshing nsScreenManagerProxy failed in the parent process.");
     return false;
   }
 
   mCacheValid = true;
 
   InvalidateCacheOnNextTick();
--- a/widget/nsScreenManagerProxy.h
+++ b/widget/nsScreenManagerProxy.h
@@ -34,17 +34,16 @@ public:
 
 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
--- a/widget/uikit/nsScreenManager.mm
+++ b/widget/uikit/nsScreenManager.mm
@@ -126,21 +126,13 @@ UIKitScreenManager::ScreenForId(uint32_t
 
 NS_IMETHODIMP
 UIKitScreenManager::ScreenForNativeWidget(void* aWidget, nsIScreen** outScreen)
 {
   return GetPrimaryScreen(outScreen);
 }
 
 NS_IMETHODIMP
-UIKitScreenManager::GetNumberOfScreens(uint32_t* aNumberOfScreens)
-{
-  //TODO: support multiple screens
-  *aNumberOfScreens = 1;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 UIKitScreenManager::GetSystemDefaultScale(float* aScale)
 {
     *aScale = [UIScreen mainScreen].scale;
     return NS_OK;
 }
--- a/widget/windows/nsScreenManagerWin.cpp
+++ b/widget/windows/nsScreenManagerWin.cpp
@@ -118,57 +118,16 @@ nsScreenManagerWin::ScreenForRect(int32_
 NS_IMETHODIMP 
 nsScreenManagerWin::GetPrimaryScreen(nsIScreen** aPrimaryScreen) 
 {
   *aPrimaryScreen = CreateNewScreenObject(nullptr);    // addrefs  
   return NS_OK;
   
 } // GetPrimaryScreen
 
-
-//
-// CountMonitors
-//
-// Will be called once for every monitor in the system. Just 
-// increments the parameter, which holds a ptr to a PRUin32 holding the
-// count up to this point.
-//
-BOOL CALLBACK
-CountMonitors(HMONITOR, HDC, LPRECT, LPARAM ioParam)
-{
-  uint32_t* countPtr = reinterpret_cast<uint32_t*>(ioParam);
-  ++(*countPtr);
-
-  return TRUE; // continue the enumeration
-
-} // CountMonitors
-
-
-//
-// GetNumberOfScreens
-//
-// Returns how many physical screens are available.
-//
-NS_IMETHODIMP
-nsScreenManagerWin::GetNumberOfScreens(uint32_t *aNumberOfScreens)
-{
-  if (mNumberOfScreens)
-    *aNumberOfScreens = mNumberOfScreens;
-  else {
-    uint32_t count = 0;
-    BOOL result = ::EnumDisplayMonitors(nullptr, nullptr, (MONITORENUMPROC)CountMonitors, (LPARAM)&count);
-    if (!result)
-      return NS_ERROR_FAILURE;
-    *aNumberOfScreens = mNumberOfScreens = count;
-  }
-
-  return NS_OK;
-  
-} // GetNumberOfScreens
-
 NS_IMETHODIMP
 nsScreenManagerWin::GetSystemDefaultScale(float *aDefaultScale)
 {
   HMONITOR primary = widget::WinUtils::GetPrimaryMonitor();
   *aDefaultScale = float(widget::WinUtils::LogToPhysFactor(primary));
   return NS_OK;
 }