Bug 1147706 - Warn if we don't use the result of const methods on BaseRect and its subclasses. r=tn

This commit is contained in:
Seth Fowler 2015-03-26 15:39:47 -07:00
Родитель 0934f2e2f0
Коммит 39007175b4
2 изменённых файлов: 31 добавлений и 19 удалений

Просмотреть файл

@ -106,7 +106,7 @@ struct BaseRect {
// (including edges) of *this and aRect. If there are no points in that
// intersection, returns an empty rectangle with x/y set to the std::max of the x/y
// of *this and aRect.
Sub Intersect(const Sub& aRect) const
MOZ_WARN_UNUSED_RESULT Sub Intersect(const Sub& aRect) const
{
Sub result;
result.x = std::max<T>(x, aRect.x);
@ -134,7 +134,7 @@ struct BaseRect {
// this and aRect2.
// Thus, empty input rectangles are ignored.
// If both rectangles are empty, returns this.
Sub Union(const Sub& aRect) const
MOZ_WARN_UNUSED_RESULT Sub Union(const Sub& aRect) const
{
if (IsEmpty()) {
return aRect;
@ -147,7 +147,7 @@ struct BaseRect {
// Returns the smallest rectangle that contains both the points (including
// edges) of both aRect1 and aRect2.
// Thus, empty input rectangles are allowed to affect the result.
Sub UnionEdges(const Sub& aRect) const
MOZ_WARN_UNUSED_RESULT Sub UnionEdges(const Sub& aRect) const
{
Sub result;
result.x = std::min(x, aRect.x);
@ -525,7 +525,7 @@ struct BaseRect {
* Clamp aPoint to this rectangle. It is allowed to end up on any
* edge of the rectangle.
*/
Point ClampPoint(const Point& aPoint) const
MOZ_WARN_UNUSED_RESULT Point ClampPoint(const Point& aPoint) const
{
return Point(std::max(x, std::min(XMost(), aPoint.x)),
std::max(y, std::min(YMost(), aPoint.y)));
@ -536,7 +536,7 @@ struct BaseRect {
* this rect after it is forced inside the bounds of aRect. It will attempt to
* retain the size but will shrink the dimensions that don't fit.
*/
Sub ForceInside(const Sub& aRect) const
MOZ_WARN_UNUSED_RESULT Sub ForceInside(const Sub& aRect) const
{
Sub rect(std::max(aRect.x, x),
std::max(aRect.y, y),

Просмотреть файл

@ -59,7 +59,7 @@ struct NS_GFX nsRect :
// overflowing nscoord values in the 'width' and 'height' fields by
// clamping the width and height values to nscoord_MAX if necessary.
nsRect SaturatingUnion(const nsRect& aRect) const
MOZ_WARN_UNUSED_RESULT nsRect SaturatingUnion(const nsRect& aRect) const
{
if (IsEmpty()) {
return aRect;
@ -70,7 +70,7 @@ struct NS_GFX nsRect :
}
}
nsRect SaturatingUnionEdges(const nsRect& aRect) const
MOZ_WARN_UNUSED_RESULT nsRect SaturatingUnionEdges(const nsRect& aRect) const
{
#ifdef NS_COORD_IS_FLOAT
return UnionEdges(aRect);
@ -107,7 +107,7 @@ struct NS_GFX nsRect :
#ifndef NS_COORD_IS_FLOAT
// Make all nsRect Union methods be saturating.
nsRect UnionEdges(const nsRect& aRect) const
MOZ_WARN_UNUSED_RESULT nsRect UnionEdges(const nsRect& aRect) const
{
return SaturatingUnionEdges(aRect);
}
@ -115,7 +115,7 @@ struct NS_GFX nsRect :
{
*this = aRect1.UnionEdges(aRect2);
}
nsRect Union(const nsRect& aRect) const
MOZ_WARN_UNUSED_RESULT nsRect Union(const nsRect& aRect) const
{
return SaturatingUnion(aRect);
}
@ -148,17 +148,28 @@ struct NS_GFX nsRect :
MOZ_WARN_UNUSED_RESULT inline nsRect
ScaleToOtherAppUnitsRoundIn(int32_t aFromAPP, int32_t aToAPP) const;
inline nsIntRect ScaleToNearestPixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const;
inline nsIntRect ToNearestPixels(nscoord aAppUnitsPerPixel) const;
MOZ_WARN_UNUSED_RESULT inline nsIntRect
ScaleToNearestPixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const;
MOZ_WARN_UNUSED_RESULT 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;
MOZ_WARN_UNUSED_RESULT inline nsIntRect
ScaleToOutsidePixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const;
// Note: this can turn an empty rectangle into a non-empty rectangle
inline nsIntRect ToOutsidePixels(nscoord aAppUnitsPerPixel) const;
inline nsIntRect ScaleToInsidePixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const;
inline nsIntRect ToInsidePixels(nscoord aAppUnitsPerPixel) const;
MOZ_WARN_UNUSED_RESULT inline nsIntRect
ToOutsidePixels(nscoord aAppUnitsPerPixel) const;
MOZ_WARN_UNUSED_RESULT inline nsIntRect
ScaleToInsidePixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const;
MOZ_WARN_UNUSED_RESULT inline nsIntRect
ToInsidePixels(nscoord aAppUnitsPerPixel) const;
// This is here only to keep IPDL-generated code happy. DO NOT USE.
bool operator==(const nsRect& aRect) const
@ -186,7 +197,8 @@ struct NS_GFX nsIntRect :
{
}
inline nsRect ToAppUnits(nscoord aAppUnitsPerPixel) const;
MOZ_WARN_UNUSED_RESULT inline nsRect
ToAppUnits(nscoord aAppUnitsPerPixel) const;
// Returns a special nsIntRect that's used in some places to signify
// "all available space".