Bug 537890. Part 9: Make accessibility's font-size text attribute return 'pt' values calculated as 4/3 of a px, not based on the DPI of the user's monitor. r=surkov
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 13 Aug 2010 21:58:02 +1200
changeset 50406 e6debc61f80dbb496a8ef6cbd369ff9b9db909be
parent 50405 1adbfc30af7c156892c37d83ef557c6c21943c3e
child 50407 ae101cf2e88207ff0eddb3168f1b38dd009f3e32
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs537890
milestone2.0b4pre
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 537890. Part 9: Make accessibility's font-size text attribute return 'pt' values calculated as 4/3 of a px, not based on the DPI of the user's monitor. r=surkov
accessible/src/base/nsTextAttrs.cpp
--- a/accessible/src/base/nsTextAttrs.cpp
+++ b/accessible/src/base/nsTextAttrs.cpp
@@ -460,19 +460,20 @@ nsFontSizeTextAttr::Format(const nscoord
   // Convert from nscoord to pt.
   //
   // Note: according to IA2, "The conversion doesn't have to be exact.
   // The intent is to give the user a feel for the size of the text."
   // 
   // ATK does not specify a unit and will likely follow IA2 here.
   //
   // XXX todo: consider sharing this code with layout module? (bug 474621)
-  float inches = static_cast<float>(aValue) /
-    static_cast<float>(mDC->AppUnitsPerInch());
-  int pts = static_cast<int>(inches * 72 + .5); // 72 pts per inch
+  float px =
+    NSAppUnitsToFloatPixels(aValue, nsIDeviceContext::AppUnitsPerCSSPixel());
+  // Each pt is 4/3 of a CSS pixel.
+  int pts = NS_lround(px*3/4);
 
   nsAutoString value;
   value.AppendInt(pts);
   value.Append(NS_LITERAL_STRING("pt"));
   aFormattedValue = value;
 }
 
 nscoord