Bug 516547. Remove the browser.display.base_font_scaler preference and all the code to process it. r=bzbarsky, sr=dbaron.

This commit is contained in:
Javi Rueda 2011-07-11 15:27:25 -04:00
parent 247edcfca1
commit 60856304e4
5 changed files with 24 additions and 75 deletions

View File

@ -649,10 +649,6 @@ nsPresContext::GetUserPreferences()
// get a presshell.
return;
}
mFontScaler =
Preferences::GetInt("browser.display.base_font_scaler", mFontScaler);
mAutoQualityMinFontSizePixelsPref =
Preferences::GetInt("browser.display.auto_quality_min_font_size");

View File

@ -394,11 +394,6 @@ public:
return PR_FALSE;
}
/**
* Access Nav's magic font scaler value
*/
PRInt32 FontScaler() const { return mFontScaler; }
/**
* Get the default colors
*/

View File

@ -2506,19 +2506,16 @@ nsRuleNode::SetFontSize(nsPresContext* aPresContext,
const nsCSSValue* sizeValue = aRuleData->ValueForFontSize();
if (eCSSUnit_Enumerated == sizeValue->GetUnit()) {
PRInt32 value = sizeValue->GetIntValue();
PRInt32 scaler = aPresContext->FontScaler();
float scaleFactor = nsStyleUtil::GetScalingFactor(scaler);
zoom = PR_TRUE;
if ((NS_STYLE_FONT_SIZE_XXSMALL <= value) &&
(value <= NS_STYLE_FONT_SIZE_XXLARGE)) {
*aSize = nsStyleUtil::CalcFontPointSize(value, baseSize,
scaleFactor, aPresContext, eFontSize_CSS);
aPresContext, eFontSize_CSS);
}
else if (NS_STYLE_FONT_SIZE_XXXLARGE == value) {
// <font size="7"> is not specified in CSS, so we don't use eFontSize_CSS.
*aSize = nsStyleUtil::CalcFontPointSize(value, baseSize,
scaleFactor, aPresContext);
*aSize = nsStyleUtil::CalcFontPointSize(value, baseSize, aPresContext);
}
else if (NS_STYLE_FONT_SIZE_LARGER == value ||
NS_STYLE_FONT_SIZE_SMALLER == value) {
@ -2534,14 +2531,14 @@ nsRuleNode::SetFontSize(nsPresContext* aPresContext,
if (NS_STYLE_FONT_SIZE_LARGER == value) {
*aSize = nsStyleUtil::FindNextLargerFontSize(parentSize,
baseSize, scaleFactor, aPresContext, eFontSize_CSS);
baseSize, aPresContext, eFontSize_CSS);
NS_ASSERTION(*aSize >= parentSize,
"FindNextLargerFontSize failed");
}
else {
*aSize = nsStyleUtil::FindNextSmallerFontSize(parentSize,
baseSize, scaleFactor, aPresContext, eFontSize_CSS);
baseSize, aPresContext, eFontSize_CSS);
NS_ASSERTION(*aSize < parentSize ||
parentSize <= nsPresContext::CSSPixelsToAppUnits(1),
"FindNextSmallerFontSize failed");

View File

@ -51,49 +51,13 @@
#include "nsTextFormatter.h"
#include "nsCSSProps.h"
#define POSITIVE_SCALE_FACTOR 1.10 /* 10% */
#define NEGATIVE_SCALE_FACTOR .90 /* 10% */
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
/*
* Return the scaling percentage given a font scaler
* Lifted from layutil.c
*/
float nsStyleUtil::GetScalingFactor(PRInt32 aScaler)
{
double scale = 1.0;
double mult;
PRInt32 count;
if(aScaler < 0) {
count = -aScaler;
mult = NEGATIVE_SCALE_FACTOR;
}
else {
count = aScaler;
mult = POSITIVE_SCALE_FACTOR;
}
/* use the percentage scaling factor to the power of the pref */
while(count--) {
scale *= mult;
}
return (float)scale;
}
//------------------------------------------------------------------------------
// Font Algorithm Code
//------------------------------------------------------------------------------
nscoord
nsStyleUtil::CalcFontPointSize(PRInt32 aHTMLSize, PRInt32 aBasePointSize,
float aScalingFactor, nsPresContext* aPresContext,
nsPresContext* aPresContext,
nsFontSizeType aFontSizeType)
{
#define sFontSizeTableMin 9
@ -212,7 +176,6 @@ nsStyleUtil::CalcFontPointSize(PRInt32 aHTMLSize, PRInt32 aBasePointSize,
dFontSize = (factor * aBasePointSize) / 100;
}
dFontSize *= aScalingFactor;
if (1.0 < dFontSize) {
return (nscoord)dFontSize;
@ -226,7 +189,7 @@ nsStyleUtil::CalcFontPointSize(PRInt32 aHTMLSize, PRInt32 aBasePointSize,
//------------------------------------------------------------------------------
nscoord nsStyleUtil::FindNextSmallerFontSize(nscoord aFontSize, PRInt32 aBasePointSize,
float aScalingFactor, nsPresContext* aPresContext,
nsPresContext* aPresContext,
nsFontSizeType aFontSizeType)
{
PRInt32 index;
@ -250,26 +213,26 @@ nscoord nsStyleUtil::FindNextSmallerFontSize(nscoord aFontSize, PRInt32 aBasePoi
indexMax = 6;
}
smallestIndexFontSize = CalcFontPointSize(indexMin, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
largestIndexFontSize = CalcFontPointSize(indexMax, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
smallestIndexFontSize = CalcFontPointSize(indexMin, aBasePointSize, aPresContext, aFontSizeType);
largestIndexFontSize = CalcFontPointSize(indexMax, aBasePointSize, aPresContext, aFontSizeType);
if (aFontSize > smallestIndexFontSize) {
if (aFontSize < NSToCoordRound(float(largestIndexFontSize) * 1.5)) { // smaller will be in HTML table
// find largest index smaller than current
for (index = indexMax; index >= indexMin; index--) {
indexFontSize = CalcFontPointSize(index, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
indexFontSize = CalcFontPointSize(index, aBasePointSize, aPresContext, aFontSizeType);
if (indexFontSize < aFontSize)
break;
}
// set up points beyond table for interpolation purposes
if (indexFontSize == smallestIndexFontSize) {
smallerIndexFontSize = indexFontSize - onePx;
largerIndexFontSize = CalcFontPointSize(index+1, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
largerIndexFontSize = CalcFontPointSize(index+1, aBasePointSize, aPresContext, aFontSizeType);
} else if (indexFontSize == largestIndexFontSize) {
smallerIndexFontSize = CalcFontPointSize(index-1, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
smallerIndexFontSize = CalcFontPointSize(index-1, aBasePointSize, aPresContext, aFontSizeType);
largerIndexFontSize = NSToCoordRound(float(largestIndexFontSize) * 1.5);
} else {
smallerIndexFontSize = CalcFontPointSize(index-1, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
largerIndexFontSize = CalcFontPointSize(index+1, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
smallerIndexFontSize = CalcFontPointSize(index-1, aBasePointSize, aPresContext, aFontSizeType);
largerIndexFontSize = CalcFontPointSize(index+1, aBasePointSize, aPresContext, aFontSizeType);
}
// compute the relative position of the parent size between the two closest indexed sizes
relativePosition = float(aFontSize - indexFontSize) / float(largerIndexFontSize - indexFontSize);
@ -291,7 +254,7 @@ nscoord nsStyleUtil::FindNextSmallerFontSize(nscoord aFontSize, PRInt32 aBasePoi
//------------------------------------------------------------------------------
nscoord nsStyleUtil::FindNextLargerFontSize(nscoord aFontSize, PRInt32 aBasePointSize,
float aScalingFactor, nsPresContext* aPresContext,
nsPresContext* aPresContext,
nsFontSizeType aFontSizeType)
{
PRInt32 index;
@ -316,26 +279,26 @@ nscoord nsStyleUtil::FindNextLargerFontSize(nscoord aFontSize, PRInt32 aBasePoin
indexMax = 6;
}
smallestIndexFontSize = CalcFontPointSize(indexMin, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
largestIndexFontSize = CalcFontPointSize(indexMax, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
smallestIndexFontSize = CalcFontPointSize(indexMin, aBasePointSize, aPresContext, aFontSizeType);
largestIndexFontSize = CalcFontPointSize(indexMax, aBasePointSize, aPresContext, aFontSizeType);
if (aFontSize > (smallestIndexFontSize - onePx)) {
if (aFontSize < largestIndexFontSize) { // larger will be in HTML table
// find smallest index larger than current
for (index = indexMin; index <= indexMax; index++) {
indexFontSize = CalcFontPointSize(index, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
indexFontSize = CalcFontPointSize(index, aBasePointSize, aPresContext, aFontSizeType);
if (indexFontSize > aFontSize)
break;
}
// set up points beyond table for interpolation purposes
if (indexFontSize == smallestIndexFontSize) {
smallerIndexFontSize = indexFontSize - onePx;
largerIndexFontSize = CalcFontPointSize(index+1, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
largerIndexFontSize = CalcFontPointSize(index+1, aBasePointSize, aPresContext, aFontSizeType);
} else if (indexFontSize == largestIndexFontSize) {
smallerIndexFontSize = CalcFontPointSize(index-1, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
smallerIndexFontSize = CalcFontPointSize(index-1, aBasePointSize, aPresContext, aFontSizeType);
largerIndexFontSize = NSCoordSaturatingMultiply(largestIndexFontSize, 1.5);
} else {
smallerIndexFontSize = CalcFontPointSize(index-1, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
largerIndexFontSize = CalcFontPointSize(index+1, aBasePointSize, aScalingFactor, aPresContext, aFontSizeType);
smallerIndexFontSize = CalcFontPointSize(index-1, aBasePointSize, aPresContext, aFontSizeType);
largerIndexFontSize = CalcFontPointSize(index+1, aBasePointSize, aPresContext, aFontSizeType);
}
// compute the relative position of the parent size between the two closest indexed sizes
relativePosition = float(aFontSize - smallerIndexFontSize) / float(indexFontSize - smallerIndexFontSize);

View File

@ -56,18 +56,16 @@ enum nsFontSizeType {
class nsStyleUtil {
public:
static float GetScalingFactor(PRInt32 aScaler);
static nscoord CalcFontPointSize(PRInt32 aHTMLSize, PRInt32 aBasePointSize,
float aScalingFactor, nsPresContext* aPresContext,
nsPresContext* aPresContext,
nsFontSizeType aFontSizeType = eFontSize_HTML);
static nscoord FindNextSmallerFontSize(nscoord aFontSize, PRInt32 aBasePointSize,
float aScalingFactor, nsPresContext* aPresContext,
nsPresContext* aPresContext,
nsFontSizeType aFontSizeType = eFontSize_HTML);
static nscoord FindNextLargerFontSize(nscoord aFontSize, PRInt32 aBasePointSize,
float aScalingFactor, nsPresContext* aPresContext,
nsPresContext* aPresContext,
nsFontSizeType aFontSizeType = eFontSize_HTML);
static PRInt32 ConstrainFontWeight(PRInt32 aWeight);