Bug 1326407 Part 0 - Add assertion to ShapeUtils functions. r=me
authorTing-Yu Lin <tlin@mozilla.com>
Thu, 16 Feb 2017 10:51:47 +0800
changeset 389876 ea8bf524e3c8a7bdb26a329b8effa3ba0d9e822e
parent 389875 36663347138dc227d190bdec9b469821058cf176
child 389877 ecc715f72d6112bd6a57a5b52603c3ca2683a003
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1326407
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1326407 Part 0 - Add assertion to ShapeUtils functions. r=me Address Bug 1326407 comment 11. MozReview-Commit-ID: 8Iy5q3f4yPd
layout/base/ShapeUtils.cpp
--- a/layout/base/ShapeUtils.cpp
+++ b/layout/base/ShapeUtils.cpp
@@ -35,29 +35,36 @@ ShapeUtils::ComputeShapeRadius(const Sty
   }
   return length;
 }
 
 nsPoint
 ShapeUtils::ComputeCircleOrEllipseCenter(StyleBasicShape* const aBasicShape,
                                          const nsRect& aRefBox)
 {
+  MOZ_ASSERT(aBasicShape->GetShapeType() == StyleBasicShapeType::Circle ||
+             aBasicShape->GetShapeType() == StyleBasicShapeType::Ellipse,
+             "The basic shape must be circle() or ellipse!");
+
   nsPoint topLeft, anchor;
   nsSize size(aRefBox.Size());
   nsImageRenderer::ComputeObjectAnchorPoint(aBasicShape->GetPosition(),
                                             size, size,
                                             &topLeft, &anchor);
   return nsPoint(anchor.x + aRefBox.x, anchor.y + aRefBox.y);
 }
 
 nscoord
 ShapeUtils::ComputeCircleRadius(StyleBasicShape* const aBasicShape,
                                 const nsPoint& aCenter,
                                 const nsRect& aRefBox)
 {
+  MOZ_ASSERT(aBasicShape->GetShapeType() == StyleBasicShapeType::Circle,
+             "The basic shape must be circle()!");
+
   const nsTArray<nsStyleCoord>& coords = aBasicShape->Coordinates();
   MOZ_ASSERT(coords.Length() == 1, "wrong number of arguments");
   nscoord r = 0;
   if (coords[0].GetUnit() == eStyleUnit_Enumerated) {
     const auto styleShapeRadius = coords[0].GetEnumValue<StyleShapeRadius>();
     nscoord horizontal =
       ComputeShapeRadius(styleShapeRadius, aCenter.x, aRefBox.x, aRefBox.XMost());
     nscoord vertical =
@@ -77,16 +84,19 @@ ShapeUtils::ComputeCircleRadius(StyleBas
   return r;
 }
 
 nsSize
 ShapeUtils::ComputeEllipseRadii(StyleBasicShape* const aBasicShape,
                                 const nsPoint& aCenter,
                                 const nsRect& aRefBox)
 {
+  MOZ_ASSERT(aBasicShape->GetShapeType() == StyleBasicShapeType::Ellipse,
+             "The basic shape must be ellipse()!");
+
   const nsTArray<nsStyleCoord>& coords = aBasicShape->Coordinates();
   MOZ_ASSERT(coords.Length() == 2, "wrong number of arguments");
   nsSize radii;
 
   if (coords[0].GetUnit() == eStyleUnit_Enumerated) {
     const StyleShapeRadius radiusX = coords[0].GetEnumValue<StyleShapeRadius>();
     radii.width = ComputeShapeRadius(radiusX, aCenter.x, aRefBox.x,
                                      aRefBox.XMost());