mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-27 10:50:35 +00:00
#5000: added "browser.screen_resolution" pref
This commit is contained in:
parent
5672625203
commit
710dd4f29d
@ -28,9 +28,11 @@
|
||||
#include <Resources.h>
|
||||
#include "il_util.h"
|
||||
#include <FixMath.h>
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
|
||||
const PRUint32 nsDeviceContextMac::kPixelsPerInch = 96;
|
||||
PRUint32 nsDeviceContextMac::mPixelsPerInch = 96;
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
@ -72,7 +74,7 @@ double pix_inch;
|
||||
thegd = ::GetMainDevice();
|
||||
thepix = (**thegd).gdPMap; // dereferenced handle: don't move memory below!
|
||||
mDepth = (**thepix).pixelSize;
|
||||
pix_inch = kPixelsPerInch; //Fix2X((**thepix).hRes);
|
||||
pix_inch = GetScreenResolution(); //Fix2X((**thepix).hRes);
|
||||
mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72);
|
||||
mPixelsToTwips = 1.0f/mTwipsToPixels;
|
||||
|
||||
@ -325,6 +327,7 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PR
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextMac::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,nsIDeviceContext *&aContext)
|
||||
@ -561,3 +564,32 @@ nsresult nsDeviceContextMac::CreateFontAliasTable()
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
PRUint32 nsDeviceContextMac::GetScreenResolution()
|
||||
{
|
||||
static PRBool initialized = PR_FALSE;
|
||||
if (initialized)
|
||||
return mPixelsPerInch;
|
||||
initialized = PR_TRUE;
|
||||
|
||||
nsIPref* prefs;
|
||||
nsresult rv = nsServiceManager::GetService(kPrefCID, kIPrefIID, (nsISupports**)&prefs);
|
||||
if (NS_SUCCEEDED(rv) && prefs) {
|
||||
PRInt32 intVal;
|
||||
if (NS_SUCCEEDED(prefs->GetIntPref("browser.screen_resolution", &intVal))) {
|
||||
mPixelsPerInch = intVal;
|
||||
}
|
||||
nsServiceManager::ReleaseService(kPrefCID, prefs);
|
||||
}
|
||||
|
||||
|
||||
return mPixelsPerInch;
|
||||
|
||||
}
|
||||
|
@ -79,7 +79,10 @@ protected:
|
||||
public:
|
||||
static bool GetMacFontNumber(const nsString& aFontName, short &fontNum);
|
||||
|
||||
static const PRUint32 kPixelsPerInch;
|
||||
private:
|
||||
static PRUint32 mPixelsPerInch;
|
||||
public:
|
||||
static PRUint32 GetScreenResolution();
|
||||
};
|
||||
|
||||
#endif /* nsDeviceContextMac_h___ */
|
||||
|
@ -113,8 +113,8 @@ PRInt32 bufferdepth;
|
||||
mThePixelmap.pixelSize = bufferdepth;
|
||||
mThePixelmap.packType = 0;
|
||||
mThePixelmap.packSize = 0;
|
||||
mThePixelmap.hRes = nsDeviceContextMac::kPixelsPerInch<<16;
|
||||
mThePixelmap.vRes = nsDeviceContextMac::kPixelsPerInch<<16;
|
||||
mThePixelmap.hRes = nsDeviceContextMac::GetScreenResolution()<<16;
|
||||
mThePixelmap.vRes = nsDeviceContextMac::GetScreenResolution()<<16;
|
||||
mThePixelmap.planeBytes = 0;
|
||||
mThePixelmap.pmReserved = 0;
|
||||
mThePixelmap.pmVersion = 0;
|
||||
|
@ -28,9 +28,11 @@
|
||||
#include <Resources.h>
|
||||
#include "il_util.h"
|
||||
#include <FixMath.h>
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
|
||||
const PRUint32 nsDeviceContextMac::kPixelsPerInch = 96;
|
||||
PRUint32 nsDeviceContextMac::mPixelsPerInch = 96;
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
@ -72,7 +74,7 @@ double pix_inch;
|
||||
thegd = ::GetMainDevice();
|
||||
thepix = (**thegd).gdPMap; // dereferenced handle: don't move memory below!
|
||||
mDepth = (**thepix).pixelSize;
|
||||
pix_inch = kPixelsPerInch; //Fix2X((**thepix).hRes);
|
||||
pix_inch = GetScreenResolution(); //Fix2X((**thepix).hRes);
|
||||
mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72);
|
||||
mPixelsToTwips = 1.0f/mTwipsToPixels;
|
||||
|
||||
@ -325,6 +327,7 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PR
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextMac::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,nsIDeviceContext *&aContext)
|
||||
@ -561,3 +564,32 @@ nsresult nsDeviceContextMac::CreateFontAliasTable()
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
PRUint32 nsDeviceContextMac::GetScreenResolution()
|
||||
{
|
||||
static PRBool initialized = PR_FALSE;
|
||||
if (initialized)
|
||||
return mPixelsPerInch;
|
||||
initialized = PR_TRUE;
|
||||
|
||||
nsIPref* prefs;
|
||||
nsresult rv = nsServiceManager::GetService(kPrefCID, kIPrefIID, (nsISupports**)&prefs);
|
||||
if (NS_SUCCEEDED(rv) && prefs) {
|
||||
PRInt32 intVal;
|
||||
if (NS_SUCCEEDED(prefs->GetIntPref("browser.screen_resolution", &intVal))) {
|
||||
mPixelsPerInch = intVal;
|
||||
}
|
||||
nsServiceManager::ReleaseService(kPrefCID, prefs);
|
||||
}
|
||||
|
||||
|
||||
return mPixelsPerInch;
|
||||
|
||||
}
|
||||
|
@ -79,7 +79,10 @@ protected:
|
||||
public:
|
||||
static bool GetMacFontNumber(const nsString& aFontName, short &fontNum);
|
||||
|
||||
static const PRUint32 kPixelsPerInch;
|
||||
private:
|
||||
static PRUint32 mPixelsPerInch;
|
||||
public:
|
||||
static PRUint32 GetScreenResolution();
|
||||
};
|
||||
|
||||
#endif /* nsDeviceContextMac_h___ */
|
||||
|
Loading…
Reference in New Issue
Block a user