author | Nathan Froyd <froydnj@mozilla.com> |
Tue, 06 Mar 2012 13:47:13 -0500 | |
changeset 100570 | 363045309cb0001d1819dd73dab5be69788968c9 |
parent 100569 | b571e6fddb8fd7abf4b0bdd2cddc93880ab12dab |
child 100571 | 873bd2f652b7f14a8b726148fcae0ca53e0d5a66 |
push id | 23185 |
push user | mbrubeck@mozilla.com |
push date | Thu, 26 Jul 2012 20:58:28 +0000 |
treeherder | mozilla-central@8a7ad0adcccf [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bz |
bugs | 719173 |
milestone | 17.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/layout/style/nsStyleTransformMatrix.cpp +++ b/layout/style/nsStyleTransformMatrix.cpp @@ -34,58 +34,50 @@ namespace nsStyleTransformMatrix { static double FlushToZero(double aVal) { if (-FLT_EPSILON < aVal && aVal < FLT_EPSILON) return 0.0f; else return aVal; } -/* Helper function to fill in an nscoord with the specified nsCSSValue. */ -static nscoord CalcLength(const nsCSSValue &aValue, - nsStyleContext* aContext, - nsPresContext* aPresContext, - bool &aCanStoreInRuleTree) -{ - if (aValue.GetUnit() == eCSSUnit_Pixel || - aValue.GetUnit() == eCSSUnit_Number) { - // Handle this here (even though nsRuleNode::CalcLength handles it - // fine) so that callers are allowed to pass a null style context - // and pres context to SetToTransformFunction if they know (as - // nsStyleAnimation does) that all lengths within the transform - // function have already been computed to pixels and percents. - // - // Raw numbers are treated as being pixels. - return nsPresContext::CSSPixelsToAppUnits(aValue.GetFloatValue()); - } - return nsRuleNode::CalcLength(aValue, aContext, aPresContext, - aCanStoreInRuleTree); -} - static float ProcessTranslatePart(const nsCSSValue& aValue, nsStyleContext* aContext, nsPresContext* aPresContext, bool& aCanStoreInRuleTree, nscoord aSize, float aAppUnitsPerMatrixUnit) { nscoord offset = 0; float percent = 0.0f; if (aValue.GetUnit() == eCSSUnit_Percent) { percent = aValue.GetPercentValue(); + } else if (aValue.GetUnit() == eCSSUnit_Pixel || + aValue.GetUnit() == eCSSUnit_Number) { + // Handle this here (even though nsRuleNode::CalcLength handles it + // fine) so that callers are allowed to pass a null style context + // and pres context to SetToTransformFunction if they know (as + // nsStyleAnimation does) that all lengths within the transform + // function have already been computed to pixels and percents. + // + // Raw numbers are treated as being pixels. + // + // Don't convert to aValue to AppUnits here to avoid precision issues. + return aValue.GetFloatValue() * + (float(nsPresContext::AppUnitsPerCSSPixel()) / aAppUnitsPerMatrixUnit); } else if (aValue.IsCalcUnit()) { nsRuleNode::ComputedCalc result = nsRuleNode::SpecifiedCalcToComputedCalc(aValue, aContext, aPresContext, aCanStoreInRuleTree); percent = result.mPercent; offset = result.mLength; } else { - offset = CalcLength(aValue, aContext, aPresContext, - aCanStoreInRuleTree); + offset = nsRuleNode::CalcLength(aValue, aContext, aPresContext, + aCanStoreInRuleTree); } return (percent * NSAppUnitsToFloatPixels(aSize, aAppUnitsPerMatrixUnit)) + NSAppUnitsToFloatPixels(offset, aAppUnitsPerMatrixUnit); } /** * Helper functions to process all the transformation function types.