Bug 1286150 - Part 4: Implement shape distance for polygon.
MozReview-Commit-ID: BONxNhUrQsF
--- 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");
}