bug 851520 - add systemDefaultScale attribute to nsIScreenManager, and use it to decide when to remove browser.content.full-zoom prefs during UI migration if running on windows/hi-dpi. r=roc,adw

This commit is contained in:
Jonathan Kew 2013-04-09 22:07:02 +01:00
parent b12a4431e0
commit 4e2d905cd6
10 changed files with 92 additions and 2 deletions

View File

@ -1223,7 +1223,7 @@ BrowserGlue.prototype = {
},
_migrateUI: function BG__migrateUI() {
const UI_VERSION = 9;
const UI_VERSION = 10;
const BROWSER_DOCURL = "chrome://browser/content/browser.xul#";
let currentUIVersion = 0;
try {
@ -1366,6 +1366,21 @@ BrowserGlue.prototype = {
Services.prefs.clearUserPref("browser.library.useNewDownloadsView");
}
#ifdef XP_WIN
if (currentUIVersion < 10) {
// For Windows systems with display set to > 96dpi (i.e. systemDefaultScale
// will return a value > 1.0), we want to discard any saved full-zoom settings,
// as we'll now be scaling the content according to the system resolution
// scale factor (Windows "logical DPI" setting)
let sm = Cc["@mozilla.org/gfx/screenmanager;1"].getService(Ci.nsIScreenManager);
if (sm.systemDefaultScale > 1.0) {
let cps2 = Cc["@mozilla.org/content-pref/service;1"].
getService(Ci.nsIContentPrefService2);
cps2.removeByName("browser.content.full-zoom", null);
}
}
#endif
if (this._dirty)
this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();

View File

@ -105,3 +105,9 @@ nsScreenManagerAndroid::GetNumberOfScreens(uint32_t *aNumberOfScreens)
return NS_OK;
}
NS_IMETHODIMP
nsScreenManagerAndroid::GetSystemDefaultScale(float *aDefaultScale)
{
*aDefaultScale = 1.0f;
return NS_OK;
}

View File

@ -96,6 +96,13 @@ nsScreenManagerCocoa::GetNumberOfScreens (uint32_t *aNumberOfScreens)
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)
{

View File

@ -872,3 +872,10 @@ nsScreenManagerGonk::GetNumberOfScreens(uint32_t *aNumberOfScreens)
*aNumberOfScreens = 1;
return NS_OK;
}
NS_IMETHODIMP
nsScreenManagerGonk::GetSystemDefaultScale(float *aDefaultScale)
{
*aDefaultScale = 1.0f;
return NS_OK;
}

View File

@ -284,6 +284,13 @@ nsScreenManagerGtk :: GetNumberOfScreens(uint32_t *aNumberOfScreens)
} // GetNumberOfScreens
NS_IMETHODIMP
nsScreenManagerGtk::GetSystemDefaultScale(float *aDefaultScale)
{
*aDefaultScale = 1.0f;
return NS_OK;
}
NS_IMETHODIMP
nsScreenManagerGtk :: ScreenForNativeWidget (void *aWidget, nsIScreen **outScreen)
{

View File

@ -7,7 +7,7 @@
#include "nsISupports.idl"
#include "nsIScreen.idl"
[scriptable, uuid(B92319E6-9A84-4ca7-A2CC-EEC22EA9854E)]
[scriptable, uuid(1C195990-FF9E-412B-AFE7-67D1C660BB27)]
interface nsIScreenManager : nsISupports
{
//
@ -25,6 +25,26 @@ interface nsIScreenManager : nsISupports
// 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.
//
// 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;
// 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.

View File

@ -91,6 +91,13 @@ nsScreenManagerOS2 :: GetNumberOfScreens(uint32_t *aNumberOfScreens)
} // GetNumberOfScreens
NS_IMETHODIMP
nsScreenManagerOS2::GetSystemDefaultScale(float *aDefaultScale)
{
*aDefaultScale = 1.0f;
return NS_OK;
}
NS_IMETHODIMP
nsScreenManagerOS2 :: ScreenForNativeWidget(void *nativeWidget, nsIScreen **aScreen)
{

View File

@ -99,6 +99,13 @@ nsScreenManagerQt::GetNumberOfScreens(uint32_t *aNumberOfScreens)
return NS_OK;
}
NS_IMETHODIMP
nsScreenManagerQt::GetSystemDefaultScale(float *aDefaultScale)
{
*aDefaultScale = 1.0f;
return NS_OK;
}
NS_IMETHODIMP
nsScreenManagerQt :: ScreenForNativeWidget (void *aWidget, nsIScreen **outScreen)
{

View File

@ -154,6 +154,13 @@ nsScreenManagerWin :: GetNumberOfScreens(uint32_t *aNumberOfScreens)
} // GetNumberOfScreens
NS_IMETHODIMP
nsScreenManagerWin::GetSystemDefaultScale(float *aDefaultScale)
{
*aDefaultScale = float(gfxWindowsPlatform::GetPlatform()->GetDPIScale());
return NS_OK;
}
NS_IMETHODIMP
nsScreenManagerWin :: ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen)
{

View File

@ -762,5 +762,12 @@ PuppetScreenManager::GetNumberOfScreens(uint32_t* aNumberOfScreens)
return NS_OK;
}
NS_IMETHODIMP
PuppetScreenManager::GetSystemDefaultScale(float *aDefaultScale)
{
*aDefaultScale = 1.0f;
return NS_OK;
}
} // namespace widget
} // namespace mozilla