Bug 1356023 - Remove nsIScreenManager.systemDefaultScale. r=jfkthame
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Thu, 13 Apr 2017 07:20:35 +0900
changeset 401280 9ad613f8801ae30eebd7717430bb1f5c36b5701e
parent 401279 5f7780670900e8a3747c500833e67be336380408
child 401281 cdc75dd4209ea183864e8e9a0fcc6aedfbc3366d
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1356023
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 1356023 - Remove nsIScreenManager.systemDefaultScale. r=jfkthame MozReview-Commit-ID: 6Ha8XrJBSiU
toolkit/components/thumbnails/PageThumbUtils.jsm
widget/PuppetWidget.cpp
widget/ScreenManager.cpp
widget/ScreenManager.h
widget/android/nsScreenManagerAndroid.cpp
widget/cocoa/ScreenHelperCocoa.h
widget/cocoa/ScreenHelperCocoa.mm
widget/gonk/nsScreenManagerGonk.cpp
widget/gtk/ScreenHelperGTK.cpp
widget/gtk/ScreenHelperGTK.h
widget/nsIScreenManager.idl
widget/uikit/nsScreenManager.mm
widget/windows/ScreenHelperWin.cpp
widget/windows/ScreenHelperWin.h
--- a/toolkit/components/thumbnails/PageThumbUtils.jsm
+++ b/toolkit/components/thumbnails/PageThumbUtils.jsm
@@ -56,36 +56,24 @@ this.PageThumbUtils = {
    */
   getThumbnailSize(aWindow = null) {
     if (!this._thumbnailWidth || !this._thumbnailHeight) {
       let screenManager = Cc["@mozilla.org/gfx/screenmanager;1"]
                             .getService(Ci.nsIScreenManager);
       let left = {}, top = {}, screenWidth = {}, screenHeight = {};
       screenManager.primaryScreen.GetRectDisplayPix(left, top, screenWidth, screenHeight);
 
-      /** *
-       * The system default scale might be different than
-       * what is reported by the window. For example,
-       * retina displays have 1:1 system scales, but 2:1 window
-       * scale as 1 pixel system wide == 2 device pixels.
+      /**
+       * The primary monitor default scale might be different than
+       * what is reported by the window on mixed-DPI systems.
        * To get the best image quality, query both and take the highest one.
        */
-      let systemScale = screenManager.systemDefaultScale;
-      let windowScale = aWindow ? aWindow.devicePixelRatio : systemScale;
-      let scale = Math.max(systemScale, windowScale);
-
-      /** *
-       * On retina displays, we can sometimes go down this path
-       * without a window object. In those cases, force 2x scaling
-       * as the system scale doesn't represent the 2x scaling
-       * on OS X.
-       */
-      if (AppConstants.platform == "macosx" && !aWindow) {
-        scale = 2;
-      }
+      let primaryScale = screenManager.primaryScreen.defaultCSSScaleFactor;
+      let windowScale = aWindow ? aWindow.devicePixelRatio : primaryScale;
+      let scale = Math.max(primaryScale, windowScale);
 
       /** *
        * THESE VALUES ARE DEFINED IN newtab.css and hard coded.
        * If you change these values from the prefs,
        * ALSO CHANGE THEM IN newtab.css
        */
       let prefWidth = Services.prefs.getIntPref("toolkit.pageThumbs.minWidth");
       let prefHeight = Services.prefs.getIntPref("toolkit.pageThumbs.minHeight");
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -1424,23 +1424,16 @@ PuppetScreenManager::ScreenForRect(int32
                                    int32_t inTop,
                                    int32_t inWidth,
                                    int32_t inHeight,
                                    nsIScreen** outScreen)
 {
   return GetPrimaryScreen(outScreen);
 }
 
-NS_IMETHODIMP
-PuppetScreenManager::GetSystemDefaultScale(float *aDefaultScale)
-{
-  *aDefaultScale = 1.0f;
-  return NS_OK;
-}
-
 nsIWidgetListener*
 PuppetWidget::GetCurrentWidgetListener()
 {
   if (!mPreviouslyAttachedWidgetListener ||
       !mAttachedWidgetListener) {
     return mAttachedWidgetListener;
   }
 
--- a/widget/ScreenManager.cpp
+++ b/widget/ScreenManager.cpp
@@ -183,21 +183,10 @@ ScreenManager::GetPrimaryScreen(nsIScree
     return NS_OK;
   }
 
   RefPtr<Screen> ret = mScreenList[0];
   ret.forget(aPrimaryScreen);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-ScreenManager::GetSystemDefaultScale(float* aDefaultScale)
-{
-  if (mHelper) {
-    *aDefaultScale = mHelper->GetSystemDefaultScale();
-    return NS_OK;
-  }
-  *aDefaultScale = 1;
-  return NS_OK;
-}
-
 } // namespace widget
 } // namespace mozilla
--- a/widget/ScreenManager.h
+++ b/widget/ScreenManager.h
@@ -25,18 +25,17 @@ namespace mozilla {
 namespace widget {
 
 class ScreenManager final : public nsIScreenManager
 {
 public:
   class Helper
   {
   public:
-    virtual float GetSystemDefaultScale() = 0;
-    virtual ~Helper() {};
+    virtual ~Helper() {}
   };
 
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSISCREENMANAGER
 
   static ScreenManager& GetSingleton();
   static already_AddRefed<ScreenManager> GetAddRefedSingleton();
--- a/widget/android/nsScreenManagerAndroid.cpp
+++ b/widget/android/nsScreenManagerAndroid.cpp
@@ -198,23 +198,16 @@ nsScreenManagerAndroid::ScreenForRect(in
                                       int32_t inWidth,
                                       int32_t inHeight,
                                       nsIScreen **outScreen)
 {
     // Not support to query non-primary screen with rect.
     return GetPrimaryScreen(outScreen);
 }
 
-NS_IMETHODIMP
-nsScreenManagerAndroid::GetSystemDefaultScale(float *aDefaultScale)
-{
-    *aDefaultScale = 1.0f;
-    return NS_OK;
-}
-
 already_AddRefed<nsScreenAndroid>
 nsScreenManagerAndroid::AddScreen(DisplayType aDisplayType, nsIntRect aRect)
 {
     ALOG("nsScreenManagerAndroid: add %s screen",
         (aDisplayType == DisplayType::DISPLAY_PRIMARY  ? "PRIMARY"  :
         (aDisplayType == DisplayType::DISPLAY_EXTERNAL ? "EXTERNAL" :
                                                          "VIRTUAL")));
     RefPtr<nsScreenAndroid> screen = new nsScreenAndroid(aDisplayType, aRect);
--- a/widget/cocoa/ScreenHelperCocoa.h
+++ b/widget/cocoa/ScreenHelperCocoa.h
@@ -16,18 +16,16 @@ namespace mozilla {
 namespace widget {
 
 class ScreenHelperCocoa final : public ScreenManager::Helper
 {
 public:
   ScreenHelperCocoa();
   ~ScreenHelperCocoa() override;
 
-  float GetSystemDefaultScale() override;
-
   void RefreshScreens();
 
   static NSScreen* CocoaScreenForScreen(nsIScreen* aScreen);
 
 private:
   ScreenHelperDelegate* mDelegate;
 };
 
--- a/widget/cocoa/ScreenHelperCocoa.mm
+++ b/widget/cocoa/ScreenHelperCocoa.mm
@@ -102,22 +102,16 @@ MakeScreen(NSScreen* aScreen)
   RefPtr<Screen> screen = new Screen(rect, availRect,
                                      pixelDepth, pixelDepth,
                                      contentsScaleFactor, defaultCssScaleFactor);
   return screen.forget();
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(nullptr);
 }
 
-float
-ScreenHelperCocoa::GetSystemDefaultScale()
-{
-  return 1.0f;
-}
-
 void
 ScreenHelperCocoa::RefreshScreens()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   MOZ_LOG(sScreenLog, LogLevel::Debug, ("Refreshing screens"));
 
   AutoTArray<RefPtr<Screen>, 4> screens;
--- a/widget/gonk/nsScreenManagerGonk.cpp
+++ b/widget/gonk/nsScreenManagerGonk.cpp
@@ -826,23 +826,16 @@ nsScreenManagerGonk::ScreenForRect(int32
                                    int32_t inHeight,
                                    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::GetSystemDefaultScale(float *aDefaultScale)
-{
-    *aDefaultScale = 1.0f;
-    return NS_OK;
-}
-
 void
 nsScreenManagerGonk::VsyncControl(bool aEnabled)
 {
     if (!NS_IsMainThread()) {
         NS_DispatchToMainThread(
             NewRunnableMethod<bool>(this,
                                     &nsScreenManagerGonk::VsyncControl,
                                     aEnabled));
--- a/widget/gtk/ScreenHelperGTK.cpp
+++ b/widget/gtk/ScreenHelperGTK.cpp
@@ -143,26 +143,16 @@ ScreenHelperGTK::GetGTKMonitorScaleFacto
 }
 
 static float
 GetDefaultCssScale()
 {
   return ScreenHelperGTK::GetGTKMonitorScaleFactor() * gfxPlatformGtk::GetDPIScale();
 }
 
-float
-ScreenHelperGTK::GetSystemDefaultScale()
-{
-  double scale = nsIWidget::DefaultScaleOverride();
-  if (scale <= 0.0) {
-    scale = GetDefaultCssScale();
-  }
-  return scale;
-}
-
 static uint32_t
 GetGTKPixelDepth()
 {
   GdkVisual * visual = gdk_screen_get_system_visual(gdk_screen_get_default());
   return gdk_visual_get_depth(visual);
 }
 
 static already_AddRefed<Screen>
--- a/widget/gtk/ScreenHelperGTK.h
+++ b/widget/gtk/ScreenHelperGTK.h
@@ -19,18 +19,16 @@ namespace mozilla {
 namespace widget {
 
 class ScreenHelperGTK final : public ScreenManager::Helper
 {
 public:
   ScreenHelperGTK();
   ~ScreenHelperGTK() override;
 
-  float GetSystemDefaultScale() override;
-
   static gint GetGTKMonitorScaleFactor();
 
 #ifdef MOZ_X11
   Atom NetWorkareaAtom() { return mNetWorkareaAtom; }
 #endif
 
   // For internal use from signal callback functions
   void RefreshScreens();
--- a/widget/nsIScreenManager.idl
+++ b/widget/nsIScreenManager.idl
@@ -16,29 +16,9 @@ interface nsIScreenManager : nsISupports
     //
     // 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 ) ;
 
     // 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
-    // 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.
-    //
-    // NOTE that on OS X, this does -not- reflect the "backing scale factor"
-    // used to support Retina displays, which is a per-display property,
-    // not a system-wide scaling factor. The default ratio of CSS pixels to
-    // 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;
 };
--- a/widget/uikit/nsScreenManager.mm
+++ b/widget/uikit/nsScreenManager.mm
@@ -111,15 +111,8 @@ NS_IMETHODIMP
 UIKitScreenManager::ScreenForRect(int32_t inLeft,
                                int32_t inTop,
                                int32_t inWidth,
                                int32_t inHeight,
                                nsIScreen** outScreen)
 {
   return GetPrimaryScreen(outScreen);
 }
-
-NS_IMETHODIMP
-UIKitScreenManager::GetSystemDefaultScale(float* aScale)
-{
-    *aScale = [UIScreen mainScreen].scale;
-    return NS_OK;
-}
--- a/widget/windows/ScreenHelperWin.cpp
+++ b/widget/windows/ScreenHelperWin.cpp
@@ -62,23 +62,16 @@ CollectMonitors(HMONITOR aMon, HDC, LPRE
     // The primary monitor must be the first element of the screen list.
     screens->InsertElementAt(0, Move(screen));
   } else {
     screens->AppendElement(Move(screen));
   }
   return TRUE;
 }
 
-float
-ScreenHelperWin::GetSystemDefaultScale()
-{
-  HMONITOR primary = widget::WinUtils::GetPrimaryMonitor();
-  return float(widget::WinUtils::LogToPhysFactor(primary));
-}
-
 void
 ScreenHelperWin::RefreshScreens()
 {
   MOZ_LOG(sScreenLog, LogLevel::Debug, ("Refreshing screens"));
 
   AutoTArray<RefPtr<Screen>, 4> screens;
   BOOL result = ::EnumDisplayMonitors(nullptr, nullptr,
                                       (MONITORENUMPROC)CollectMonitors,
--- a/widget/windows/ScreenHelperWin.h
+++ b/widget/windows/ScreenHelperWin.h
@@ -12,17 +12,16 @@
 namespace mozilla {
 namespace widget {
 
 class ScreenHelperWin final : public ScreenManager::Helper
 {
 public:
   ScreenHelperWin() {};
   ~ScreenHelperWin() override {}
-  float GetSystemDefaultScale() override;
 
   static void RefreshScreens();
 };
 
 } // namespace widget
 } // namespace mozilla
 
 #endif // mozilla_widget_windows_ScreenHelperWin_h