tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 963d609160cd35102db07fccd3c369b2b7b12a42
parent 9c8a09d9bed5bd44b21b3b99cb86e3f0a8535375
Author: serge-sans-paille <sguelton@mozilla.com>
Date:   Wed,  5 Nov 2025 18:43:17 +0000

Bug 1997864 - Make RefPtr constinit-compatible and use MOZ_CONSTINIT accordingly r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D271020

Diffstat:
Mdom/fs/test/gtest/parent/TestFileSystemOriginInitialization.cpp | 5++++-
Mdom/media/gtest/TestMediaDataDecoder.cpp | 4++--
Mgfx/gl/GLContextProviderCGL.mm | 2+-
Mgfx/gl/GLContextProviderEAGL.mm | 2+-
Mgfx/layers/GLImages.cpp | 2+-
Mgfx/layers/d3d11/FenceD3D11.cpp | 2+-
Mgfx/thebes/gfxFontMissingGlyphs.cpp | 2+-
Mhal/windows/WindowsSensor.cpp | 2+-
Mmfbt/RefPtr.h | 2+-
Mtoolkit/components/places/tests/gtest/test_IHistory.cpp | 2+-
Mtoolkit/xre/nsAppRunner.cpp | 4++--
Mwidget/gtk/DMABufSurface.cpp | 2+-
Mxpcom/tests/gtest/TestHandleWatcher.cpp | 3+--
13 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/dom/fs/test/gtest/parent/TestFileSystemOriginInitialization.cpp b/dom/fs/test/gtest/parent/TestFileSystemOriginInitialization.cpp @@ -111,9 +111,12 @@ class TestFileSystemOriginInitialization : public FileSystemParentTest { FileSystemQuotaClientFactory::SetCustomFactory(nullptr); } - MOZ_RUNINIT static inline RefPtr<MockFileSystemQuotaClient> sQuotaClient; + static RefPtr<MockFileSystemQuotaClient> sQuotaClient; }; +MOZ_CONSTINIT RefPtr<MockFileSystemQuotaClient> + TestFileSystemOriginInitialization::sQuotaClient; + TEST_F(TestFileSystemOriginInitialization, EmptyOriginDirectory) { ASSERT_NO_FATAL_FAILURE(ShutdownStorage()); diff --git a/dom/media/gtest/TestMediaDataDecoder.cpp b/dom/media/gtest/TestMediaDataDecoder.cpp @@ -43,8 +43,8 @@ class PropertyTest : public ::testing::TestWithParam<ParamType> { static UniquePtr<VideoInfo> sAVCInfo; static UniquePtr<VideoInfo> sVP9Info; }; -MOZ_RUNINIT RefPtr<PDMFactory> PropertyTest::sFactory; -MOZ_RUNINIT RefPtr<TaskQueue> PropertyTest::sTaskQueue; +MOZ_CONSTINIT RefPtr<PDMFactory> PropertyTest::sFactory; +MOZ_CONSTINIT RefPtr<TaskQueue> PropertyTest::sTaskQueue; MOZ_CONSTINIT UniquePtr<VideoInfo> PropertyTest::sAVCInfo; MOZ_CONSTINIT UniquePtr<VideoInfo> PropertyTest::sVP9Info; diff --git a/gfx/gl/GLContextProviderCGL.mm b/gfx/gl/GLContextProviderCGL.mm @@ -342,7 +342,7 @@ already_AddRefed<GLContext> GLContextProviderCGL::CreateHeadless( return gl.forget(); } -MOZ_RUNINIT static RefPtr<GLContext> gGlobalContext; +MOZ_CONSTINIT static RefPtr<GLContext> gGlobalContext; GLContext* GLContextProviderCGL::GetGlobalContext() { static bool triedToCreateContext = false; diff --git a/gfx/gl/GLContextProviderEAGL.mm b/gfx/gl/GLContextProviderEAGL.mm @@ -142,7 +142,7 @@ already_AddRefed<GLContext> GLContextProviderEAGL::CreateHeadless( return CreateEAGLContext(desc, GetGlobalContextEAGL()).forget(); } -MOZ_RUNINIT static RefPtr<GLContext> gGlobalContext; +MOZ_CONSTINIT static RefPtr<GLContext> gGlobalContext; GLContext* GLContextProviderEAGL::GetGlobalContext() { static bool triedToCreateContext = false; diff --git a/gfx/layers/GLImages.cpp b/gfx/layers/GLImages.cpp @@ -20,7 +20,7 @@ using namespace mozilla::gl; namespace mozilla::layers { -MOZ_RUNINIT static RefPtr<GLContext> sSnapshotContext; +MOZ_CONSTINIT static RefPtr<GLContext> sSnapshotContext; nsresult GLImage::ReadIntoBuffer(uint8_t* aData, int32_t aStride, const gfx::IntSize& aSize, diff --git a/gfx/layers/d3d11/FenceD3D11.cpp b/gfx/layers/d3d11/FenceD3D11.cpp @@ -16,7 +16,7 @@ namespace mozilla { namespace layers { -MOZ_RUNINIT RefPtr<ID3D11Device> mDevice; +MOZ_CONSTINIT RefPtr<ID3D11Device> mDevice; /* static */ RefPtr<FenceD3D11> FenceD3D11::Create(ID3D11Device* aDevice) { diff --git a/gfx/thebes/gfxFontMissingGlyphs.cpp b/gfx/thebes/gfxFontMissingGlyphs.cpp @@ -200,7 +200,7 @@ static void DestroyImageKey(void* aClosure) { delete key; } -MOZ_RUNINIT static RefPtr<SourceSurface> gWRGlyphAtlas[8]; +MOZ_CONSTINIT static RefPtr<SourceSurface> gWRGlyphAtlas[8]; MOZ_RUNINIT static LinkedList<WRUserData> gWRUsers; UserDataKey WRUserData::sWRUserDataKey; diff --git a/hal/windows/WindowsSensor.cpp b/hal/windows/WindowsSensor.cpp @@ -16,7 +16,7 @@ using namespace mozilla::hal; namespace mozilla { namespace hal_impl { -MOZ_RUNINIT static RefPtr<ISensor> sAccelerometer; +MOZ_CONSTINIT static RefPtr<ISensor> sAccelerometer; class SensorEvent final : public ISensorEvents { public: diff --git a/mfbt/RefPtr.h b/mfbt/RefPtr.h @@ -109,7 +109,7 @@ class MOZ_IS_REFPTR RefPtr { } } - MOZ_IMPLICIT RefPtr(decltype(nullptr)) : mRawPtr(nullptr) {} + MOZ_IMPLICIT constexpr RefPtr(std::nullptr_t) : mRawPtr(nullptr) {} template <typename I, typename = std::enable_if_t<std::is_convertible_v<I*, T*>>> diff --git a/toolkit/components/places/tests/gtest/test_IHistory.cpp b/toolkit/components/places/tests/gtest/test_IHistory.cpp @@ -122,7 +122,7 @@ void test_wait_checkpoint() { // sets the nsCOMPtr's to nullptr, freeing the reference. namespace test_unvisited_does_not_notify { MOZ_RUNINIT nsCOMPtr<nsIURI> testURI; -MOZ_RUNINIT RefPtr<mock_Link> testLink; +MOZ_CONSTINIT RefPtr<mock_Link> testLink; } // namespace test_unvisited_does_not_notify void test_unvisited_does_not_notify_part1() { using namespace test_unvisited_does_not_notify; diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp @@ -312,8 +312,8 @@ extern const char gToolkitBuildID[]; static nsIProfileLock* gProfileLock; #if defined(MOZ_HAS_REMOTE) -MOZ_RUNINIT static RefPtr<nsRemoteService> gRemoteService; -MOZ_RUNINIT static RefPtr<nsStartupLock> gStartupLock; +MOZ_CONSTINIT static RefPtr<nsRemoteService> gRemoteService; +MOZ_CONSTINIT static RefPtr<nsStartupLock> gStartupLock; #endif int gRestartArgc; diff --git a/widget/gtk/DMABufSurface.cpp b/widget/gtk/DMABufSurface.cpp @@ -131,7 +131,7 @@ static const std::string FormatEGLError(EGLint err) { } } -MOZ_RUNINIT static RefPtr<GLContext> sSnapshotContext; +MOZ_CONSTINIT static RefPtr<GLContext> sSnapshotContext; static StaticMutex sSnapshotContextMutex MOZ_UNANNOTATED; MOZ_RUNINIT static Atomic<int> gNewSurfaceUID(getpid()); /* Memory reporter stuff */ diff --git a/xpcom/tests/gtest/TestHandleWatcher.cpp b/xpcom/tests/gtest/TestHandleWatcher.cpp @@ -113,8 +113,7 @@ class TestHandleWatcher : public testing::Test { /* static */ bool TestHandleWatcher::sIsLive = false; /* static */ -MOZ_RUNINIT RefPtr<mozilla::SharedThreadPool> TestHandleWatcher::sPool = - nullptr; +MOZ_CONSTINIT RefPtr<mozilla::SharedThreadPool> TestHandleWatcher::sPool; /////////////////////////////////////////////////////////////////////// // WindowsEventObject