mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 493202. Add a layout.css.devPixelsPerPx hidden pref to control that ratio if desired. r=vlad
This commit is contained in:
parent
9eb2887534
commit
8d23e695a3
@ -621,6 +621,18 @@ nsThebesDeviceContext::SetDPI()
|
||||
{
|
||||
PRInt32 dpi = -1;
|
||||
PRBool dotsArePixels = PR_TRUE;
|
||||
// The number of device pixels per CSS pixel. A value <= 0 means choose
|
||||
// automatically based on the DPI. A positive value is used as-is. This effectively
|
||||
// controls the size of a CSS "px".
|
||||
PRInt32 prefDevPixelsPerCSSPixel = -1;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefs) {
|
||||
nsresult rv = prefs->GetIntPref("layout.css.devPixelsPerPx", &prefDevPixelsPerCSSPixel);
|
||||
if (NS_FAILED(rv)) {
|
||||
prefDevPixelsPerCSSPixel = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// PostScript, PDF and Mac (when printing) all use 72 dpi
|
||||
if (mPrintingSurface &&
|
||||
@ -630,16 +642,12 @@ nsThebesDeviceContext::SetDPI()
|
||||
dpi = 72;
|
||||
dotsArePixels = PR_FALSE;
|
||||
} else {
|
||||
// Get prefVal the value of the preference
|
||||
// "layout.css.dpi"
|
||||
// or -1 if we can't get it.
|
||||
// If it's negative, use the default DPI setting
|
||||
// If it's 0, force the use of the OS's set resolution. Set this if your
|
||||
// X server has the correct DPI and it's less than 96dpi.
|
||||
// If it's positive, we use it as the logical resolution
|
||||
nsresult rv;
|
||||
PRInt32 prefDPI;
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
// A value of -1 means use the minimum of 96 and the system DPI.
|
||||
// A value of 0 means use the system DPI. A positive value is used as the DPI.
|
||||
// This sets the physical size of a device pixel and thus controls the
|
||||
// interpretation of physical units such as "pt".
|
||||
PRInt32 prefDPI = -1;
|
||||
if (prefs) {
|
||||
rv = prefs->GetIntPref("layout.css.dpi", &prefDPI);
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -715,18 +723,23 @@ nsThebesDeviceContext::SetDPI()
|
||||
NS_ASSERTION(dpi != -1, "no dpi set");
|
||||
|
||||
if (dotsArePixels) {
|
||||
// First figure out the closest multiple of 96, which is the number of
|
||||
// dev pixels per CSS pixel. Then, divide that into AppUnitsPerCSSPixel()
|
||||
// to get the number of app units per dev pixel. The PR_MAXes are to
|
||||
// make sure we don't end up dividing by zero.
|
||||
PRUint32 roundedDPIScaleFactor = (dpi + 48)/96;
|
||||
if (prefDevPixelsPerCSSPixel <= 0) {
|
||||
// First figure out the closest multiple of 96, which is the number of
|
||||
// dev pixels per CSS pixel. Then, divide that into AppUnitsPerCSSPixel()
|
||||
// to get the number of app units per dev pixel. The PR_MAXes are to
|
||||
// make sure we don't end up dividing by zero.
|
||||
PRUint32 roundedDPIScaleFactor = (dpi + 48)/96;
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
// be more conservative about activating scaling on GTK2, since the dpi
|
||||
// information is more likely to be wrong
|
||||
roundedDPIScaleFactor = dpi/96;
|
||||
// be more conservative about activating scaling on GTK2, since the dpi
|
||||
// information is more likely to be wrong
|
||||
roundedDPIScaleFactor = dpi/96;
|
||||
#endif
|
||||
mAppUnitsPerDevNotScaledPixel =
|
||||
PR_MAX(1, AppUnitsPerCSSPixel() / PR_MAX(1, roundedDPIScaleFactor));
|
||||
mAppUnitsPerDevNotScaledPixel =
|
||||
PR_MAX(1, AppUnitsPerCSSPixel() / PR_MAX(1, roundedDPIScaleFactor));
|
||||
} else {
|
||||
mAppUnitsPerDevNotScaledPixel =
|
||||
PR_MAX(1, AppUnitsPerCSSPixel() / prefDevPixelsPerCSSPixel);
|
||||
}
|
||||
} else {
|
||||
/* set mAppUnitsPerDevPixel so we're using exactly 72 dpi, even
|
||||
* though that means we have a non-integer number of device "pixels"
|
||||
|
@ -297,6 +297,9 @@ nsPresContext::~nsPresContext()
|
||||
nsContentUtils::UnregisterPrefCallback("layout.css.dpi",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::UnregisterPrefCallback("layout.css.devPixelsPerPx",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
|
||||
NS_IF_RELEASE(mDeviceContext);
|
||||
NS_IF_RELEASE(mLookAndFeel);
|
||||
@ -747,7 +750,8 @@ void
|
||||
nsPresContext::PreferenceChanged(const char* aPrefName)
|
||||
{
|
||||
nsDependentCString prefName(aPrefName);
|
||||
if (prefName.EqualsLiteral("layout.css.dpi")) {
|
||||
if (prefName.EqualsLiteral("layout.css.dpi") ||
|
||||
prefName.EqualsLiteral("layout.css.devPixelsPerPx")) {
|
||||
PRInt32 oldAppUnitsPerDevPixel = AppUnitsPerDevPixel();
|
||||
if (mDeviceContext->CheckDPIChange() && mShell) {
|
||||
mDeviceContext->FlushFontCache();
|
||||
@ -891,6 +895,9 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
||||
nsContentUtils::RegisterPrefCallback("layout.css.dpi",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::RegisterPrefCallback("layout.css.devPixelsPerPx",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
|
||||
rv = mEventManager->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -1088,6 +1088,18 @@ pref("layout.css.report_errors", true);
|
||||
// Should the :visited selector ever match (otherwise :link matches instead)?
|
||||
pref("layout.css.visited_links_enabled", true);
|
||||
|
||||
// Override DPI. A value of -1 means use the minimum of 96 and the system DPI.
|
||||
// A value of 0 means use the system DPI. A positive value is used as the DPI.
|
||||
// This sets the physical size of a device pixel and thus controls the
|
||||
// interpretation of physical units such as "pt".
|
||||
pref("layout.css.dpi", -1);
|
||||
|
||||
// Set the number of device pixels per CSS pixel. A value <= 0 means choose
|
||||
// automatically based on the DPI. A positive value is used as-is. This effectively
|
||||
// controls the size of a CSS "px". This is only used for pixel-based
|
||||
// (screen) output devices.
|
||||
pref("layout.css.devPixelsPerPx", -1);
|
||||
|
||||
// pref for which side vertical scrollbars should be on
|
||||
// 0 = end-side in UI direction
|
||||
// 1 = end-side in document/content direction
|
||||
@ -1994,7 +2006,6 @@ pref("ui.panel.default_level_parent", false);
|
||||
#ifdef XP_OS2
|
||||
|
||||
pref("ui.key.menuAccessKeyFocuses", true);
|
||||
pref("layout.css.dpi", -1); // max(96dpi, System setting)
|
||||
|
||||
pref("font.alias-list", "sans,sans-serif,serif,monospace,Tms Rmn,Helv,Courier,Times New Roman");
|
||||
|
||||
@ -2195,8 +2206,6 @@ pref("ui.panel.default_level_parent", false);
|
||||
|
||||
#ifdef XP_BEOS
|
||||
|
||||
pref("layout.css.dpi", -1); // max(96dpi, System setting)
|
||||
|
||||
pref("intl.font_charset", "");
|
||||
pref("intl.font_spec_list", "");
|
||||
pref("mail.signature_date", 0);
|
||||
@ -2295,7 +2304,6 @@ pref("ui.panel.default_level_parent", false);
|
||||
pref("network.hosts.smtp_server", "localhost");
|
||||
pref("network.hosts.pop_server", "pop");
|
||||
pref("network.protocol-handler.warn-external.file", false);
|
||||
pref("layout.css.dpi", -1); // max(96dpi, System setting)
|
||||
pref("browser.drag_out_of_frame_style", 1);
|
||||
pref("editor.singleLine.pasteNewlines", 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user