From 66b9023deadcb587d03c18f188e6900a75e00ffe Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Sun, 6 Sep 2026 09:14:24 +0000 Subject: [PATCH] Bug 2069594. Give nsRect the default copy constructor so the compiler knows it is trivially copyable. r=layout-reviewers,emilio On some ABIs this means that it can be passed and returned in a register instead of in memory. Differential Revision: https://phabricator.services.mozilla.com/D323836 --- gfx/src/nsRect.h | 28 +++++++++++++--------------- widget/WidgetUtils.h | 1 + 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/gfx/src/nsRect.h b/gfx/src/nsRect.h index 76ec0107b388..d0dd68edf09f 100644 --- a/gfx/src/nsRect.h +++ b/gfx/src/nsRect.h @@ -7,15 +7,15 @@ #include // for int32_t, int64_t -#include // for min/max +#include // for min/max +#include // for is_trivially_copyable_v #include "mozilla/Likely.h" // for MOZ_UNLIKELY #include "mozilla/gfx/BaseRect.h" #include "mozilla/gfx/Rect.h" -#include "nsCoord.h" // for nscoord, etc -#include "nsISupports.h" // for MOZ_COUNT_CTOR, etc -#include "nsPoint.h" // for nsIntPoint, nsPoint -#include "nsSize.h" // for IntSize, nsSize +#include "nsCoord.h" // for nscoord, etc +#include "nsPoint.h" // for nsIntPoint, nsPoint +#include "nsSize.h" // for IntSize, nsSize #if !defined(ANDROID) && (defined(__SSE2__) || defined(_M_X64) || \ (defined(_M_IX86_FP) && _M_IX86_FP >= 2)) @@ -38,19 +38,13 @@ struct nsRect : public mozilla::gfx::BaseRect, + "nsRect must stay trivially copyable so that it is passed and " + "returned in registers"); + /* * App Unit/Pixel conversions */ diff --git a/widget/WidgetUtils.h b/widget/WidgetUtils.h index a7e1e8b38cd7..915697f30c10 100644 --- a/widget/WidgetUtils.h +++ b/widget/WidgetUtils.h @@ -8,6 +8,7 @@ #include "mozilla/AlreadyAddRefed.h" #include "mozilla/gfx/Matrix.h" #include "nsRect.h" +#include "nsStringFwd.h" class nsIWidget; class nsPIDOMWindowOuter;