Bug 804970, patch 1: Don't force calc() units out of the rule tree. r=bzbarsky

This moves the calc() handling above the aCanStoreInRuleTree = false,
which it had no reason to be below.

calc() units are still forced out of the rule tree when there's an em,
ex, or rem unit inside the calc() structure, since aCanStoreInRuleTree
is passed through to the leaf CalcLengthWith calls.
This commit is contained in:
L. David Baron 2012-10-26 19:04:20 +02:00
Родитель 63402fa50e
Коммит 26b86aa5e3
1 изменённых файлов: 12 добавлений и 17 удалений

Просмотреть файл

@ -257,6 +257,18 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
if (aValue.IsPixelLengthUnit()) { if (aValue.IsPixelLengthUnit()) {
return aValue.GetPixelLength(); return aValue.GetPixelLength();
} }
if (aValue.IsCalcUnit()) {
// For properties for which lengths are the *only* units accepted in
// calc(), we can handle calc() here and just compute a final
// result. We ensure that we don't get to this code for other
// properties by not calling CalcLength in those cases: SetCoord
// only calls CalcLength for a calc when it is appropriate to do so.
CalcLengthCalcOps ops(aFontSize, aStyleFont,
aStyleContext, aPresContext,
aUseProvidedRootEmSize, aUseUserFontSet,
aCanStoreInRuleTree);
return css::ComputeCalc(aValue, ops);
}
// Common code for all units other than pixel-based units and fixed-length // Common code for all units other than pixel-based units and fixed-length
// units: // units:
aCanStoreInRuleTree = false; aCanStoreInRuleTree = false;
@ -342,23 +354,6 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
return ScaleCoord(aValue, ceil(aPresContext->AppUnitsPerDevPixel() * return ScaleCoord(aValue, ceil(aPresContext->AppUnitsPerDevPixel() *
zeroWidth)); zeroWidth));
} }
// For properties for which lengths are the *only* units accepted in
// calc(), we can handle calc() here and just compute a final
// result. We ensure that we don't get to this code for other
// properties by not calling CalcLength in those cases: SetCoord
// only calls CalcLength for a calc when it is appropriate to do so.
case eCSSUnit_Calc:
case eCSSUnit_Calc_Plus:
case eCSSUnit_Calc_Minus:
case eCSSUnit_Calc_Times_L:
case eCSSUnit_Calc_Times_R:
case eCSSUnit_Calc_Divided: {
CalcLengthCalcOps ops(aFontSize, aStyleFont,
aStyleContext, aPresContext,
aUseProvidedRootEmSize, aUseUserFontSet,
aCanStoreInRuleTree);
return css::ComputeCalc(aValue, ops);
}
default: default:
NS_NOTREACHED("unexpected unit"); NS_NOTREACHED("unexpected unit");
break; break;