Bug 1286150 - Part 4: Implement shape distance for polygon. draft
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 26 Oct 2016 17:32:18 +0800
changeset 432447 2051f0acf3b94428ead256b58aaadfe4d1fa2054
parent 432446 d5b707d5136b470cd88d581de962bf88e5ab87d3
child 432448 f07174c769032586fb9fc4e3d8139dbf320fa259
push id34315
push userbmo:boris.chiou@gmail.com
push dateWed, 02 Nov 2016 03:24:03 +0000
bugs1286150
milestone52.0a1
Bug 1286150 - Part 4: Implement shape distance for polygon. 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");
   }