--- a/layout/style/nsStyleTransformMatrix.cpp
+++ b/layout/style/nsStyleTransformMatrix.cpp
@@ -376,25 +376,25 @@ OperateTransformMatrix(const Matrix4x4 &
Operator::operateForScale(scale1, scale2, aProgress);
if (scale != Point3D(1.0, 1.0, 1.0)) {
result.PreScale(scale.x, scale.y, scale.z);
}
return result;
}
-/* Helper function to process two matrices that we need to interpolate between */
-void
-ProcessInterpolateMatrix(Matrix4x4& aMatrix,
- const nsCSSValue::Array* aData,
- nsStyleContext* aContext,
- nsPresContext* aPresContext,
- RuleNodeCacheConditions& aConditions,
- TransformReferenceBox& aRefBox,
- bool* aContains3dTransform)
+template <typename Operator>
+static void
+ProcessMatrixOperator(Matrix4x4& aMatrix,
+ const nsCSSValue::Array* aData,
+ nsStyleContext* aContext,
+ nsPresContext* aPresContext,
+ RuleNodeCacheConditions& aConditions,
+ TransformReferenceBox& aRefBox,
+ bool* aContains3dTransform)
{
NS_PRECONDITION(aData->Count() == 4, "Invalid array!");
Matrix4x4 matrix1, matrix2;
if (aData->Item(1).GetUnit() == eCSSUnit_List) {
matrix1 = nsStyleTransformMatrix::ReadTransforms(aData->Item(1).GetListValue(),
aContext, aPresContext,
aConditions,
@@ -406,17 +406,32 @@ ProcessInterpolateMatrix(Matrix4x4& aMat
aContext, aPresContext,
aConditions,
aRefBox, nsPresContext::AppUnitsPerCSSPixel(),
aContains3dTransform);
}
double progress = aData->Item(3).GetPercentValue();
aMatrix =
- OperateTransformMatrix<Interpolate>(matrix1, matrix2, progress) * aMatrix;
+ OperateTransformMatrix<Operator>(matrix1, matrix2, progress) * aMatrix;
+}
+
+/* Helper function to process two matrices that we need to interpolate between */
+void
+ProcessInterpolateMatrix(Matrix4x4& aMatrix,
+ const nsCSSValue::Array* aData,
+ nsStyleContext* aContext,
+ nsPresContext* aPresContext,
+ RuleNodeCacheConditions& aConditions,
+ TransformReferenceBox& aRefBox,
+ bool* aContains3dTransform)
+{
+ ProcessMatrixOperator<Interpolate>(aMatrix, aData, aContext, aPresContext,
+ aConditions, aRefBox,
+ aContains3dTransform);
}
/* Helper function to process a translatex function. */
static void
ProcessTranslateX(Matrix4x4& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
@@ -772,19 +787,19 @@ MatrixForTransformFunction(Matrix4x4& aM
aConditions, aRefBox);
break;
case eCSSKeyword_matrix3d:
*aContains3dTransform = true;
ProcessMatrix3D(aMatrix, aData, aContext, aPresContext,
aConditions, aRefBox);
break;
case eCSSKeyword_interpolatematrix:
- ProcessInterpolateMatrix(aMatrix, aData, aContext, aPresContext,
- aConditions, aRefBox,
- aContains3dTransform);
+ ProcessMatrixOperator<Interpolate>(aMatrix, aData, aContext, aPresContext,
+ aConditions, aRefBox,
+ aContains3dTransform);
break;
case eCSSKeyword_perspective:
*aContains3dTransform = true;
ProcessPerspective(aMatrix, aData, aContext, aPresContext,
aConditions);
break;
default:
NS_NOTREACHED("Unknown transform function!");