Bug 573953. Ensure that zoom factors are chosen in reftests so appunits-per-dev-pixel is an integer. r=dbaron
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 16 Jul 2010 09:04:16 +1200
changeset 47722 558b2df6a462e6c8d71f9149daf09f8a8d5ea3df
parent 47721 92339b84d089b8d91ddf9fd1b5d1ec717c6bf918
child 47723 4d1dc2ea47fd2daa17ef072acb829c8c5bdd56cb
push id14413
push userrocallahan@mozilla.com
push dateThu, 15 Jul 2010 21:12:02 +0000
treeherderautoland@e1d7fd5255fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs573953
milestone2.0b2pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 573953. Ensure that zoom factors are chosen in reftests so appunits-per-dev-pixel is an integer. r=dbaron
gfx/src/thebes/nsThebesDeviceContext.cpp
layout/reftests/bugs/446100-1a.html
layout/reftests/bugs/446100-1c.html
layout/reftests/bugs/446100-1f.html
layout/reftests/image-rect/background-zoom-1-ref.html
layout/reftests/image-rect/background-zoom-1.html
layout/reftests/image-rect/background-zoom-2-ref.html
layout/reftests/image-rect/background-zoom-2.html
layout/reftests/image-rect/background-zoom-3-ref.html
layout/reftests/image-rect/background-zoom-3.html
layout/reftests/image-rect/background-zoom-4-ref.html
layout/reftests/image-rect/background-zoom-4.html
layout/tools/reftest/README.txt
--- a/gfx/src/thebes/nsThebesDeviceContext.cpp
+++ b/gfx/src/thebes/nsThebesDeviceContext.cpp
@@ -1219,17 +1219,18 @@ nsThebesDeviceContext::SetPixelScale(flo
     mPixelScale = aScale;
     UpdateScaledAppUnits();
     return oldAppUnitsPerDevPixel != mAppUnitsPerDevPixel;
 }
 
 void
 nsThebesDeviceContext::UpdateScaledAppUnits()
 {
-    mAppUnitsPerDevPixel = PR_MAX(1, PRInt32(float(mAppUnitsPerDevNotScaledPixel) / mPixelScale));
+    mAppUnitsPerDevPixel =
+        PR_MAX(1, NSToIntRound(float(mAppUnitsPerDevNotScaledPixel) / mPixelScale));
 }
 
 #if defined(XP_WIN) || defined(XP_OS2)
 HDC
 nsThebesDeviceContext::GetPrintHDC()
 {
     if (mPrintingSurface) {
         switch (mPrintingSurface->GetType()) {
--- a/layout/reftests/bugs/446100-1a.html
+++ b/layout/reftests/bugs/446100-1a.html
@@ -1,10 +1,10 @@
 <!DOCTYPE HTML>
-<html reftest-zoom="1.1">
+<html reftest-zoom="1.2">
 <head>
 <style>
 div { margin:1em; }
 /* A 7x7px image, black with a 5x5 transparent box centered in it */
 div.box { background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAFklEQVQImWNgYGD4jwdDCCxgQCWxYgBX8hfpeym4dwAAAABJRU5ErkJggg==); }
 /* A 7x5px image, black with a 5x5 transparent box centered in it */
 div.vstrip { background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAFCAYAAACJmvbYAAAAFElEQVQImWNgYGD4z4Ad/GcYAEkAw+kJ94z5rSYAAAAASUVORK5CYII=); }
 /* A 5x7px image, black with a 5x5 transparent box centered in it */
--- a/layout/reftests/bugs/446100-1c.html
+++ b/layout/reftests/bugs/446100-1c.html
@@ -1,10 +1,10 @@
 <!DOCTYPE HTML>
-<html reftest-zoom="1.7">
+<html reftest-zoom="1.8">
 <head>
 <style>
 div { margin:1em; }
 /* A 7x7px image, black with a 5x5 transparent box centered in it */
 div.box { background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAFklEQVQImWNgYGD4jwdDCCxgQCWxYgBX8hfpeym4dwAAAABJRU5ErkJggg==); }
 /* A 7x5px image, black with a 5x5 transparent box centered in it */
 div.vstrip { background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAFCAYAAACJmvbYAAAAFElEQVQImWNgYGD4z4Ad/GcYAEkAw+kJ94z5rSYAAAAASUVORK5CYII=); }
 /* A 5x7px image, black with a 5x5 transparent box centered in it */
--- a/layout/reftests/bugs/446100-1f.html
+++ b/layout/reftests/bugs/446100-1f.html
@@ -1,10 +1,10 @@
 <!DOCTYPE HTML>
-<html reftest-zoom="0.67">
+<html reftest-zoom="0.6666666">
 <head>
 <style>
 div { margin:1em; }
 /* A 7x7px image, black with a 5x5 transparent box centered in it */
 div.box { background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAFklEQVQImWNgYGD4jwdDCCxgQCWxYgBX8hfpeym4dwAAAABJRU5ErkJggg==); }
 /* A 7x5px image, black with a 5x5 transparent box centered in it */
 div.vstrip { background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAFCAYAAACJmvbYAAAAFElEQVQImWNgYGD4z4Ad/GcYAEkAw+kJ94z5rSYAAAAASUVORK5CYII=); }
 /* A 5x7px image, black with a 5x5 transparent box centered in it */
--- a/layout/reftests/image-rect/background-zoom-1-ref.html
+++ b/layout/reftests/image-rect/background-zoom-1-ref.html
@@ -5,17 +5,17 @@
 
     Checks if the full zoom (x1.3) on -moz-image-rect() produces the same
     result as the same full zoom on the CSS sprites produced by hacking
     background-position.
 
     This file is identical to background-common-usage-pixel.html except the
     zoom factor.
 -->
-<html reftest-zoom="1.3">
+<html reftest-zoom="1.304348">
   <head>
     <title>Testcases: -moz-image-rect() [bug 113577]</title>
     <style>
       div.wrapper {
         width: 32px;
         height: 32px;
         margin: 10px;
         background-color: red;
--- a/layout/reftests/image-rect/background-zoom-1.html
+++ b/layout/reftests/image-rect/background-zoom-1.html
@@ -5,17 +5,17 @@
 
     Checks if the full zoom (x1.3) on -moz-image-rect() produces the same
     result as the same full zoom on the CSS sprites produced by hacking
     background-position.
 
     This file is identical to background-common-usage-pixel.html except the
     zoom factor.
 -->
-<html reftest-zoom="1.3">
+<html reftest-zoom="1.304348">
   <head>
     <title>Testcases: -moz-image-rect() [bug 113577]</title>
     <style>
       div.wrapper {
         width: 32px;
         height: 32px;
         margin: 10px;
         background-color: red;
--- a/layout/reftests/image-rect/background-zoom-2-ref.html
+++ b/layout/reftests/image-rect/background-zoom-2-ref.html
@@ -5,17 +5,17 @@
 
     Checks if the full zoom (x1.3) on -moz-image-rect() produces the same
     result as the same full zoom on the CSS sprites produced by hacking
     background-position.
 
     This file is identical to background-common-usage-pixel.html except the
     zoom factor.
 -->
-<html reftest-zoom="1.3">
+<html reftest-zoom="1.304348">
   <head>
     <title>Testcases: -moz-image-rect() [bug 113577]</title>
     <style>
       div.wrapper {
         width: 32px;
         height: 32px;
         margin: 10px;
         background-color: red;
--- a/layout/reftests/image-rect/background-zoom-2.html
+++ b/layout/reftests/image-rect/background-zoom-2.html
@@ -5,17 +5,17 @@
 
     Checks if the full zoom (x1.3) on -moz-image-rect() produces the same
     result as the same full zoom on the CSS sprites produced by hacking
     background-position.
 
     This file is identical to background-common-usage-pixel.html except the
     zoom factor.
 -->
-<html reftest-zoom="1.3">
+<html reftest-zoom="1.304348">
   <head>
     <title>Testcases: -moz-image-rect() [bug 113577]</title>
     <style>
       div.wrapper {
         width: 32px;
         height: 32px;
         margin: 10px;
         background-color: red;
--- a/layout/reftests/image-rect/background-zoom-3-ref.html
+++ b/layout/reftests/image-rect/background-zoom-3-ref.html
@@ -5,17 +5,17 @@
 
     Checks if the full zoom (x1.3) on -moz-image-rect() produces the same
     result as the same full zoom on the CSS sprites produced by hacking
     background-position.
 
     This file is identical to background-common-usage-pixel.html except the
     zoom factor.
 -->
-<html reftest-zoom="1.3">
+<html reftest-zoom="1.304348">
   <head>
     <title>Testcases: -moz-image-rect() [bug 113577]</title>
     <style>
       div.wrapper {
         width: 32px;
         height: 32px;
         margin: 10px;
         background-color: red;
--- a/layout/reftests/image-rect/background-zoom-3.html
+++ b/layout/reftests/image-rect/background-zoom-3.html
@@ -5,17 +5,17 @@
 
     Checks if the full zoom (x1.3) on -moz-image-rect() produces the same
     result as the same full zoom on the CSS sprites produced by hacking
     background-position.
 
     This file is identical to background-common-usage-pixel.html except the
     zoom factor.
 -->
-<html reftest-zoom="1.3">
+<html reftest-zoom="1.304348">
   <head>
     <title>Testcases: -moz-image-rect() [bug 113577]</title>
     <style>
       div.wrapper {
         width: 32px;
         height: 32px;
         margin: 10px;
         background-color: red;
--- a/layout/reftests/image-rect/background-zoom-4-ref.html
+++ b/layout/reftests/image-rect/background-zoom-4-ref.html
@@ -5,17 +5,17 @@
 
     Checks if the full zoom (x1.3) on -moz-image-rect() produces the same
     result as the same full zoom on the CSS sprites produced by hacking
     background-position.
 
     This file is identical to background-common-usage-pixel.html except the
     zoom factor.
 -->
-<html reftest-zoom="1.3">
+<html reftest-zoom="1.304348">
   <head>
     <title>Testcases: -moz-image-rect() [bug 113577]</title>
     <style>
       div.wrapper {
         width: 32px;
         height: 32px;
         margin: 10px;
         background-color: red;
--- a/layout/reftests/image-rect/background-zoom-4.html
+++ b/layout/reftests/image-rect/background-zoom-4.html
@@ -5,17 +5,17 @@
 
     Checks if the full zoom (x1.3) on -moz-image-rect() produces the same
     result as the same full zoom on the CSS sprites produced by hacking
     background-position.
 
     This file is identical to background-common-usage-pixel.html except the
     zoom factor.
 -->
-<html reftest-zoom="1.3">
+<html reftest-zoom="1.304348">
   <head>
     <title>Testcases: -moz-image-rect() [bug 113577]</title>
     <style>
       div.wrapper {
         width: 32px;
         height: 32px;
         margin: 10px;
         background-color: red;
--- a/layout/tools/reftest/README.txt
+++ b/layout/tools/reftest/README.txt
@@ -346,16 +346,27 @@ make changes that should test invalidati
 document and window so you can set listeners there too. For example,
 
 function doTest() {
   document.body.style.border = "";
   document.documentElement.removeAttribute('class');
 }
 document.addEventListener("MozReftestInvalidate", doTest, false);
 
+Zoom Tests
+==========
+
+When the root element of a test has a "reftest-zoom" attribute, that zoom
+factor is applied when rendering the test. The reftest document will be
+800 device pixels wide by 1000 device pixels high. The reftest harness assumes
+that the CSS pixel dimensions are 800/zoom and 1000/zoom. For best results
+therefore, choose zoom factors that do not require rounding when we calculate
+the number of appunits per device pixel; i.e. the zoom factor should divide 60,
+so 60/zoom is an integer.
+
 Printing Tests
 ==============
 Now that the patch for bug 374050 has landed
 (https://bugzilla.mozilla.org/show_bug.cgi?id=374050), it is possible to
 create reftests that run in a paginated context.
 
 The page size used is 5in wide and 3in tall (with the default half-inch
 margins).  This is to allow tests to have less text and to make the