--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -3229,151 +3229,16 @@ nsRuleNode::CalcFontPointSize(int32_t aH
if (1.0 < dFontSize) {
return (nscoord)dFontSize;
}
return (nscoord)1;
}
-
-//------------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------------
-
-/* static */ nscoord
-nsRuleNode::FindNextSmallerFontSize(nscoord aFontSize, int32_t aBasePointSize,
- nsPresContext* aPresContext,
- nsFontSizeType aFontSizeType)
-{
- int32_t index;
- int32_t indexMin;
- int32_t indexMax;
- float relativePosition;
- nscoord smallerSize;
- nscoord indexFontSize = aFontSize; // XXX initialize to quell a spurious gcc3.2 warning
- nscoord smallestIndexFontSize;
- nscoord largestIndexFontSize;
- nscoord smallerIndexFontSize;
- nscoord largerIndexFontSize;
-
- nscoord onePx = nsPresContext::CSSPixelsToAppUnits(1);
-
- if (aFontSizeType == eFontSize_HTML) {
- indexMin = 1;
- indexMax = 7;
- } else {
- indexMin = 0;
- indexMax = 6;
- }
-
- 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, 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, aPresContext, aFontSizeType);
- } else if (indexFontSize == largestIndexFontSize) {
- smallerIndexFontSize = CalcFontPointSize(index-1, aBasePointSize, aPresContext, aFontSizeType);
- largerIndexFontSize = NSToCoordRound(float(largestIndexFontSize) * 1.5);
- } else {
- 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);
- // set the new size to have the same relative position between the next smallest two indexed sizes
- smallerSize = smallerIndexFontSize + NSToCoordRound(relativePosition * (indexFontSize - smallerIndexFontSize));
- }
- else { // larger than HTML table, drop by 33%
- smallerSize = NSToCoordRound(float(aFontSize) / 1.5);
- }
- }
- else { // smaller than HTML table, drop by 1px
- smallerSize = std::max(aFontSize - onePx, onePx);
- }
- return smallerSize;
-}
-
-//------------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------------
-
-/* static */ nscoord
-nsRuleNode::FindNextLargerFontSize(nscoord aFontSize, int32_t aBasePointSize,
- nsPresContext* aPresContext,
- nsFontSizeType aFontSizeType)
-{
- int32_t index;
- int32_t indexMin;
- int32_t indexMax;
- float relativePosition;
- nscoord adjustment;
- nscoord largerSize;
- nscoord indexFontSize = aFontSize; // XXX initialize to quell a spurious gcc3.2 warning
- nscoord smallestIndexFontSize;
- nscoord largestIndexFontSize;
- nscoord smallerIndexFontSize;
- nscoord largerIndexFontSize;
-
- nscoord onePx = nsPresContext::CSSPixelsToAppUnits(1);
-
- if (aFontSizeType == eFontSize_HTML) {
- indexMin = 1;
- indexMax = 7;
- } else {
- indexMin = 0;
- indexMax = 6;
- }
-
- 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, 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, aPresContext, aFontSizeType);
- } else if (indexFontSize == largestIndexFontSize) {
- smallerIndexFontSize = CalcFontPointSize(index-1, aBasePointSize, aPresContext, aFontSizeType);
- largerIndexFontSize = NSCoordSaturatingMultiply(largestIndexFontSize, 1.5);
- } else {
- 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);
- // set the new size to have the same relative position between the next largest two indexed sizes
- adjustment = NSCoordSaturatingNonnegativeMultiply(largerIndexFontSize - indexFontSize, relativePosition);
- largerSize = NSCoordSaturatingAdd(indexFontSize, adjustment);
- }
- else { // larger than HTML table, increase by 50%
- largerSize = NSCoordSaturatingMultiply(aFontSize, 1.5);
- }
- }
- else { // smaller than HTML table, increase by 1px
- largerSize = NSCoordSaturatingAdd(aFontSize, onePx);
- }
- return largerSize;
-}
-
struct SetFontSizeCalcOps : public css::BasicCoordCalcOps,
public css::FloatCoeffsAlreadyNormalizedOps
{
// Declare that we have floats as coefficients so that we unambiguously
// resolve coeff_type (BasicCoordCalcOps and FloatCoeffsAlreadyNormalizedOps
// both have |typedef float coeff_type|).
typedef float coeff_type;
@@ -3472,30 +3337,20 @@ nsRuleNode::SetFontSize(nsPresContext* a
// Note that relative units here use the parent's size unadjusted
// for scriptlevel changes. A scriptlevel change between us and the parent
// is simply ignored.
nscoord parentSize = aParentSize;
if (aParentFont->mAllowZoom) {
parentSize = nsStyleFont::UnZoomText(aPresContext, parentSize);
}
- if (NS_STYLE_FONT_SIZE_LARGER == value) {
- *aSize = FindNextLargerFontSize(parentSize,
- baseSize, aPresContext, eFontSize_CSS);
-
- NS_ASSERTION(*aSize >= parentSize,
- "FindNextLargerFontSize failed");
- }
- else {
- *aSize = FindNextSmallerFontSize(parentSize,
- baseSize, aPresContext, eFontSize_CSS);
- NS_ASSERTION(*aSize < parentSize ||
- parentSize <= nsPresContext::CSSPixelsToAppUnits(1),
- "FindNextSmallerFontSize failed");
- }
+ float factor = (NS_STYLE_FONT_SIZE_LARGER == value) ? 1.2f : (1.0f / 1.2f);
+
+ *aSize = parentSize * factor;
+
} else {
NS_NOTREACHED("unexpected value");
}
}
else if (sizeValue->IsLengthUnit() ||
sizeValue->GetUnit() == eCSSUnit_Percent ||
sizeValue->IsCalcUnit()) {
SetFontSizeCalcOps ops(aParentSize, aParentFont,