commit 497e96799d2ebb4615e1f4bc8ecbb2257f0238e0
parent c22d71ab11f06ad5bf2ab9dc9427749a003436c3
Author: Chris Peterson <cpeterson@mozilla.com>
Date: Tue, 9 Dec 2025 00:01:28 +0000
Bug 2002864 - Replace MOZ_CONSTINIT with C++20 constinit in dom code. r=dom-core,places-reviewers,dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D274498
Diffstat:
9 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/dom/base/PlacesObservers.cpp b/dom/base/PlacesObservers.cpp
@@ -67,7 +67,7 @@ using WeakNativeListeners =
// Even if NotifyListeners is called any timing, we mange the notifications with
// adding to this queue, then sending in sequence. This avoids sending nested
// notifications while previous ones are still being sent.
-MOZ_CONSTINIT static nsTArray<Sequence<OwningNonNull<PlacesEvent>>>
+constinit static nsTArray<Sequence<OwningNonNull<PlacesEvent>>>
gNotificationQueue;
uint32_t GetEventTypeFlag(PlacesEventType aEventType) {
diff --git a/dom/base/PointerLockManager.cpp b/dom/base/PointerLockManager.cpp
@@ -42,10 +42,10 @@ using mozilla::dom::Element;
using mozilla::dom::WindowContext;
// Reference to the pointer locked element.
-MOZ_CONSTINIT static nsWeakPtr sLockedElement;
+constinit static nsWeakPtr sLockedElement;
// Reference to the document which requested pointer lock.
-MOZ_CONSTINIT static nsWeakPtr sLockedDoc;
+constinit static nsWeakPtr sLockedDoc;
// Reference to the BrowserParent requested pointer lock.
static BrowserParent* sLockedRemoteTarget = nullptr;
diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp
@@ -152,7 +152,7 @@ static nsITimer* gUserInteractionTimer = nullptr;
static nsITimerCallback* gUserInteractionTimerCallback = nullptr;
static const double kCursorLoadingTimeout = 1000; // ms
-MOZ_CONSTINIT static AutoWeakFrame gLastCursorSourceFrame;
+constinit static AutoWeakFrame gLastCursorSourceFrame;
static TimeStamp gLastCursorUpdateTime;
static TimeStamp gTypingStartTime;
static TimeStamp gTypingEndTime;
@@ -616,7 +616,7 @@ bool EventStateManager::sNormalLMouseEventInProcess = false;
int16_t EventStateManager::sCurrentMouseBtn = MouseButton::eNotPressed;
EventStateManager* EventStateManager::sActiveESM = nullptr;
EventStateManager* EventStateManager::sCursorSettingManager = nullptr;
-MOZ_CONSTINIT AutoWeakFrame EventStateManager::sLastDragOverFrame{};
+constinit AutoWeakFrame EventStateManager::sLastDragOverFrame{};
LayoutDeviceIntPoint EventStateManager::sPreLockScreenPoint =
LayoutDeviceIntPoint(0, 0);
LayoutDeviceIntPoint EventStateManager::sLastRefPoint = kInvalidRefPoint;
diff --git a/dom/events/WheelHandlingHelper.cpp b/dom/events/WheelHandlingHelper.cpp
@@ -118,8 +118,8 @@ WheelHandlingUtils::GetDisregardedWheelScrollDirection(const nsIFrame* aFrame) {
/* mozilla::WheelTransaction */
/******************************************************************/
-MOZ_CONSTINIT AutoWeakFrame WheelTransaction::sScrollTargetFrame;
-MOZ_CONSTINIT AutoWeakFrame WheelTransaction::sEventTargetFrame;
+constinit AutoWeakFrame WheelTransaction::sScrollTargetFrame;
+constinit AutoWeakFrame WheelTransaction::sEventTargetFrame;
bool WheelTransaction::sHandledByApz(false);
uint32_t WheelTransaction::sTime = 0;
@@ -474,8 +474,8 @@ DeltaValues WheelTransaction::OverrideSystemScrollSpeed(
/* mozilla::ScrollbarsForWheel */
/******************************************************************/
-MOZ_CONSTINIT AutoWeakFrame ScrollbarsForWheel::sActiveOwner;
-MOZ_CONSTINIT AutoWeakFrame
+constinit AutoWeakFrame ScrollbarsForWheel::sActiveOwner;
+constinit AutoWeakFrame
ScrollbarsForWheel::sActivatedScrollTargets[kNumberOfTargets];
bool ScrollbarsForWheel::sHadWheelStart = false;
diff --git a/dom/fetch/FetchUtil.cpp b/dom/fetch/FetchUtil.cpp
@@ -653,7 +653,7 @@ class JSStreamConsumer final : public nsIInputStreamCallback,
NS_IMPL_ISUPPORTS(JSStreamConsumer, nsIInputStreamCallback)
// static
-MOZ_CONSTINIT nsCString FetchUtil::WasmAltDataType;
+constinit nsCString FetchUtil::WasmAltDataType;
// static
void FetchUtil::InitWasmAltDataType() {
diff --git a/dom/security/featurepolicy/fuzztest/fp_fuzzer.cpp b/dom/security/featurepolicy/fuzztest/fp_fuzzer.cpp
@@ -15,8 +15,8 @@
using namespace mozilla;
using namespace mozilla::dom;
-MOZ_CONSTINIT static nsCOMPtr<nsIPrincipal> selfURIPrincipal;
-MOZ_CONSTINIT static nsCOMPtr<nsIURI> selfURI;
+constinit static nsCOMPtr<nsIPrincipal> selfURIPrincipal;
+constinit static nsCOMPtr<nsIURI> selfURI;
static int LVVMFuzzerInitTest(int* argc, char*** argv) {
nsresult ret;
diff --git a/dom/serviceworkers/test/gtest/TestReadWrite.cpp b/dom/serviceworkers/test/gtest/TestReadWrite.cpp
@@ -35,7 +35,7 @@ struct HandlerStats {
nsCString lastValue2;
};
-MOZ_CONSTINIT mozilla::UniquePtr<HandlerStats> gHandlerStats;
+constinit mozilla::UniquePtr<HandlerStats> gHandlerStats;
void MaybeCreateHandlerStats() {
if (!gHandlerStats) {
diff --git a/dom/webscheduling/WebTaskScheduler.h b/dom/webscheduling/WebTaskScheduler.h
@@ -23,7 +23,7 @@ namespace mozilla::dom {
// Keep tracks of the number of same-event-loop-high-priority-queues
// (User_blocking or User_visible) that have at least one task scheduled.
-MOZ_CONSTINIT extern uint32_t
+constinit extern uint32_t
gNumNormalOrHighPriorityQueuesHaveTaskScheduledMainThread;
// https://wicg.github.io/scheduling-apis/#scheduling-state
diff --git a/dom/webscheduling/WebTaskSchedulerMainThread.cpp b/dom/webscheduling/WebTaskSchedulerMainThread.cpp
@@ -13,8 +13,8 @@
namespace mozilla::dom {
-MOZ_CONSTINIT uint32_t
- gNumNormalOrHighPriorityQueuesHaveTaskScheduledMainThread = 0;
+constinit uint32_t gNumNormalOrHighPriorityQueuesHaveTaskScheduledMainThread =
+ 0;
NS_IMETHODIMP WebTaskMainThreadRunnable::Run() {
if (mScheduler) {