diff --git a/image/Downscaler.cpp b/image/Downscaler.cpp index 59d2dd024877..d10759553fbb 100644 --- a/image/Downscaler.cpp +++ b/image/Downscaler.cpp @@ -286,7 +286,7 @@ void Downscaler::DownscaleInputLine() { // Shift the buffer. We're just moving pointers here, so this is cheap. mLinesInBuffer -= diff; - mLinesInBuffer = std::min(std::max(mLinesInBuffer, 0), mWindowCapacity); + mLinesInBuffer = std::clamp(mLinesInBuffer, 0, mWindowCapacity); // If we already have enough rows to satisfy the filter, there is no need // to swap as we won't be writing more before the next convolution. diff --git a/image/DownscalingFilter.h b/image/DownscalingFilter.h index 1233e7be0b2b..b3bb5dd3df44 100644 --- a/image/DownscalingFilter.h +++ b/image/DownscalingFilter.h @@ -260,7 +260,7 @@ class DownscalingFilter final : public SurfaceFilter { // Shift the buffer. We're just moving pointers here, so this is cheap. mRowsInWindow -= diff; - mRowsInWindow = std::min(std::max(mRowsInWindow, 0), mWindowCapacity); + mRowsInWindow = std::clamp(mRowsInWindow, 0, mWindowCapacity); // If we already have enough rows to satisfy the filter, there is no need // to swap as we won't be writing more before the next convolution. diff --git a/image/RasterImage.cpp b/image/RasterImage.cpp index d426beefdaa9..6c956c9175a1 100644 --- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -744,8 +744,8 @@ bool RasterImage::SetMetadata(const ImageMetadata& aMetadata, MOZ_ASSERT(mOrientation.IsIdentity(), "Would need to orient hotspot point"); auto hotspot = aMetadata.GetHotspot(); - mHotspot.x = std::max(std::min(hotspot.x.value, mSize.width - 1), 0); - mHotspot.y = std::max(std::min(hotspot.y.value, mSize.height - 1), 0); + mHotspot.x = std::clamp(hotspot.x.value, 0, mSize.width - 1); + mHotspot.y = std::clamp(hotspot.y.value, 0, mSize.height - 1); } return true; diff --git a/image/imgFrame.cpp b/image/imgFrame.cpp index 0df40fcfa93c..fc21fb196595 100644 --- a/image/imgFrame.cpp +++ b/image/imgFrame.cpp @@ -262,7 +262,7 @@ nsresult imgFrame::InitForDecoderRecycle(const AnimationParams& aAnimParams) { // is still in use for some other purpose, it won't be returned to the pool // and its owner can hold onto it forever without additional impact here. int32_t refreshInterval = - std::max(std::min(nsRefreshDriver::DefaultInterval(), 20), 4); + std::clamp(nsRefreshDriver::DefaultInterval(), 4, 20); TimeDuration waitInterval = TimeDuration::FromMilliseconds(refreshInterval >> 2); TimeStamp timeout =