Bug 1311244 Part 1 - Use nsPoint type for center in nsCSSClipPathInstance. draft
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 06 Jan 2017 16:35:00 +0800
changeset 459613 830376fb7287af2379f9a7f1b760fb1dbfeee484
parent 459612 d7ec8149dfcbfc9d611e18f45b2165e78e921f8c
child 459614 79a63631fd6f1919cb61ab8eaa9c52b7c8eb0c5b
push id41270
push userbmo:tlin@mozilla.com
push dateThu, 12 Jan 2017 09:51:31 +0000
bugs1311244
milestone53.0a1
Bug 1311244 Part 1 - Use nsPoint type for center in nsCSSClipPathInstance. |center| should be of nsPoint type since all the arguments of ComputeObjectAnchorPoint() uses nsPoint and nsSize. We should only convert center to Point (which is an an UnknownUnits type) for APIs requiring Point type. MozReview-Commit-ID: EDrQGPUZp6m
layout/svg/nsCSSClipPathInstance.cpp
--- a/layout/svg/nsCSSClipPathInstance.cpp
+++ b/layout/svg/nsCSSClipPathInstance.cpp
@@ -128,17 +128,17 @@ nsCSSClipPathInstance::CreateClipPathCir
 
   RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
 
   nsPoint topLeft, anchor;
   nsSize size = nsSize(aRefBox.width, aRefBox.height);
   nsImageRenderer::ComputeObjectAnchorPoint(basicShape->GetPosition(),
                                             size, size,
                                             &topLeft, &anchor);
-  Point center = Point(anchor.x + aRefBox.x, anchor.y + aRefBox.y);
+  nsPoint center(anchor.x + aRefBox.x, anchor.y + aRefBox.y);
 
   const nsTArray<nsStyleCoord>& coords = basicShape->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, vertical;
     EnumerationToLength(horizontal, styleShapeRadius,
@@ -157,17 +157,18 @@ nsCSSClipPathInstance::CreateClipPathCir
       SVGContentUtils::ComputeNormalizedHypotenuse(aRefBox.width,
                                                    aRefBox.height);
     r = nsRuleNode::ComputeCoordPercentCalc(coords[0],
                                             NSToCoordRound(referenceLength));
   }
 
   nscoord appUnitsPerDevPixel =
     mTargetFrame->PresContext()->AppUnitsPerDevPixel();
-  builder->Arc(center / appUnitsPerDevPixel, r / appUnitsPerDevPixel,
+  builder->Arc(Point(center.x, center.y) / appUnitsPerDevPixel,
+               r / appUnitsPerDevPixel,
                0, Float(2 * M_PI));
   builder->Close();
   return builder->Finish();
 }
 
 already_AddRefed<Path>
 nsCSSClipPathInstance::CreateClipPathEllipse(DrawTarget* aDrawTarget,
                                              const nsRect& aRefBox)
@@ -176,17 +177,17 @@ nsCSSClipPathInstance::CreateClipPathEll
 
   RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
 
   nsPoint topLeft, anchor;
   nsSize size = nsSize(aRefBox.width, aRefBox.height);
   nsImageRenderer::ComputeObjectAnchorPoint(basicShape->GetPosition(),
                                             size, size,
                                             &topLeft, &anchor);
-  Point center = Point(anchor.x + aRefBox.x, anchor.y + aRefBox.y);
+  nsPoint center(anchor.x + aRefBox.x, anchor.y + aRefBox.y);
 
   const nsTArray<nsStyleCoord>& coords = basicShape->Coordinates();
   MOZ_ASSERT(coords.Length() == 2, "wrong number of arguments");
   nscoord rx = 0, ry = 0;
   if (coords[0].GetUnit() == eStyleUnit_Enumerated) {
     EnumerationToLength(rx, coords[0].GetEnumValue<StyleShapeRadius>(),
                         center.x, aRefBox.x, aRefBox.x + aRefBox.width);
   } else {
@@ -197,17 +198,17 @@ nsCSSClipPathInstance::CreateClipPathEll
                         center.y, aRefBox.y, aRefBox.y + aRefBox.height);
   } else {
     ry = nsRuleNode::ComputeCoordPercentCalc(coords[1], aRefBox.height);
   }
 
   nscoord appUnitsPerDevPixel =
     mTargetFrame->PresContext()->AppUnitsPerDevPixel();
   EllipseToBezier(builder.get(),
-                  center / appUnitsPerDevPixel,
+                  Point(center.x, center.y) / appUnitsPerDevPixel,
                   Size(rx, ry) / appUnitsPerDevPixel);
   builder->Close();
   return builder->Finish();
 }
 
 already_AddRefed<Path>
 nsCSSClipPathInstance::CreateClipPathPolygon(DrawTarget* aDrawTarget,
                                              const nsRect& aRefBox)