From c72bd3a22dd7a0a3b9dadb7b12b84f492ef32120 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Wed, 6 Nov 2024 10:14:24 +0000 Subject: [PATCH] Bug 1929262 - Use std::clamp instead of min/max chain in widget/nsBaseWidget.h r=m_kato Differential Revision: https://phabricator.services.mozilla.com/D227974 --- widget/nsBaseWidget.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index dcb2fd3d9014..297f280a7ae5 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -570,9 +570,8 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference { */ void ConstrainSize(int32_t* aWidth, int32_t* aHeight) override { SizeConstraints c = GetSizeConstraints(); - *aWidth = std::max(c.mMinSize.width, std::min(c.mMaxSize.width, *aWidth)); - *aHeight = - std::max(c.mMinSize.height, std::min(c.mMaxSize.height, *aHeight)); + *aWidth = std::clamp(*aWidth, c.mMinSize.width, c.mMaxSize.width); + *aHeight = std::clamp(*aHeight, c.mMinSize.height, c.mMaxSize.height); } CompositorBridgeChild* GetRemoteRenderer() override;