Bug 1286150 - Part 4: Implement shape distance for polygon. r=hiro
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 26 Oct 2016 17:32:18 +0800
changeset 347144 3f70a3328993e4f31952b0c306b75de5a5951ab3
parent 347143 acbcd6418399a7c2793778bf54896a6027c22a4c
child 347145 1d839c998bab4f8772b1788d2a74cfb9f92ee02d
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 4: Implement shape distance for polygon. r=hiro MozReview-Commit-ID: BONxNhUrQsF
layout/style/StyleAnimationValue.cpp
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -779,21 +779,27 @@ ComputeShapeDistance(nsCSSPropertyID aPr
       // Only iterate over elements 1 and 3. The <position> is 'uncomputed' to
       // only those elements.  See also the comment in SetPositionValue.
       for (size_t i = 1; i < 4; i += 2) {
         const nsCSSValue& value = func->Item(len - 1).GetArrayValue()->Item(i);
         squareDistance += pixelCalcDistance(ExtractCalcValue(value));
       }
       break;
     }
-    case eCSSKeyword_polygon:
-      // TODO: will be fixed in the later patch.
-      MOZ_ASSERT(false);
+    case eCSSKeyword_polygon: {
+      // Don't care about the first element which is the function keyword, and
+      // the second element which is the fill rule.
+      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);
       break;
 
     default:
       MOZ_ASSERT_UNREACHABLE("Unknown shape type");
   }