Bug 1304886 - Part 6: Make ProcessInterpolateMatrix template. r?boris draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Thu, 03 Nov 2016 09:21:32 +0900
changeset 433036 22b4a4c2a434115c78467f8ed6379dd47279bb69
parent 433035 8e4ec6996524205827e052d3b0b2ac4983b3c2a7
child 433037 9a121154d90715a58032e8aaa33154cf011ad621
push id34461
push userhiikezoe@mozilla-japan.org
push dateThu, 03 Nov 2016 02:12:14 +0000
reviewersboris
bugs1304886
milestone52.0a1
Bug 1304886 - Part 6: Make ProcessInterpolateMatrix template. r?boris To avoid exposing the template ProcessInterpolateMatrix is left because it is used in AddTransformFunctions in nsDisplayList.cpp. MozReview-Commit-ID: D9KW7du5j04
layout/style/nsStyleTransformMatrix.cpp
--- 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!");