Bug 1311244 Part 1 - Use nsPoint type for center in nsCSSClipPathInstance. r=dbaron
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 06 Jan 2017 16:35:00 +0800
changeset 374258 8b36e6de0c4a9cb12adef70587ad40722033dd26
parent 374257 50a921a0b78d908d64dd8a8ef96b9087702eea0f
child 374259 ccdb3279cca91fd01729f612a34e688bcdfb8108
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1311244
milestone53.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 1311244 Part 1 - Use nsPoint type for center in nsCSSClipPathInstance. r=dbaron |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)