Bug 1286150 - Part 5: Implement shape distance for inset. r=hiro
authorBoris Chiou <boris.chiou@gmail.com>
Thu, 27 Oct 2016 15:34:06 +0800
changeset 347145 1d839c998bab4f8772b1788d2a74cfb9f92ee02d
parent 347144 3f70a3328993e4f31952b0c306b75de5a5951ab3
child 347146 2ba49ae5f6dbb59feacbbbf51ef15f56dec68771
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1286150
milestone52.0a1
Bug 1286150 - Part 5: Implement shape distance for inset. r=hiro MozReview-Commit-ID: 4C2uZp9qM3D
layout/style/StyleAnimationValue.cpp
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -790,21 +790,34 @@ ComputeShapeDistance(nsCSSPropertyID aPr
       const nsCSSValuePairList* list = func->Item(2).GetPairListValue();
       do {
         squareDistance += pixelCalcDistance(ExtractCalcValue(list->mXValue)) +
                           pixelCalcDistance(ExtractCalcValue(list->mYValue));
         list = list->mNext;
       } while (list);
       break;
     }
-    case eCSSKeyword_inset:
-      // TODO: will be fixed in the later patch.
-      MOZ_ASSERT(false);
+    case eCSSKeyword_inset: {
+      // Items 1-4 are respectively the top, right, bottom and left offsets
+      // from the reference box.
+      for (size_t i = 1; i <= 4; ++i) {
+        const nsCSSValue& value = func->Item(i);
+        squareDistance += pixelCalcDistance(ExtractCalcValue(value));
+      }
+      // Item 5 contains the radii of the rounded corners for the inset
+      // rectangle.
+      const nsCSSValue::Array* array = func->Item(5).GetArrayValue();
+      const size_t len = array->Count();
+      for (size_t i = 0; i < len; ++i) {
+        const nsCSSValuePair& pair = array->Item(i).GetPairValue();
+        squareDistance += pixelCalcDistance(ExtractCalcValue(pair.mXValue)) +
+                          pixelCalcDistance(ExtractCalcValue(pair.mYValue));
+      }
       break;
-
+    }
     default:
       MOZ_ASSERT_UNREACHABLE("Unknown shape type");
   }
   return sqrt(squareDistance);
 }
 
 static nsCSSValueList*
 AddTransformLists(double aCoeff1, const nsCSSValueList* aList1,