From 26b86aa5e3e4208180a151bf9018a2ce54666caf Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Fri, 26 Oct 2012 19:04:20 +0200 Subject: [PATCH] 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. --- layout/style/nsRuleNode.cpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 3fbe864ceba6..446408b05220 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -257,6 +257,18 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue, if (aValue.IsPixelLengthUnit()) { 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 // units: aCanStoreInRuleTree = false; @@ -342,23 +354,6 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue, return ScaleCoord(aValue, ceil(aPresContext->AppUnitsPerDevPixel() * 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: NS_NOTREACHED("unexpected unit"); break;