From owner-freebsd-ports-bugs@FreeBSD.ORG Thu Mar 24 14:00:02 2011 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7C935106566B for ; Thu, 24 Mar 2011 14:00:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 361B18FC1B for ; Thu, 24 Mar 2011 14:00:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p2OE02lt094369 for ; Thu, 24 Mar 2011 14:00:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p2OE024n094368; Thu, 24 Mar 2011 14:00:02 GMT (envelope-from gnats) Resent-Date: Thu, 24 Mar 2011 14:00:02 GMT Resent-Message-Id: <201103241400.p2OE024n094368@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dominic Fandrey Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7CBF106564A for ; Thu, 24 Mar 2011 13:58:24 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id A714F8FC13 for ; Thu, 24 Mar 2011 13:58:24 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p2ODwOoF015273 for ; Thu, 24 Mar 2011 13:58:24 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p2ODwOOp015272; Thu, 24 Mar 2011 13:58:24 GMT (envelope-from nobody) Message-Id: <201103241358.p2ODwOOp015272@red.freebsd.org> Date: Thu, 24 Mar 2011 13:58:24 GMT From: Dominic Fandrey To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/155913: [patch] www/firefox ignores DPI settings X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2011 14:00:02 -0000 >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: