From 7f577e2b3aaba84e56be0290b8cc7bcfaf091e28 Mon Sep 17 00:00:00 2001 From: roytam1 Date: Thu, 18 Jan 2024 11:50:00 +0800 Subject: [PATCH] import from UXP: Issue #2452 - Fix getter constness (458f5eb3) --- xpcom/base/CycleCollectedJSContext.cpp | 4 +++- xpcom/base/CycleCollectedJSContext.h | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp index 220775d1a..12456b3bf 100644 --- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -1421,6 +1421,8 @@ CycleCollectedJSContext::ProcessStableStateQueue() MOZ_RELEASE_ASSERT(!mDoingStableStates); mDoingStableStates = true; + // When run, one event can add another event to the mStableStateEvents, as + // such you can't use iterators here. for (uint32_t i = 0; i < mStableStateEvents.Length(); ++i) { nsCOMPtr event = mStableStateEvents[i].forget(); event->Run(); @@ -1508,7 +1510,7 @@ CycleCollectedJSContext::AfterProcessMicrotasks() } uint32_t -CycleCollectedJSContext::RecursionDepth() +CycleCollectedJSContext::RecursionDepth() const { return mOwningThread->RecursionDepth(); } diff --git a/xpcom/base/CycleCollectedJSContext.h b/xpcom/base/CycleCollectedJSContext.h index 9faa16671..b312a689f 100644 --- a/xpcom/base/CycleCollectedJSContext.h +++ b/xpcom/base/CycleCollectedJSContext.h @@ -364,7 +364,7 @@ public: virtual void BeforeProcessTask(bool aMightBlock); virtual void AfterProcessTask(uint32_t aRecursionDepth); - uint32_t RecursionDepth(); + uint32_t RecursionDepth() const; // Run in stable state (call through nsContentUtils) void RunInStableState(already_AddRefed&& aRunnable); @@ -404,12 +404,12 @@ public: } } - bool IsInMicroTask() + bool IsInMicroTask() const { return mMicroTaskLevel != 0; } - uint32_t MicroTaskLevel() + uint32_t MicroTaskLevel() const { return mMicroTaskLevel; } @@ -423,7 +423,7 @@ public: void PerformDebuggerMicroTaskCheckpoint(); - bool IsInStableOrMetaStableState() + bool IsInStableOrMetaStableState() const { return mDoingStableStates; }