Bug 1144951. Warn if the result of ConvertAppUnits is unused. r=mats
authorTimothy Nikkel <tnikkel@gmail.com>
Thu, 26 Mar 2015 16:44:38 -0500
changeset 264888 a1f0b23f51049f8abe0faef128c60e52962d9426
parent 264887 1652874e2d978dab14dd56b39342ccb93ddee650
child 264889 b617b76326f7b7000703e8625d49543662846ca9
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1144951
milestone39.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 1144951. Warn if the result of ConvertAppUnits is unused. r=mats There is never a case where Ignoring the result makes sense.
gfx/src/nsPoint.h
gfx/src/nsRect.h
gfx/src/nsRegion.h
gfx/src/nsSize.h
--- a/gfx/src/nsPoint.h
+++ b/gfx/src/nsPoint.h
@@ -21,18 +21,23 @@ struct nsPoint : public mozilla::gfx::Ba
   nsPoint() : Super() {}
   nsPoint(const nsPoint& aPoint) : Super(aPoint) {}
   nsPoint(nscoord aX, nscoord aY) : Super(aX, aY) {}
 
   inline nsIntPoint ScaleToNearestPixels(float aXScale, float aYScale,
                                          nscoord aAppUnitsPerPixel) const;
   inline nsIntPoint ToNearestPixels(nscoord aAppUnitsPerPixel) const;
 
-  // Converts this point from aFromAPP, an appunits per pixel ratio, to aToAPP.
-  inline nsPoint ConvertAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
+  /**
+   * Return this point scaled to a different appunits per pixel (APP) ratio.
+   * @param aFromAPP the APP to scale from
+   * @param aToAPP the APP to scale to
+   */
+  MOZ_WARN_UNUSED_RESULT inline nsPoint
+    ConvertAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
 };
 
 // nsIntPoint represents a point in one of the types of pixels.
 // Uses of nsIntPoint should eventually be converted to CSSIntPoint,
 // LayoutDeviceIntPoint, etc. (see layout/base/Units.h).
 
 struct nsIntPoint : public mozilla::gfx::BasePoint<int32_t, nsIntPoint> {
   typedef mozilla::gfx::BasePoint<int32_t, nsIntPoint> Super;
--- a/gfx/src/nsRect.h
+++ b/gfx/src/nsRect.h
@@ -129,23 +129,29 @@ struct NS_GFX nsRect :
   {
     *this = aRect1.SaturatingUnion(aRect2);
   }
   void SaturatingUnionRectEdges(const nsRect& aRect1, const nsRect& aRect2)
   {
     *this = aRect1.SaturatingUnionEdges(aRect2);
   }
 
-  // Converts this rect from aFromAPP, an appunits per pixel ratio, to aToAPP.
-  // In the RoundOut version we make the rect the smallest rect containing the
-  // unrounded result. In the RoundIn version we make the rect the largest rect
-  // contained in the unrounded result.
-  // Note: this can turn an empty rectangle into a non-empty rectangle
-  inline nsRect ConvertAppUnitsRoundOut(int32_t aFromAPP, int32_t aToAPP) const;
-  inline nsRect ConvertAppUnitsRoundIn(int32_t aFromAPP, int32_t aToAPP) const;
+  /**
+   * Return this rect scaled to a different appunits per pixel (APP) ratio.
+   * In the RoundOut version we make the rect the smallest rect containing the
+   * unrounded result. In the RoundIn version we make the rect the largest rect
+   * contained in the unrounded result.
+   * @param aFromAPP the APP to scale from
+   * @param aToAPP the APP to scale to
+   * @note this can turn an empty rectangle into a non-empty rectangle
+   */
+  MOZ_WARN_UNUSED_RESULT inline nsRect
+    ConvertAppUnitsRoundOut(int32_t aFromAPP, int32_t aToAPP) const;
+  MOZ_WARN_UNUSED_RESULT inline nsRect
+    ConvertAppUnitsRoundIn(int32_t aFromAPP, int32_t aToAPP) const;
 
   inline nsIntRect ScaleToNearestPixels(float aXScale, float aYScale,
                                         nscoord aAppUnitsPerPixel) const;
   inline nsIntRect ToNearestPixels(nscoord aAppUnitsPerPixel) const;
   // Note: this can turn an empty rectangle into a non-empty rectangle
   inline nsIntRect ScaleToOutsidePixels(float aXScale, float aYScale,
                                         nscoord aAppUnitsPerPixel) const;
   // Note: this can turn an empty rectangle into a non-empty rectangle
--- a/gfx/src/nsRegion.h
+++ b/gfx/src/nsRegion.h
@@ -280,21 +280,28 @@ public:
   {
     // Work around pixman bug. Sometimes pixman creates regions with 1 rect
     // that's empty.
     uint32_t result = pixman_region32_n_rects(Impl());
     return (result == 1 && GetBounds().IsEmpty()) ? 0 : result;
   }
   const nsRect GetBounds () const { return BoxToRect(mImpl.extents); }
   uint64_t Area () const;
-  // Converts this region from aFromAPP, an appunits per pixel ratio, to
-  // aToAPP. This applies nsRect::ConvertAppUnitsRoundOut/In to each rect of
-  // the region.
-  nsRegion ConvertAppUnitsRoundOut (int32_t aFromAPP, int32_t aToAPP) const;
-  nsRegion ConvertAppUnitsRoundIn (int32_t aFromAPP, int32_t aToAPP) const;
+
+  /**
+   * Return this region scaled to a different appunits per pixel (APP) ratio.
+   * This applies nsRect::ConvertAppUnitsRoundOut/In to each rect of the region.
+   * @param aFromAPP the APP to scale from
+   * @param aToAPP the APP to scale to
+   * @note this can turn an empty region into a non-empty region
+   */
+  MOZ_WARN_UNUSED_RESULT nsRegion
+    ConvertAppUnitsRoundOut (int32_t aFromAPP, int32_t aToAPP) const;
+  MOZ_WARN_UNUSED_RESULT nsRegion
+    ConvertAppUnitsRoundIn (int32_t aFromAPP, int32_t aToAPP) const;
   nsRegion& ScaleRoundOut(float aXScale, float aYScale);
   nsRegion& ScaleInverseRoundOut(float aXScale, float aYScale);
   nsRegion& Transform (const gfx3DMatrix &aTransform);
   nsIntRegion ScaleToOutsidePixels (float aXScale, float aYScale, nscoord aAppUnitsPerPixel) const;
   nsIntRegion ScaleToInsidePixels (float aXScale, float aYScale, nscoord aAppUnitsPerPixel) const;
   nsIntRegion ScaleToNearestPixels (float aXScale, float aYScale, nscoord aAppUnitsPerPixel) const;
   nsIntRegion ToOutsidePixels (nscoord aAppUnitsPerPixel) const;
   nsIntRegion ToNearestPixels (nscoord aAppUnitsPerPixel) const;
--- a/gfx/src/nsSize.h
+++ b/gfx/src/nsSize.h
@@ -21,18 +21,23 @@ struct nsSize : public mozilla::gfx::Bas
 
   nsSize() : Super() {}
   nsSize(nscoord aWidth, nscoord aHeight) : Super(aWidth, aHeight) {}
 
   inline nsIntSize ScaleToNearestPixels(float aXScale, float aYScale,
                                         nscoord aAppUnitsPerPixel) const;
   inline nsIntSize ToNearestPixels(nscoord aAppUnitsPerPixel) const;
 
-  // Converts this size from aFromAPP, an appunits per pixel ratio, to aToAPP.
-  inline nsSize ConvertAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
+  /**
+   * Return this size scaled to a different appunits per pixel (APP) ratio.
+   * @param aFromAPP the APP to scale from
+   * @param aToAPP the APP to scale to
+   */
+  MOZ_WARN_UNUSED_RESULT inline nsSize
+    ConvertAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
 };
 
 struct nsIntSize : public mozilla::gfx::BaseSize<int32_t, nsIntSize> {
   typedef mozilla::gfx::BaseSize<int32_t, nsIntSize> Super;
 
   nsIntSize() : Super() {}
   nsIntSize(int32_t aWidth, int32_t aHeight) : Super(aWidth, aHeight) {}