Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Mar 2011 13:58:24 GMT
From:      Dominic Fandrey <kamikaze@bsdforen.de>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/155913: [patch] www/firefox ignores DPI settings
Message-ID:  <201103241358.p2ODwOOp015272@red.freebsd.org>
Resent-Message-ID: <201103241400.p2OE024n094368@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         155913
>Category:       ports
>Synopsis:       [patch] www/firefox ignores DPI settings
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 24 14:00:01 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Dominic Fandrey
>Release:        RELENG_8
>Organization:
private
>Environment:
FreeBSD mobileKamikaze.norad 8.2-STABLE FreeBSD 8.2-STABLE #0: Sun Mar 20 04:15:47 CET 2011     root@mobileKamikaze.norad:/usr/obj/HP6510b-8/amd64/usr/src/sys/HP6510b-8  amd64

>Description:
Firefox4 ignores system DPI and the DPI settings in layout.css.dpi.

The following patch can be dropped into www/firefox/files/ as is. I have submitted to bugzilla.mozilla.org (https://bugzilla.mozilla.org/show_bug.cgi?id=603880). However I doubt it will be accepted anytime soon (the original bug reports is months old and does not even have confirmed status).

This is why I want to suggest adding the patches to the FreeBSD ports tree, the following explanation is taken from my submission to mozilla.
>How-To-Repeat:
Check:
http://www.home.hs-karlsruhe.de/~fado0001/testdpi.html

Change your system DPI settings or play with the layout.css.dpi setting. You will notice, none of these things have an effect.
>Fix:
gfx/src/thebes/nsThebesDeviceContext.cpp
Issue:
- The PR_MAX macro is used in an unsafe fashion, with function calls as
  parameters. Every function in the call is thus called twice, leading
  to several variables being set to 0 (at least when compiled under
  FreeBSD)
Fix:
- Only forward variables to the PR_MAX macro

layout/style/nsCSSValue.h
layout/style/nsCSSValue.cpp
layout/mathml/nsMathMLFrame.cpp
layout/style/nsRuleNode.cpp
Issue:
- The GetPixelLength() function is hard-coded to 96 DPI
Fix:
layout/style/nsCSSValue.h
- Change signature of GetPixelLength() to take an nsPresContext argument
layout/style/nsCSSValue.cpp
- Use AppUnitsPerPhysicalInch() / AppUnitsPerDevPixel() from the
  context to determine the real DPI as determined by thebes
layout/mathml/nsMathMLFrame.cpp
layout/style/nsRuleNode.cpp
- Update all calls of GetPixelLength() to the new signature


Patch attached with submission follows:

diff -Nur mozilla-2.0.orig/gfx/src/thebes/nsThebesDeviceContext.cpp gfx/src/thebes/nsThebesDeviceContext.cpp
--- mozilla-2.0.orig/gfx/src/thebes/nsThebesDeviceContext.cpp	2011-03-24 01:34:08.000000000 +0100
+++ gfx/src/thebes/nsThebesDeviceContext.cpp	2011-03-24 01:43:31.000000000 +0100
@@ -678,7 +678,8 @@
         }
 
         mAppUnitsPerDevNotScaledPixel =
-            PR_MAX(1, NS_lround(AppUnitsPerCSSPixel() / devPixelsPerCSSPixel));
+            NS_lround(AppUnitsPerCSSPixel() / devPixelsPerCSSPixel);
+        mAppUnitsPerDevNotScaledPixel = PR_MAX(1, mAppUnitsPerDevNotScaledPixel);
     }
 
     NS_ASSERTION(dpi != -1.0, "no dpi set");
@@ -1210,7 +1211,8 @@
 nsThebesDeviceContext::UpdateScaledAppUnits()
 {
     mAppUnitsPerDevPixel =
-        PR_MAX(1, NSToIntRound(float(mAppUnitsPerDevNotScaledPixel) / mPixelScale));
+        NSToIntRound(float(mAppUnitsPerDevNotScaledPixel) / mPixelScale);
+    mAppUnitsPerDevPixel = PR_MAX(1, mAppUnitsPerDevPixel);
 }
 
 #if defined(XP_WIN) || defined(XP_OS2)
diff -Nur mozilla-2.0.orig/layout/mathml/nsMathMLFrame.cpp layout/mathml/nsMathMLFrame.cpp
--- mozilla-2.0.orig/layout/mathml/nsMathMLFrame.cpp	2011-03-24 01:34:08.000000000 +0100
+++ layout/mathml/nsMathMLFrame.cpp	2011-03-24 01:36:32.000000000 +0100
@@ -351,7 +351,7 @@
     return aCSSValue.GetFixedLength(aPresContext);
   }
   if (aCSSValue.IsPixelLengthUnit()) {
-    return aCSSValue.GetPixelLength();
+    return aCSSValue.GetPixelLength(aPresContext);
   }
 
   nsCSSUnit unit = aCSSValue.GetUnit();
diff -Nur mozilla-2.0.orig/layout/style/nsCSSValue.cpp layout/style/nsCSSValue.cpp
--- mozilla-2.0.orig/layout/style/nsCSSValue.cpp	2011-03-24 01:34:08.000000000 +0100
+++ layout/style/nsCSSValue.cpp	2011-03-24 01:41:12.000000000 +0100
@@ -277,18 +277,19 @@
   return inches * aPresContext->DeviceContext()->AppUnitsPerPhysicalInch();
 }
 
-nscoord nsCSSValue::GetPixelLength() const
+nscoord nsCSSValue::GetPixelLength(nsPresContext* aPresContext) const
 {
   NS_ABORT_IF_FALSE(IsPixelLengthUnit(), "not a fixed length unit");
 
-  double scaleFactor;
+  double scaleFactor = aPresContext->DeviceContext()->AppUnitsPerPhysicalInch()
+	/ aPresContext->DeviceContext()->AppUnitsPerDevPixel();
   switch (mUnit) {
   case eCSSUnit_Pixel: return nsPresContext::CSSPixelsToAppUnits(mValue.mFloat);
-  case eCSSUnit_Pica: scaleFactor = 16.0; break;
-  case eCSSUnit_Point: scaleFactor = 4/3.0; break;
-  case eCSSUnit_Inch: scaleFactor = 96.0; break;
-  case eCSSUnit_Millimeter: scaleFactor = 96/25.4; break;
-  case eCSSUnit_Centimeter: scaleFactor = 96/2.54; break;
+  case eCSSUnit_Pica: scaleFactor /= 6.0; break;
+  case eCSSUnit_Point: scaleFactor /= 72.0; break;
+  case eCSSUnit_Inch: break;
+  case eCSSUnit_Millimeter: scaleFactor /= 25.4; break;
+  case eCSSUnit_Centimeter: scaleFactor /= 2.54; break;
   default:
     NS_ERROR("should never get here");
     return 0;
diff -Nur mozilla-2.0.orig/layout/style/nsCSSValue.h layout/style/nsCSSValue.h
--- mozilla-2.0.orig/layout/style/nsCSSValue.h	2011-03-24 01:34:08.000000000 +0100
+++ layout/style/nsCSSValue.h	2011-03-24 01:33:24.000000000 +0100
@@ -391,7 +391,7 @@
   imgIRequest* GetImageValue() const;
 
   nscoord GetFixedLength(nsPresContext* aPresContext) const;
-  nscoord GetPixelLength() const;
+  nscoord GetPixelLength(nsPresContext* aPresContext) const;
 
   void Reset()  // sets to null
   {
diff -Nur mozilla-2.0.orig/layout/style/nsRuleNode.cpp layout/style/nsRuleNode.cpp
--- mozilla-2.0.orig/layout/style/nsRuleNode.cpp	2011-03-24 01:34:08.000000000 +0100
+++ layout/style/nsRuleNode.cpp	2011-03-24 01:37:05.000000000 +0100
@@ -242,7 +242,7 @@
     return aValue.GetFixedLength(aPresContext);
   }
   if (aValue.IsPixelLengthUnit()) {
-    return aValue.GetPixelLength();
+    return aValue.GetPixelLength(aPresContext);
   }
   // Common code for all units other than pixel-based units and fixed-length
   // units:


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103241358.p2ODwOOp015272>