Bug 1144951. Warn if the result of ConvertAppUnits is unused. r=mats

There is never a case where Ignoring the result makes sense.
This commit is contained in:
Timothy Nikkel 2015-03-26 16:44:38 -05:00
parent afd6d68422
commit 6c9c9adad9
4 changed files with 39 additions and 16 deletions

View File

@ -26,8 +26,13 @@ struct nsPoint : public mozilla::gfx::BasePoint<nscoord, nsPoint> {
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.

View File

@ -134,13 +134,19 @@ struct NS_GFX nsRect :
*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;

View File

@ -285,11 +285,18 @@ public:
}
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);

View File

@ -26,8 +26,13 @@ struct nsSize : public mozilla::gfx::BaseSize<nscoord, nsSize> {
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> {