summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2023-11-11 01:55:07 +0000
committerMoonchild <moonchild@palemoon.org>2023-11-11 01:55:07 +0000
commitc789882a294d29b3e5450a972ad67c4839c75e23 (patch)
tree4234880ff76df9da2caaf06983da144e42032a09 /gfx
parent93eee35e84c29e1e64cb1531a0830b8ab2a7c5fa (diff)
parentf9ad6258221d89d8ee8e543c2ff8b21a42dbd285 (diff)
downloaduxp-c789882a294d29b3e5450a972ad67c4839c75e23.tar.gz
Merge pull request 'Replace MOZ_MUST_USE with [[nodiscard]]' (#2375) from 2342-nodiscard-work into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2375
Diffstat (limited to 'gfx')
-rw-r--r--gfx/2d/BaseRect.h12
-rw-r--r--gfx/2d/Rect.h4
-rw-r--r--gfx/src/nsPoint.h6
-rw-r--r--gfx/src/nsRect.h26
-rw-r--r--gfx/src/nsRegion.h4
-rw-r--r--gfx/src/nsSize.h2
6 files changed, 27 insertions, 27 deletions
diff --git a/gfx/2d/BaseRect.h b/gfx/2d/BaseRect.h
index a4e5e4c1d0..7f1590060d 100644
--- a/gfx/2d/BaseRect.h
+++ b/gfx/2d/BaseRect.h
@@ -111,7 +111,7 @@ struct BaseRect {
// Intersection with an empty Rect may not produce an empty Rect if overflow
// occurs. e.g. {INT_MIN, 0, 0, 20} Intersect { 5000, 0, 500, 20 } gives:
// the non-emtpy {5000, 0, 500, 20 } instead of {5000, 0, 0, 0}
- MOZ_MUST_USE Sub Intersect(const Sub& aRect) const
+ [[nodiscard]] Sub Intersect(const Sub& aRect) const
{
Sub result;
result.x = std::max<T>(x, aRect.x);
@@ -127,7 +127,7 @@ struct BaseRect {
// better. This comes at a tiny cost in performance.
// e.g. {INT_MIN, 0, 0, 20} Intersect { 5000, 0, 500, 20 } gives:
// {5000, 0, 0, 0}
- MOZ_MUST_USE Sub SafeIntersect(const Sub& aRect) const
+ [[nodiscard]] Sub SafeIntersect(const Sub& aRect) const
{
Sub result;
result.x = std::max<T>(x, aRect.x);
@@ -161,7 +161,7 @@ struct BaseRect {
// If both rectangles are empty, returns this.
// WARNING! This is not safe against overflow, prefer using SafeUnion instead
// when dealing with int-based rects.
- MOZ_MUST_USE Sub Union(const Sub& aRect) const
+ [[nodiscard]] Sub Union(const Sub& aRect) const
{
if (IsEmpty()) {
return aRect;
@@ -176,7 +176,7 @@ struct BaseRect {
// Thus, empty input rectangles are allowed to affect the result.
// WARNING! This is not safe against overflow, prefer using SafeUnionEdges
// instead when dealing with int-based rects.
- MOZ_MUST_USE Sub UnionEdges(const Sub& aRect) const
+ [[nodiscard]] Sub UnionEdges(const Sub& aRect) const
{
Sub result;
result.x = std::min(x, aRect.x);
@@ -588,7 +588,7 @@ struct BaseRect {
* Clamp aPoint to this rectangle. It is allowed to end up on any
* edge of the rectangle.
*/
- MOZ_MUST_USE Point ClampPoint(const Point& aPoint) const
+ [[nodiscard]] Point ClampPoint(const Point& aPoint) const
{
return Point(std::max(x, std::min(XMost(), aPoint.x)),
std::max(y, std::min(YMost(), aPoint.y)));
@@ -599,7 +599,7 @@ struct BaseRect {
* aRect then the dimensions that don't fit will be shrunk so that they
* do fit. The resulting rect is returned.
*/
- MOZ_MUST_USE Sub MoveInsideAndClamp(const Sub& aRect) const
+ [[nodiscard]] Sub MoveInsideAndClamp(const Sub& aRect) const
{
Sub rect(std::max(aRect.x, x),
std::max(aRect.y, y),
diff --git a/gfx/2d/Rect.h b/gfx/2d/Rect.h
index 942cb200db..d17b802434 100644
--- a/gfx/2d/Rect.h
+++ b/gfx/2d/Rect.h
@@ -166,7 +166,7 @@ struct IntRectTyped :
// Same as Union(), but in the cases where aRect is non-empty, the union is
// done while guarding against overflow. If an overflow is detected, Nothing
// is returned.
- MOZ_MUST_USE Maybe<Self> SafeUnion(const Self& aRect) const
+ [[nodiscard]] Maybe<Self> SafeUnion(const Self& aRect) const
{
if (this->IsEmpty()) {
return aRect.Overflows() ? Nothing() : Some(aRect);
@@ -179,7 +179,7 @@ struct IntRectTyped :
// Same as UnionEdges, but guards against overflow. If an overflow is detected,
// Nothing is returned.
- MOZ_MUST_USE Maybe<Self> SafeUnionEdges(const Self& aRect) const
+ [[nodiscard]] Maybe<Self> SafeUnionEdges(const Self& aRect) const
{
if (this->Overflows() || aRect.Overflows()) {
return Nothing();
diff --git a/gfx/src/nsPoint.h b/gfx/src/nsPoint.h
index b377eb5a56..3c406e5a61 100644
--- a/gfx/src/nsPoint.h
+++ b/gfx/src/nsPoint.h
@@ -35,12 +35,12 @@ struct nsPoint : public mozilla::gfx::BasePoint<nscoord, nsPoint> {
* @param aFromAPP the APP to scale from
* @param aToAPP the APP to scale to
*/
- MOZ_MUST_USE inline nsPoint
+ [[nodiscard]] inline nsPoint
ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
- MOZ_MUST_USE inline nsPoint
+ [[nodiscard]] inline nsPoint
RemoveResolution(const float resolution) const;
- MOZ_MUST_USE inline nsPoint
+ [[nodiscard]] inline nsPoint
ApplyResolution(const float resolution) const;
};
diff --git a/gfx/src/nsRect.h b/gfx/src/nsRect.h
index 267f5849cb..403d3c06b2 100644
--- a/gfx/src/nsRect.h
+++ b/gfx/src/nsRect.h
@@ -56,7 +56,7 @@ struct nsRect :
// overflowing nscoord values in the 'width' and 'height' fields by
// clamping the width and height values to nscoord_MAX if necessary.
- MOZ_MUST_USE nsRect SaturatingUnion(const nsRect& aRect) const
+ [[nodiscard]] nsRect SaturatingUnion(const nsRect& aRect) const
{
if (IsEmpty()) {
return aRect;
@@ -67,7 +67,7 @@ struct nsRect :
}
}
- MOZ_MUST_USE nsRect SaturatingUnionEdges(const nsRect& aRect) const
+ [[nodiscard]] nsRect SaturatingUnionEdges(const nsRect& aRect) const
{
#ifdef NS_COORD_IS_FLOAT
return UnionEdges(aRect);
@@ -102,7 +102,7 @@ struct nsRect :
#ifndef NS_COORD_IS_FLOAT
// Make all nsRect Union methods be saturating.
- MOZ_MUST_USE nsRect UnionEdges(const nsRect& aRect) const
+ [[nodiscard]] nsRect UnionEdges(const nsRect& aRect) const
{
return SaturatingUnionEdges(aRect);
}
@@ -110,7 +110,7 @@ struct nsRect :
{
*this = aRect1.UnionEdges(aRect2);
}
- MOZ_MUST_USE nsRect Union(const nsRect& aRect) const
+ [[nodiscard]] nsRect Union(const nsRect& aRect) const
{
return SaturatingUnion(aRect);
}
@@ -141,32 +141,32 @@ struct nsRect :
* @param aToAPP the APP to scale to
* @note this can turn an empty rectangle into a non-empty rectangle
*/
- MOZ_MUST_USE inline nsRect
+ [[nodiscard]] inline nsRect
ScaleToOtherAppUnitsRoundOut(int32_t aFromAPP, int32_t aToAPP) const;
- MOZ_MUST_USE inline nsRect
+ [[nodiscard]] inline nsRect
ScaleToOtherAppUnitsRoundIn(int32_t aFromAPP, int32_t aToAPP) const;
- MOZ_MUST_USE inline mozilla::gfx::IntRect
+ [[nodiscard]] inline mozilla::gfx::IntRect
ScaleToNearestPixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const;
- MOZ_MUST_USE inline mozilla::gfx::IntRect
+ [[nodiscard]] inline mozilla::gfx::IntRect
ToNearestPixels(nscoord aAppUnitsPerPixel) const;
// Note: this can turn an empty rectangle into a non-empty rectangle
- MOZ_MUST_USE inline mozilla::gfx::IntRect
+ [[nodiscard]] inline mozilla::gfx::IntRect
ScaleToOutsidePixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const;
// Note: this can turn an empty rectangle into a non-empty rectangle
- MOZ_MUST_USE inline mozilla::gfx::IntRect
+ [[nodiscard]] inline mozilla::gfx::IntRect
ToOutsidePixels(nscoord aAppUnitsPerPixel) const;
- MOZ_MUST_USE inline mozilla::gfx::IntRect
+ [[nodiscard]] inline mozilla::gfx::IntRect
ScaleToInsidePixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const;
- MOZ_MUST_USE inline mozilla::gfx::IntRect
+ [[nodiscard]] inline mozilla::gfx::IntRect
ToInsidePixels(nscoord aAppUnitsPerPixel) const;
// This is here only to keep IPDL-generated code happy. DO NOT USE.
@@ -175,7 +175,7 @@ struct nsRect :
return IsEqualEdges(aRect);
}
- MOZ_MUST_USE inline nsRect RemoveResolution(const float aResolution) const;
+ [[nodiscard]] inline nsRect RemoveResolution(const float aResolution) const;
};
/*
diff --git a/gfx/src/nsRegion.h b/gfx/src/nsRegion.h
index e4ad5fc8a0..143be356e6 100644
--- a/gfx/src/nsRegion.h
+++ b/gfx/src/nsRegion.h
@@ -296,9 +296,9 @@ public:
* @param aToAPP the APP to scale to
* @note this can turn an empty region into a non-empty region
*/
- MOZ_MUST_USE nsRegion
+ [[nodiscard]] nsRegion
ScaleToOtherAppUnitsRoundOut (int32_t aFromAPP, int32_t aToAPP) const;
- MOZ_MUST_USE nsRegion
+ [[nodiscard]] nsRegion
ScaleToOtherAppUnitsRoundIn (int32_t aFromAPP, int32_t aToAPP) const;
nsRegion& ScaleRoundOut(float aXScale, float aYScale);
nsRegion& ScaleInverseRoundOut(float aXScale, float aYScale);
diff --git a/gfx/src/nsSize.h b/gfx/src/nsSize.h
index f27c478f96..bb1505a2c2 100644
--- a/gfx/src/nsSize.h
+++ b/gfx/src/nsSize.h
@@ -30,7 +30,7 @@ struct nsSize : public mozilla::gfx::BaseSize<nscoord, nsSize> {
* @param aFromAPP the APP to scale from
* @param aToAPP the APP to scale to
*/
- MOZ_MUST_USE inline nsSize
+ [[nodiscard]] inline nsSize
ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
};