mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-22 10:27:03 +00:00
Bug 513439. Parse layout.css.devPixelsPerCSSPx as a string float. r=roc
--HG-- extra : rebase_source : 28d39726e3714d2614f5f010a8e6f914ddecaf75
This commit is contained in:
parent
e94dfedb9f
commit
28b8e15f98
@ -624,13 +624,14 @@ nsThebesDeviceContext::SetDPI()
|
||||
// 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;
|
||||
float prefDevPixelsPerCSSPixel = -1.0;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefs) {
|
||||
nsresult rv = prefs->GetIntPref("layout.css.devPixelsPerPx", &prefDevPixelsPerCSSPixel);
|
||||
if (NS_FAILED(rv)) {
|
||||
prefDevPixelsPerCSSPixel = -1;
|
||||
nsXPIDLCString prefString;
|
||||
nsresult rv = prefs->GetCharPref("layout.css.devPixelsPerPx", getter_Copies(prefString));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
prefDevPixelsPerCSSPixel = static_cast<float>(atof(prefString));
|
||||
}
|
||||
}
|
||||
|
||||
@ -738,7 +739,8 @@ nsThebesDeviceContext::SetDPI()
|
||||
PR_MAX(1, AppUnitsPerCSSPixel() / PR_MAX(1, roundedDPIScaleFactor));
|
||||
} else {
|
||||
mAppUnitsPerDevNotScaledPixel =
|
||||
PR_MAX(1, AppUnitsPerCSSPixel() / prefDevPixelsPerCSSPixel);
|
||||
PR_MAX(1, static_cast<PRInt32>(AppUnitsPerCSSPixel() /
|
||||
prefDevPixelsPerCSSPixel));
|
||||
}
|
||||
} else {
|
||||
/* set mAppUnitsPerDevPixel so we're using exactly 72 dpi, even
|
||||
|
@ -8,7 +8,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = thebes
|
||||
|
||||
DIRS = public src
|
||||
DIRS = public src mochitest
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
ifndef MOZ_ENABLE_LIBXUL
|
||||
|
51
gfx/thebes/mochitest/Makefile.in
Normal file
51
gfx/thebes/mochitest/Makefile.in
Normal file
@ -0,0 +1,51 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Sylvain Pasche <sylvain.pasche@gmail.com>
|
||||
# Portions created by the Initial Developer are Copyright (C) 2007
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = gfx/thebes/mochitest
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES = test_bug513439.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
|
47
gfx/thebes/mochitest/test_bug513439.html
Normal file
47
gfx/thebes/mochitest/test_bug513439.html
Normal file
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=513439
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 513439</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=513439">Mozilla Bug 513439</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 513439 **/
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
var layoutCSSBranch = prefService.getBranch("layout.css.");
|
||||
var oldVal = layoutCSSBranch.getCharPref("devPixelsPerPx");
|
||||
|
||||
try {
|
||||
var domWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
var devPxPerCSSPx = domWindowUtils.screenPixelsPerCSSPixel;
|
||||
|
||||
layoutCSSBranch.setCharPref("devPixelsPerPx", "2");
|
||||
is(domWindowUtils.screenPixelsPerCSSPixel, 2, "devPixelsPerPx wasn't set correctly");
|
||||
|
||||
layoutCSSBranch.setCharPref("devPixelsPerPx", "1.5");
|
||||
is(domWindowUtils.screenPixelsPerCSSPixel, 1.5, "devPixelsPerPx wasn't set correctly");
|
||||
|
||||
} finally {
|
||||
layoutCSSBranch.setCharPref("devPixelsPerPx", oldVal);
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1125,7 +1125,7 @@ pref("layout.css.dpi", -1);
|
||||
// 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("layout.css.devPixelsPerPx", "-1");
|
||||
|
||||
// pref for which side vertical scrollbars should be on
|
||||
// 0 = end-side in UI direction
|
||||
|
Loading…
x
Reference in New Issue
Block a user