summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2023-11-03 00:34:37 +0100
committerMoonchild <moonchild@palemoon.org>2023-11-08 13:45:15 +0100
commitad321f50d91937a319f29ebab89b9509acc9b51e (patch)
tree5beef6cccca31d72dd46a286b006fc75239aa476
parentcd8c5dae0cb5c23699171cf787cc70d720eec14c (diff)
downloaduxp-ad321f50d91937a319f29ebab89b9509acc9b51e.tar.gz
Issue #2342: Use [[nodiscard]] in /gfx and /layout
-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
-rw-r--r--layout/generic/AspectRatio.h2
-rw-r--r--layout/style/ServoStyleSheet.h10
-rw-r--r--layout/style/StyleAnimationValue.h28
-rw-r--r--layout/svg/AutoReferenceLimiter.h2
10 files changed, 48 insertions, 48 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;
};
diff --git a/layout/generic/AspectRatio.h b/layout/generic/AspectRatio.h
index 5cb281c804..b940376257 100644
--- a/layout/generic/AspectRatio.h
+++ b/layout/generic/AspectRatio.h
@@ -47,7 +47,7 @@ struct AspectRatio {
}
// Inverts the ratio, in order to get the height / width ratio.
- MOZ_MUST_USE AspectRatio Inverted() const {
+ [[nodiscard]] AspectRatio Inverted() const {
if (!*this) {
return AspectRatio();
}
diff --git a/layout/style/ServoStyleSheet.h b/layout/style/ServoStyleSheet.h
index d32d576746..8c3b888c4d 100644
--- a/layout/style/ServoStyleSheet.h
+++ b/layout/style/ServoStyleSheet.h
@@ -34,11 +34,11 @@ public:
ServoStyleSheet* GetParentSheet() const;
void AppendStyleSheet(ServoStyleSheet* aSheet);
- MOZ_MUST_USE nsresult ParseSheet(const nsAString& aInput,
- nsIURI* aSheetURI,
- nsIURI* aBaseURI,
- nsIPrincipal* aSheetPrincipal,
- uint32_t aLineNumber);
+ [[nodiscard]] nsresult ParseSheet(const nsAString& aInput,
+ nsIURI* aSheetURI,
+ nsIURI* aBaseURI,
+ nsIPrincipal* aSheetPrincipal,
+ uint32_t aLineNumber);
/**
* Called instead of ParseSheet to initialize the Servo stylesheet object
diff --git a/layout/style/StyleAnimationValue.h b/layout/style/StyleAnimationValue.h
index e318cecb6b..af58daac13 100644
--- a/layout/style/StyleAnimationValue.h
+++ b/layout/style/StyleAnimationValue.h
@@ -55,7 +55,7 @@ public:
* @param aCount The number of times to add aValueToAdd.
* @return true on success, false on failure.
*/
- static MOZ_MUST_USE bool
+ [[nodiscard]] static bool
Add(nsCSSPropertyID aProperty, StyleAnimationValue& aDest,
const StyleAnimationValue& aValueToAdd, uint32_t aCount) {
return AddWeighted(aProperty, 1.0, aDest, aCount, aValueToAdd, aDest);
@@ -93,7 +93,7 @@ public:
* @param aDistance The result of the calculation.
* @return true on success, false on failure.
*/
- static MOZ_MUST_USE bool
+ [[nodiscard]] static bool
ComputeDistance(nsCSSPropertyID aProperty,
const StyleAnimationValue& aStartValue,
const StyleAnimationValue& aEndValue,
@@ -116,7 +116,7 @@ public:
* @param [out] aResultValue The resulting interpolated value.
* @return true on success, false on failure.
*/
- static MOZ_MUST_USE bool
+ [[nodiscard]] static bool
Interpolate(nsCSSPropertyID aProperty,
const StyleAnimationValue& aStartValue,
const StyleAnimationValue& aEndValue,
@@ -140,7 +140,7 @@ public:
* difficulty, we might change this to restrict them to being
* positive.
*/
- static MOZ_MUST_USE bool
+ [[nodiscard]] static bool
AddWeighted(nsCSSPropertyID aProperty,
double aCoeff1, const StyleAnimationValue& aValue1,
double aCoeff2, const StyleAnimationValue& aValue2,
@@ -162,7 +162,7 @@ public:
* has a value which is outside the range [0, 1] so that we can calculate
* plausible values as interpolation with the return value.
*/
- static MOZ_MUST_USE bool
+ [[nodiscard]] static bool
Accumulate(nsCSSPropertyID aProperty, StyleAnimationValue& aDest,
const StyleAnimationValue& aValueToAccumulate,
uint64_t aCount);
@@ -199,7 +199,7 @@ public:
* nullptr.
* @return true on success, false on failure.
*/
- static MOZ_MUST_USE bool
+ [[nodiscard]] static bool
ComputeValue(nsCSSPropertyID aProperty,
mozilla::dom::Element* aTargetElement,
nsStyleContext* aStyleContext,
@@ -218,7 +218,7 @@ public:
* to aResult. On failure, aResult might still have partial results
* in it.
*/
- static MOZ_MUST_USE bool
+ [[nodiscard]] static bool
ComputeValues(nsCSSPropertyID aProperty,
mozilla::CSSEnabledState aEnabledState,
mozilla::dom::Element* aTargetElement,
@@ -231,7 +231,7 @@ public:
* A variant on ComputeValues that takes an nsCSSValue as the specified
* value. Only longhand properties are supported.
*/
- static MOZ_MUST_USE bool
+ [[nodiscard]] static bool
ComputeValues(nsCSSPropertyID aProperty,
mozilla::CSSEnabledState aEnabledState,
mozilla::dom::Element* aTargetElement,
@@ -244,7 +244,7 @@ public:
* A variant of ComputeValues that takes a RawServoDeclarationBlock
* as the specified value.
*/
- static MOZ_MUST_USE bool
+ [[nodiscard]] static bool
ComputeValues(nsCSSPropertyID aProperty,
mozilla::CSSEnabledState aEnabledState,
nsStyleContext* aStyleContext,
@@ -268,18 +268,18 @@ public:
* @param [out] aSpecifiedValue The resulting specified value.
* @return true on success, false on failure.
*
- * These functions are not MOZ_MUST_USE because failing to check the return
+ * These functions are not [[nodiscard]] because failing to check the return
* value is common and reasonable.
*/
- static MOZ_MUST_USE bool
+ static bool
UncomputeValue(nsCSSPropertyID aProperty,
const StyleAnimationValue& aComputedValue,
nsCSSValue& aSpecifiedValue);
- static MOZ_MUST_USE bool
+ static bool
UncomputeValue(nsCSSPropertyID aProperty,
StyleAnimationValue&& aComputedValue,
nsCSSValue& aSpecifiedValue);
- static MOZ_MUST_USE bool
+ static bool
UncomputeValue(nsCSSPropertyID aProperty,
const StyleAnimationValue& aComputedValue,
nsAString& aSpecifiedValue);
@@ -298,7 +298,7 @@ public:
* @param [out] aComputedValue The resulting computed value.
* @return true on success, false on failure.
*/
- static MOZ_MUST_USE bool ExtractComputedValue(
+ [[nodiscard]] static bool ExtractComputedValue(
nsCSSPropertyID aProperty,
nsStyleContext* aStyleContext,
StyleAnimationValue& aComputedValue);
diff --git a/layout/svg/AutoReferenceLimiter.h b/layout/svg/AutoReferenceLimiter.h
index 5f822ba135..268f84539a 100644
--- a/layout/svg/AutoReferenceLimiter.h
+++ b/layout/svg/AutoReferenceLimiter.h
@@ -96,7 +96,7 @@ public:
* within the specified limits), else returns false on failure (there is a
* reference loop/the reference chain has exceeded the specified limits).
*/
- MOZ_MUST_USE bool Reference() {
+ [[nodiscard]] bool Reference() {
// If we fail this assertion then either a consumer failed to break a
// reference loop/chain, or else they called Reference() more than once
MOZ_ASSERT(*mRefCounter >= 0);