Bug 1352773 - Take into account DefaultScaleOverride in Screen::GetDefaultCSSScaleFactor. r=kanru
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Wed, 05 Apr 2017 22:11:34 +0900
changeset 351655 68a13da9b6f255df1edde21d0ffb4669988a7cec
parent 351654 a8a2f17897b583db07f5ba53450234b326201567
child 351656 b21110aa79591ea6556ca0c9781675ec039e6599
push id31618
push usercbook@mozilla.com
push dateFri, 07 Apr 2017 13:06:08 +0000
treeherdermozilla-central@6471400d8fbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskanru
bugs1352773
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 1352773 - Take into account DefaultScaleOverride in Screen::GetDefaultCSSScaleFactor. r=kanru MozReview-Commit-ID: EJidy1NH3DX
widget/Screen.cpp
widget/gtk/ScreenHelperGTK.cpp
widget/windows/ScreenHelperWin.cpp
--- a/widget/Screen.cpp
+++ b/widget/Screen.cpp
@@ -131,14 +131,19 @@ Screen::GetContentsScaleFactor(double *a
 {
   *aOutScale = mContentsScale.scale;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Screen::GetDefaultCSSScaleFactor(double *aOutScale)
 {
-  *aOutScale = mDefaultCssScale.scale;
+  double scale = nsIWidget::DefaultScaleOverride();
+  if (scale > 0.0) {
+    *aOutScale = scale;
+  } else {
+    *aOutScale = mDefaultCssScale.scale;
+  }
   return NS_OK;
 }
 
 } // namespace widget
 } // namespace mozilla
--- a/widget/gtk/ScreenHelperGTK.cpp
+++ b/widget/gtk/ScreenHelperGTK.cpp
@@ -140,27 +140,27 @@ ScreenHelperGTK::GetGTKMonitorScaleFacto
   }
 #endif
   return 1;
 }
 
 static float
 GetDefaultCssScale()
 {
-  double scale = nsIWidget::DefaultScaleOverride();
-  if (scale <= 0.0) {
-    scale = ScreenHelperGTK::GetGTKMonitorScaleFactor() * gfxPlatformGtk::GetDPIScale();
-  }
-  return scale;
+  return ScreenHelperGTK::GetGTKMonitorScaleFactor() * gfxPlatformGtk::GetDPIScale();
 }
 
 float
 ScreenHelperGTK::GetSystemDefaultScale()
 {
-  return GetDefaultCssScale();
+  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);
 }
--- a/widget/windows/ScreenHelperWin.cpp
+++ b/widget/windows/ScreenHelperWin.cpp
@@ -29,20 +29,17 @@ CollectMonitors(HMONITOR aMon, HDC, LPRE
   }
   double scale = WinUtils::LogToPhysFactor(aMon);
   DesktopToLayoutDeviceScale contentsScaleFactor;
   if (WinUtils::IsPerMonitorDPIAware()) {
     contentsScaleFactor.scale = 1.0;
   } else {
     contentsScaleFactor.scale = scale;
   }
-  CSSToLayoutDeviceScale defaultCssScaleFactor(nsIWidget::DefaultScaleOverride());
-  if (defaultCssScaleFactor.scale <= 0.0) {
-    defaultCssScaleFactor.scale = scale;
-  }
+  CSSToLayoutDeviceScale defaultCssScaleFactor(scale);
   LayoutDeviceIntRect rect(info.rcMonitor.left, info.rcMonitor.top,
                            info.rcMonitor.right - info.rcMonitor.left,
                            info.rcMonitor.bottom - info.rcMonitor.top);
   LayoutDeviceIntRect availRect(info.rcWork.left, info.rcWork.top,
                                 info.rcWork.right - info.rcWork.left,
                                 info.rcWork.bottom - info.rcWork.top);
   //XXX not sure how to get this info for multiple monitors, this might be ok...
   HDC hDCScreen = ::GetDC(nullptr);