зеркало из https://github.com/mozilla/gecko-dev.git
Change our interpretation of resolution units in CSS to match updates to the spec: i.e., device pixels per CSS inch (instead of device pixels per physical inch). (Bug 771390) r=bzbarsky
Given that this makes GetResolution work like GetDevicePixelRatio, I believe this should also fix bug 662061 (on resolution's behavior when zooming)?
This commit is contained in:
Родитель
4bf35ecd35
Коммит
c51fdbf971
|
@ -248,9 +248,10 @@ static nsresult
|
||||||
GetResolution(nsPresContext* aPresContext, const nsMediaFeature*,
|
GetResolution(nsPresContext* aPresContext, const nsMediaFeature*,
|
||||||
nsCSSValue& aResult)
|
nsCSSValue& aResult)
|
||||||
{
|
{
|
||||||
// Resolution values are in device pixels, not CSS pixels.
|
// Resolution measures device pixels per CSS (inch/cm/pixel). We
|
||||||
nsDeviceContext *dx = GetDeviceContextFor(aPresContext);
|
// return it in device pixels per CSS inches.
|
||||||
float dpi = float(dx->AppUnitsPerPhysicalInch()) / float(dx->AppUnitsPerDevPixel());
|
float dpi = float(nsPresContext::AppUnitsPerCSSInch()) /
|
||||||
|
float(aPresContext->AppUnitsPerDevPixel());
|
||||||
aResult.SetFloatValue(dpi, eCSSUnit_Inch);
|
aResult.SetFloatValue(dpi, eCSSUnit_Inch);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,6 +483,7 @@ function run() {
|
||||||
var dpi_low = resolution - 1;
|
var dpi_low = resolution - 1;
|
||||||
if (query_applies("(min-resolution: " + resolution + "dpi)")) {
|
if (query_applies("(min-resolution: " + resolution + "dpi)")) {
|
||||||
// It's exact!
|
// It's exact!
|
||||||
|
is(resolution % 96, 0, "resolution should be a multiple of 96dpi");
|
||||||
should_apply("(resolution: " + resolution + "dpi)");
|
should_apply("(resolution: " + resolution + "dpi)");
|
||||||
should_not_apply("(resolution: " + (resolution + 1) + "dpi)");
|
should_not_apply("(resolution: " + (resolution + 1) + "dpi)");
|
||||||
should_not_apply("(resolution: " + (resolution - 1) + "dpi)");
|
should_not_apply("(resolution: " + (resolution - 1) + "dpi)");
|
||||||
|
@ -490,6 +491,7 @@ function run() {
|
||||||
} else {
|
} else {
|
||||||
// We have no way to test resolution applying since it need not be
|
// We have no way to test resolution applying since it need not be
|
||||||
// an integer.
|
// an integer.
|
||||||
|
ok(false, "resolution should be a multiple of 96dpi");
|
||||||
should_not_apply("(resolution: " + resolution + "dpi)");
|
should_not_apply("(resolution: " + resolution + "dpi)");
|
||||||
should_not_apply("(resolution: " + (resolution - 1) + "dpi)");
|
should_not_apply("(resolution: " + (resolution - 1) + "dpi)");
|
||||||
dpi_high = resolution;
|
dpi_high = resolution;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче