Bug 1920718 - Annotate all global variable with runtime initialization attributes r=glandium,application-update-reviewers,media-playback-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,gfx-reviewers,aosmond,lina,nalexander,aabh,geckoview-reviewers,win-reviewers,gstoll,m_kato

MOZ_RUNINIT => initialized at runtime
MOZ_CONSTINIT => initialized at compile time
MOZ_GLOBINIT => initialized either at runtime or compile time, depending on template parameter, macro parameter etc
This annotation is only understood by our clang-tidy plugin. It has no
effect on regular compilation.

Differential Revision: https://phabricator.services.mozilla.com/D223341
This commit is contained in:
serge-sans-paille 2024-10-30 11:05:24 +00:00
parent 793bb2cd41
commit 8a0a0f7524
290 changed files with 922 additions and 793 deletions

View File

@ -19,7 +19,7 @@
using namespace mozilla;
using namespace mozilla::a11y;
static nsTHashMap<nsStringHashKey, nsString> sLocalizedStrings;
MOZ_RUNINIT static nsTHashMap<nsStringHashKey, nsString> sLocalizedStrings;
void a11y::PlatformInit() {
nsresult rv = NS_OK;

View File

@ -1498,7 +1498,7 @@ LocalAccessible* nsAccessibilityService::CreateAccessible(
# include "mozilla/Monitor.h"
# include "mozilla/Maybe.h"
static Maybe<Monitor> sAndroidMonitor;
MOZ_RUNINIT static Maybe<Monitor> sAndroidMonitor;
mozilla::Monitor& nsAccessibilityService::GetAndroidMonitor() {
if (!sAndroidMonitor.isSome()) {

View File

@ -18,8 +18,8 @@ using namespace mozilla::a11y;
#define PREF_ACCESSIBILITY_MAC_DEBUG "accessibility.mac.debug"
static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
MOXTextMarkerDelegate*>
MOZ_RUNINIT static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
MOXTextMarkerDelegate*>
sDelegates;
@implementation MOXTextMarkerDelegate

View File

@ -411,7 +411,7 @@ struct RoleDescrMap {
const nsString description;
};
static const RoleDescrMap sRoleDescrMap[] = {
MOZ_RUNINIT static const RoleDescrMap sRoleDescrMap[] = {
{@"AXApplicationAlert", u"alert"_ns},
{@"AXApplicationAlertDialog", u"alertDialog"_ns},
{@"AXApplicationDialog", u"dialog"_ns},

View File

@ -45,7 +45,7 @@ static const GUID IID_MsaaAccessible = {
0x4afc,
{0xa3, 0x2c, 0xd6, 0xb5, 0xc0, 0x10, 0x04, 0x6b}};
MsaaIdGenerator MsaaAccessible::sIDGen;
MOZ_RUNINIT MsaaIdGenerator MsaaAccessible::sIDGen;
ITypeInfo* MsaaAccessible::gTypeInfo = nullptr;
/* static */

View File

@ -158,7 +158,7 @@ static bool IsArg(const char* arg, const char* s) {
return false;
}
Bootstrap::UniquePtr gBootstrap;
MOZ_RUNINIT Bootstrap::UniquePtr gBootstrap;
static int do_main(int argc, char* argv[], char* envp[]) {
// Allow firefox.exe to launch XULRunner apps via -app <application.ini>

View File

@ -78,8 +78,7 @@ class SafeThreadLocal final {
};
template <typename T>
MOZ_THREAD_LOCAL(T)
SafeThreadLocal<T>::sThreadLocal;
MOZ_GLOBINIT MOZ_THREAD_LOCAL(T) SafeThreadLocal<T>::sThreadLocal;
template <typename T>
T SafeThreadLocal<T>::sGlobal = nullptr;

View File

@ -289,9 +289,9 @@ static DynamicBlockList ConvertStaticBlocklistToDynamic(
return blockList;
}
const DynamicBlockList gFullList =
MOZ_RUNINIT const DynamicBlockList gFullList =
ConvertStaticBlocklistToDynamic(gWindowsDllBlocklist);
const DynamicBlockList gShortList =
MOZ_RUNINIT const DynamicBlockList gShortList =
ConvertStaticBlocklistToDynamic(kDllBlocklistShort);
static bool TestDependentModules() {

View File

@ -29,7 +29,7 @@ TEST_P(PrincipalAttributesTest, PrincipalAttributesTest) {
ASSERT_EQ(principal->GetIsIpAddress(), GetParam().expectIsIpAddress);
}
static const PrincipalAttributesParam kAttributes[] = {
MOZ_RUNINIT static const PrincipalAttributesParam kAttributes[] = {
{nsAutoCString("https://mozilla.com"), false},
{nsAutoCString("https://127.0.0.1"), true},
{nsAutoCString("https://[::1]"), true},

View File

@ -394,6 +394,11 @@ C/C++ practices
- One-argument constructors, that are not copy or move constructors,
should generally be marked explicit. Exceptions should be annotated
with ``MOZ_IMPLICIT``.
- Global variables with runtimle initialization should be avoided. Flagging
them as ``constexpr`` or ``MOZ_CONSTINIT`` is a good way to make sure the
initialization happens at compile-time. If runtime initialization cannot be
avoided, use the attribute ``MOZ_RUNINIT`` to identify those and tell the
linter to ignore that variable.
- Use ``char32_t`` as the return type or argument type of a method that
returns or takes as argument a single Unicode scalar value. (Don't
use UTF-32 strings, though.)

View File

@ -82,7 +82,7 @@ struct ListHelper {
LinkedList<nsSHistory> mList;
};
static ListHelper gSHistoryList;
MOZ_RUNINIT static ListHelper gSHistoryList;
// Max viewers allowed total, across all SHistory objects - negative default
// means we will calculate how many viewers to cache based on total memory
int32_t nsSHistory::sHistoryMaxTotalViewers = -1;

View File

@ -15,20 +15,25 @@
/* Globally initialized constants
*/
namespace mozilla {
const TimeDuration kOneMinute = TimeDuration::FromSeconds(60.0f);
const TimeDuration kCCDelay = TimeDuration::FromSeconds(6);
const TimeDuration kCCSkippableDelay = TimeDuration::FromMilliseconds(250);
const TimeDuration kTimeBetweenForgetSkippableCycles =
MOZ_RUNINIT const TimeDuration kOneMinute = TimeDuration::FromSeconds(60.0f);
MOZ_RUNINIT const TimeDuration kCCDelay = TimeDuration::FromSeconds(6);
MOZ_RUNINIT const TimeDuration kCCSkippableDelay =
TimeDuration::FromMilliseconds(250);
MOZ_RUNINIT const TimeDuration kTimeBetweenForgetSkippableCycles =
TimeDuration::FromSeconds(2);
const TimeDuration kForgetSkippableSliceDuration =
MOZ_RUNINIT const TimeDuration kForgetSkippableSliceDuration =
TimeDuration::FromMilliseconds(2);
const TimeDuration kICCIntersliceDelay = TimeDuration::FromMilliseconds(250);
const TimeDuration kICCSliceBudget = TimeDuration::FromMilliseconds(3);
const TimeDuration kIdleICCSliceBudget = TimeDuration::FromMilliseconds(2);
const TimeDuration kMaxICCDuration = TimeDuration::FromSeconds(2);
MOZ_RUNINIT const TimeDuration kICCIntersliceDelay =
TimeDuration::FromMilliseconds(250);
MOZ_RUNINIT const TimeDuration kICCSliceBudget =
TimeDuration::FromMilliseconds(3);
MOZ_RUNINIT const TimeDuration kIdleICCSliceBudget =
TimeDuration::FromMilliseconds(2);
MOZ_RUNINIT const TimeDuration kMaxICCDuration = TimeDuration::FromSeconds(2);
const TimeDuration kCCForced = kOneMinute * 2;
const TimeDuration kMaxCCLockedoutTime = TimeDuration::FromSeconds(30);
MOZ_RUNINIT const TimeDuration kCCForced = kOneMinute * 2;
MOZ_RUNINIT const TimeDuration kMaxCCLockedoutTime =
TimeDuration::FromSeconds(30);
} // namespace mozilla
/*

View File

@ -14785,7 +14785,7 @@ class PendingFullscreenChangeList {
};
/* static */
LinkedList<FullscreenChange> PendingFullscreenChangeList::sList;
MOZ_RUNINIT LinkedList<FullscreenChange> PendingFullscreenChangeList::sList;
size_t Document::CountFullscreenElements() const {
size_t count = 0;

View File

@ -89,7 +89,7 @@ struct ModifierKey final {
mLockable(aLockable) {}
};
static const ModifierKey kModifierKeys[] = {
MOZ_RUNINIT static const ModifierKey kModifierKeys[] = {
ModifierKey(MODIFIER_ALT, KEY_NAME_INDEX_Alt, false),
ModifierKey(MODIFIER_ALTGRAPH, KEY_NAME_INDEX_AltGraph, false),
ModifierKey(MODIFIER_CONTROL, KEY_NAME_INDEX_Control, false),

View File

@ -54,9 +54,10 @@ struct ListenerCollection {
};
template <class T>
StaticAutoPtr<FlaggedArray<T>> ListenerCollection<T>::gListeners;
MOZ_GLOBINIT StaticAutoPtr<FlaggedArray<T>> ListenerCollection<T>::gListeners;
template <class T>
StaticAutoPtr<FlaggedArray<T>> ListenerCollection<T>::gListenersToRemove;
MOZ_GLOBINIT StaticAutoPtr<FlaggedArray<T>>
ListenerCollection<T>::gListenersToRemove;
using JSListeners = ListenerCollection<RefPtr<PlacesEventCallback>>;
using WeakJSListeners = ListenerCollection<WeakPtr<PlacesWeakCallbackWrapper>>;
@ -66,7 +67,8 @@ 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.
static nsTArray<Sequence<OwningNonNull<PlacesEvent>>> gNotificationQueue;
MOZ_RUNINIT static nsTArray<Sequence<OwningNonNull<PlacesEvent>>>
gNotificationQueue;
uint32_t GetEventTypeFlag(PlacesEventType aEventType) {
if (aEventType == PlacesEventType::None) {

View File

@ -34,10 +34,10 @@ using mozilla::dom::Element;
using mozilla::dom::WindowContext;
// Reference to the pointer locked element.
static nsWeakPtr sLockedElement;
MOZ_RUNINIT static nsWeakPtr sLockedElement;
// Reference to the document which requested pointer lock.
static nsWeakPtr sLockedDoc;
MOZ_RUNINIT static nsWeakPtr sLockedDoc;
// Reference to the BrowserParent requested pointer lock.
static BrowserParent* sLockedRemoteTarget = nullptr;

View File

@ -13,7 +13,7 @@ namespace mozilla {
static TimeStamp gScrollingStartTime;
static TimeStamp gScrollingEndTime;
static uint32_t gScrollDistanceCSSPixels = 0;
static dom::InteractionData gScrollingInteraction = {};
MOZ_RUNINIT static dom::InteractionData gScrollingInteraction = {};
void ScrollingMetrics::OnScrollingInteractionEnded() {
// We are only interested in content process scrolling

View File

@ -22,7 +22,7 @@ using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::dom::ipc;
JS::PersistentRooted<JSObject*> global;
MOZ_RUNINIT JS::PersistentRooted<JSObject*> global;
static int FuzzingInitDomSC(int* argc, char*** argv) {
JSObject* simpleGlobal =

View File

@ -219,7 +219,7 @@ already_AddRefed<nsIRunnable> NativeInputRunnable::Create(
} // unnamed namespace
LinkedList<OldWindowSize> OldWindowSize::sList;
MOZ_RUNINIT LinkedList<OldWindowSize> OldWindowSize::sList;
NS_INTERFACE_MAP_BEGIN(nsDOMWindowUtils)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMWindowUtils)

View File

@ -11,11 +11,12 @@
using namespace mozilla;
static TimeDuration kOneSecond = TimeDuration::FromSeconds(1);
static TimeDuration kTenthSecond = TimeDuration::FromSeconds(0.1);
static TimeDuration kFrameDuration = TimeDuration::FromSeconds(1.0 / 60.0);
MOZ_RUNINIT static TimeDuration kOneSecond = TimeDuration::FromSeconds(1);
MOZ_RUNINIT static TimeDuration kTenthSecond = TimeDuration::FromSeconds(0.1);
MOZ_RUNINIT static TimeDuration kFrameDuration =
TimeDuration::FromSeconds(1.0 / 60.0);
static mozilla::TimeStamp sNow = TimeStamp::Now();
MOZ_RUNINIT static mozilla::TimeStamp sNow = TimeStamp::Now();
static mozilla::TimeStamp AdvanceTime(TimeDuration aDuration) {
sNow += aDuration;
@ -328,10 +329,10 @@ static bool BasicScenario(CCGCScheduler& aScheduler, TestGC* aTestGC,
return true;
}
static CCGCScheduler scheduler;
static TestGC gc(scheduler);
static TestIdleCC ccIdle(scheduler);
static TestNonIdleCC ccNonIdle(scheduler);
MOZ_RUNINIT static CCGCScheduler scheduler;
MOZ_RUNINIT static TestGC gc(scheduler);
MOZ_RUNINIT static TestIdleCC ccIdle(scheduler);
MOZ_RUNINIT static TestNonIdleCC ccNonIdle(scheduler);
TEST(TestScheduler, Idle)
{

View File

@ -2618,7 +2618,7 @@ class PropertyDefiner:
specType = "const " + specType
arrays = fill(
"""
static ${specType} ${name}_specs[] = {
MOZ_GLOBINIT static ${specType} ${name}_specs[] = {
${specs}
};

View File

@ -71,7 +71,7 @@ struct SetDOMProxyInformation {
}
};
SetDOMProxyInformation gSetDOMProxyInformation;
MOZ_RUNINIT SetDOMProxyInformation gSetDOMProxyInformation;
static inline void CheckExpandoObject(JSObject* proxy,
const JS::Value& expando) {

View File

@ -102,7 +102,7 @@ WebGLContextOptions::WebGLContextOptions() {
}
StaticMutex WebGLContext::sLruMutex;
std::list<WebGLContext*> WebGLContext::sLru;
MOZ_RUNINIT std::list<WebGLContext*> WebGLContext::sLru;
WebGLContext::LruPosition::LruPosition() {
StaticMutexAutoLock lock(sLruMutex);

View File

@ -85,8 +85,9 @@ static inline auto FindPtrOrNull(C& container, const K2& key) {
//////////////////////////////////////////////////////////////////////////////////////////
std::map<EffectiveFormat, const CompressedFormatInfo> gCompressedFormatInfoMap;
std::map<EffectiveFormat, FormatInfo> gFormatInfoMap;
MOZ_RUNINIT std::map<EffectiveFormat, const CompressedFormatInfo>
gCompressedFormatInfoMap;
MOZ_RUNINIT std::map<EffectiveFormat, FormatInfo> gFormatInfoMap;
static inline const CompressedFormatInfo* GetCompressedFormatInfo(
EffectiveFormat format) {

View File

@ -25,7 +25,7 @@
namespace mozilla {
namespace webgl {
/*static*/ const ImageInfo ImageInfo::kUndefined;
MOZ_RUNINIT /*static*/ const ImageInfo ImageInfo::kUndefined;
size_t ImageInfo::MemoryUsage() const {
if (!IsDefined()) return 0;

View File

@ -26,7 +26,7 @@
// Template taken from security/nss/lib/util/templates.c
// This (or SGN_EncodeDigestInfo) would ideally be exported
// by NSS and until that happens we have to keep our own copy.
const SEC_ASN1Template SGN_DigestInfoTemplate[] = {
MOZ_GLOBINIT const SEC_ASN1Template SGN_DigestInfoTemplate[] = {
{SEC_ASN1_SEQUENCE, 0, NULL, sizeof(SGNDigestInfo)},
{SEC_ASN1_INLINE, offsetof(SGNDigestInfo, digestAlgorithm),
SEC_ASN1_GET(SECOID_AlgorithmIDTemplate)},

View File

@ -142,12 +142,12 @@ static nsITimer* gUserInteractionTimer = nullptr;
static nsITimerCallback* gUserInteractionTimerCallback = nullptr;
static const double kCursorLoadingTimeout = 1000; // ms
static AutoWeakFrame gLastCursorSourceFrame;
MOZ_RUNINIT static AutoWeakFrame gLastCursorSourceFrame;
static TimeStamp gLastCursorUpdateTime;
static TimeStamp gTypingStartTime;
static TimeStamp gTypingEndTime;
static int32_t gTypingInteractionKeyPresses = 0;
static dom::InteractionData gTypingInteraction = {};
MOZ_RUNINIT static dom::InteractionData gTypingInteraction = {};
static inline int32_t RoundDown(double aDouble) {
return (aDouble > 0) ? static_cast<int32_t>(floor(aDouble))
@ -559,14 +559,14 @@ bool EventStateManager::sNormalLMouseEventInProcess = false;
int16_t EventStateManager::sCurrentMouseBtn = MouseButton::eNotPressed;
EventStateManager* EventStateManager::sActiveESM = nullptr;
EventStateManager* EventStateManager::sCursorSettingManager = nullptr;
AutoWeakFrame EventStateManager::sLastDragOverFrame = nullptr;
MOZ_RUNINIT AutoWeakFrame EventStateManager::sLastDragOverFrame = nullptr;
LayoutDeviceIntPoint EventStateManager::sPreLockScreenPoint =
LayoutDeviceIntPoint(0, 0);
LayoutDeviceIntPoint EventStateManager::sLastRefPoint = kInvalidRefPoint;
CSSIntPoint EventStateManager::sLastScreenPoint = CSSIntPoint(0, 0);
LayoutDeviceIntPoint EventStateManager::sSynthCenteringPoint = kInvalidRefPoint;
CSSIntPoint EventStateManager::sLastClientPoint = CSSIntPoint(0, 0);
nsCOMPtr<nsIContent> EventStateManager::sDragOverContent = nullptr;
MOZ_RUNINIT nsCOMPtr<nsIContent> EventStateManager::sDragOverContent = nullptr;
EventStateManager::WheelPrefs* EventStateManager::WheelPrefs::sInstance =
nullptr;

View File

@ -79,12 +79,12 @@ nsIWidget* IMEStateManager::sActiveInputContextWidget = nullptr;
StaticRefPtr<IMEContentObserver> IMEStateManager::sActiveIMEContentObserver;
TextCompositionArray* IMEStateManager::sTextCompositions = nullptr;
InputContext::Origin IMEStateManager::sOrigin = InputContext::ORIGIN_MAIN;
InputContext IMEStateManager::sActiveChildInputContext;
MOZ_RUNINIT InputContext IMEStateManager::sActiveChildInputContext;
bool IMEStateManager::sInstalledMenuKeyboardListener = false;
bool IMEStateManager::sIsGettingNewIMEState = false;
bool IMEStateManager::sCleaningUpForStoppingIMEStateManagement = false;
bool IMEStateManager::sIsActive = false;
Maybe<IMEStateManager::PendingFocusedBrowserSwitchingData>
MOZ_RUNINIT Maybe<IMEStateManager::PendingFocusedBrowserSwitchingData>
IMEStateManager::sPendingFocusedBrowserSwitchingData;
class PseudoFocusChangeRunnable : public Runnable {

View File

@ -49,7 +49,8 @@ NS_IMETHODIMP FetchParent::FetchParentCSPEventListener::OnCSPViolationEvent(
return NS_OK;
}
nsTHashMap<nsIDHashKey, RefPtr<FetchParent>> FetchParent::sActorTable;
MOZ_RUNINIT nsTHashMap<nsIDHashKey, RefPtr<FetchParent>>
FetchParent::sActorTable;
/*static*/
RefPtr<FetchParent> FetchParent::GetActorByID(const nsID& aID) {

View File

@ -655,7 +655,7 @@ class JSStreamConsumer final : public nsIInputStreamCallback,
NS_IMPL_ISUPPORTS(JSStreamConsumer, nsIInputStreamCallback)
// static
const nsCString FetchUtil::WasmAltDataType;
MOZ_RUNINIT const nsCString FetchUtil::WasmAltDataType;
// static
void FetchUtil::InitWasmAltDataType() {

View File

@ -111,7 +111,7 @@ class TestFileSystemOriginInitialization : public FileSystemParentTest {
FileSystemQuotaClientFactory::SetCustomFactory(nullptr);
}
static inline RefPtr<MockFileSystemQuotaClient> sQuotaClient;
MOZ_RUNINIT static inline RefPtr<MockFileSystemQuotaClient> sQuotaClient;
};
TEST_F(TestFileSystemOriginInitialization, EmptyOriginDirectory) {

View File

@ -100,7 +100,7 @@ class WindowsGamepadService;
// it will be created and destroyed by background thread and
// used by gMonitorThread
WindowsGamepadService* MOZ_NON_OWNING_REF gService = nullptr;
nsCOMPtr<nsIThread> gMonitorThread = nullptr;
MOZ_RUNINIT nsCOMPtr<nsIThread> gMonitorThread = nullptr;
static bool sIsShutdown = false;
class Gamepad {

View File

@ -255,7 +255,8 @@ class RequestingAccessKeyEventData {
static int32_t sBrowserParentCount;
};
int32_t RequestingAccessKeyEventData::sBrowserParentCount = 0;
Maybe<RequestingAccessKeyEventData::Data> RequestingAccessKeyEventData::sData;
MOZ_RUNINIT Maybe<RequestingAccessKeyEventData::Data>
RequestingAccessKeyEventData::sData;
namespace dom {

View File

@ -369,7 +369,8 @@ namespace dom {
LazyLogModule gProcessLog("Process");
static std::map<RemoteDecodeIn, media::MediaCodecsSupported> sCodecsSupported;
MOZ_RUNINIT static std::map<RemoteDecodeIn, media::MediaCodecsSupported>
sCodecsSupported;
/* static */
uint32_t ContentParent::sMaxContentProcesses = 0;

View File

@ -2802,7 +2802,7 @@ using PrivateDatastoreHashtable =
// event of an (unlikely) race where the private browsing windows are still
// being torn down, will cause the Datastore to be discarded when the last
// window actually goes away.
UniquePtr<PrivateDatastoreHashtable> gPrivateDatastores;
MOZ_RUNINIT UniquePtr<PrivateDatastoreHashtable> gPrivateDatastores;
using DatabaseArray = nsTArray<Database*>;

View File

@ -121,7 +121,7 @@ int sInCommunicationCount = 0;
const char kBrandBundleURL[] = "chrome://branding/locale/brand.properties";
std::unordered_map<std::string, LABELS_MEDIA_AUDIO_BACKEND>
MOZ_RUNINIT std::unordered_map<std::string, LABELS_MEDIA_AUDIO_BACKEND>
kTelemetryBackendLabel = {
{"audiounit", LABELS_MEDIA_AUDIO_BACKEND::audiounit},
{"audiounit-rust", LABELS_MEDIA_AUDIO_BACKEND::audiounit_rust},

View File

@ -130,7 +130,7 @@ class ProcessCrashMonitor final {
}
static inline StaticMutex sMutex;
static inline UniquePtr<ProcessCrashMonitor> sCrashMonitor;
static inline MOZ_RUNINIT UniquePtr<ProcessCrashMonitor> sCrashMonitor;
static inline Atomic<bool> sIsShutdown{false};
uint32_t mCrashNums;

View File

@ -12,7 +12,7 @@ using namespace mozilla;
using TracingPhase = mozilla::AsyncLogger::TracingPhase;
mozilla::AsyncLogger gAudioCallbackTraceLogger;
MOZ_RUNINIT mozilla::AsyncLogger gAudioCallbackTraceLogger;
static std::atomic<int> gTracingStarted(0);
void StartAudioCallbackTracing() {

View File

@ -19,7 +19,7 @@ struct B64Test {
bool shouldPass;
};
const B64Test tests[] = {
MOZ_RUNINIT const B64Test tests[] = {
{"AAAAADk4AU4AAAAAAAAAAA",
{0x0, 0x0, 0x0, 0x0, 0x39, 0x38, 0x1, 0x4e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0},

View File

@ -175,7 +175,7 @@ bool ChromiumCDMAdapter::Supports(int32_t aModuleVersion,
#ifdef XP_WIN
static WindowsDllInterceptor sKernel32Intercept;
MOZ_RUNINIT static WindowsDllInterceptor sKernel32Intercept;
typedef DWORD(WINAPI* QueryDosDeviceWFnPtr)(_In_opt_ LPCWSTR lpDeviceName,
_Out_ LPWSTR lpTargetPath,

View File

@ -40,12 +40,12 @@ using namespace mozilla;
static gfx::IntSize kImageSize(WIDTH, HEIGHT);
// Set codec to avc1.42001E - Base profile, constraint 0, level 30.
const H264Specific kH264SpecificAnnexB(H264_PROFILE_BASE,
H264_LEVEL::H264_LEVEL_3,
H264BitStreamFormat::ANNEXB);
const H264Specific kH264SpecificAVCC(H264_PROFILE_BASE,
H264_LEVEL::H264_LEVEL_3,
H264BitStreamFormat::AVC);
MOZ_RUNINIT const H264Specific kH264SpecificAnnexB(H264_PROFILE_BASE,
H264_LEVEL::H264_LEVEL_3,
H264BitStreamFormat::ANNEXB);
MOZ_RUNINIT const H264Specific kH264SpecificAVCC(H264_PROFILE_BASE,
H264_LEVEL::H264_LEVEL_3,
H264BitStreamFormat::AVC);
class MediaDataEncoderTest : public testing::Test {
protected:

View File

@ -90,11 +90,12 @@ DEFINE_PROPERTYKEY(EME_CONTENTDECRYPTIONMODULE_ORIGIN_ID, 0x1218a3e2, 0xcfb0,
} while (false)
StaticMutex sFactoryMutex;
static nsTHashMap<nsStringHashKey, ComPtr<IMFContentDecryptionModuleFactory>>
MOZ_RUNINIT static nsTHashMap<nsStringHashKey,
ComPtr<IMFContentDecryptionModuleFactory>>
sFactoryMap;
static CopyableTArray<MFCDMCapabilitiesIPDL> sCapabilities;
MOZ_RUNINIT static CopyableTArray<MFCDMCapabilitiesIPDL> sCapabilities;
StaticMutex sCapabilitesMutex;
static ComPtr<IUnknown> sMediaEngineClassFactory;
MOZ_RUNINIT static ComPtr<IUnknown> sMediaEngineClassFactory;
// RAIIized PROPVARIANT. See
// third_party/libwebrtc/modules/audio_device/win/core_audio_utility_win.h

View File

@ -133,7 +133,8 @@ class MFCDMParent final : public PMFCDMParent {
const RefPtr<RemoteDecoderManagerParent> mManager;
const RefPtr<nsISerialEventTarget> mManagerThread;
static inline nsTHashMap<nsUint64HashKey, MFCDMParent*> sRegisteredCDMs;
MOZ_RUNINIT static inline nsTHashMap<nsUint64HashKey, MFCDMParent*>
sRegisteredCDMs;
static inline uint64_t sNextId = 1;
const uint64_t mId;

View File

@ -57,7 +57,7 @@ static EnumeratedArray<RemoteDecodeIn, StaticRefPtr<GenericNonExclusivePromise>,
// Only modified on the main-thread, read on any thread. While it could be read
// on the main thread directly, for clarity we force access via the DataMutex
// wrapper.
static StaticDataMutex<StaticRefPtr<nsIThread>>
MOZ_RUNINIT static StaticDataMutex<StaticRefPtr<nsIThread>>
sRemoteDecoderManagerChildThread("sRemoteDecoderManagerChildThread");
// Only accessed from sRemoteDecoderManagerChildThread
@ -70,11 +70,9 @@ static StaticAutoPtr<nsTArray<RefPtr<Runnable>>> sRecreateTasks;
// Used for protecting codec support information collected from different remote
// processes.
StaticMutex sProcessSupportedMutex;
#ifndef MOZ_DEBUG
MOZ_CONSTINIT
#endif
static EnumeratedArray<RemoteDecodeIn, Maybe<media::MediaCodecsSupported>,
size_t(RemoteDecodeIn::SENTINEL)>
MOZ_GLOBINIT static EnumeratedArray<RemoteDecodeIn,
Maybe<media::MediaCodecsSupported>,
size_t(RemoteDecodeIn::SENTINEL)>
sProcessSupported MOZ_GUARDED_BY(sProcessSupportedMutex);
class ShutdownObserver final : public nsIObserver {

View File

@ -20,97 +20,98 @@ struct CurrentPlaybackPositionFixture {
class CurrentPlaybackPositionTest
: public testing::TestWithParam<CurrentPlaybackPositionFixture> {};
static const std::initializer_list<CurrentPlaybackPositionFixture> kFixtures = {
// position must be positive
{
10.0,
1.0,
0.0,
TimeDuration::FromSeconds(-1.0),
0.0,
},
// no time elapsed
{
10.0,
1.0,
0.0,
TimeDuration::FromSeconds(0.0),
0.0,
},
{
10.0,
1.0,
0.0,
TimeDuration::FromSeconds(3.0),
3.0,
},
{
10.0,
1.0,
0.0,
TimeDuration::FromSeconds(10.0),
10.0,
},
// position is clamped to the duration
{
10.0,
1.0,
0.0,
TimeDuration::FromSeconds(20.0),
10.0,
},
{
10.0,
1.0,
5.0,
TimeDuration::FromSeconds(-1.0),
4.0,
},
{
10.0,
1.0,
5.0,
TimeDuration::FromSeconds(-6.0),
0.0,
},
{
10.0,
1.0,
5.0,
TimeDuration::FromSeconds(6.0),
10.0,
},
// expected: 5s + 2 * 2s
{
10.0,
2.0,
5.0,
TimeDuration::FromSeconds(2.0),
9.0,
},
// expected: 5s + 0.5 * 2s
{
10.0,
0.5,
5.0,
TimeDuration::FromSeconds(2.0),
6.0,
},
{
5.0,
4.0,
10.0,
TimeDuration::FromSeconds(20.0),
5.0,
},
// empty media (0s)
{
0.0,
4.0,
5.0,
TimeDuration::FromSeconds(20.0),
0.0,
},
MOZ_RUNINIT static const std::initializer_list<CurrentPlaybackPositionFixture>
kFixtures = {
// position must be positive
{
10.0,
1.0,
0.0,
TimeDuration::FromSeconds(-1.0),
0.0,
},
// no time elapsed
{
10.0,
1.0,
0.0,
TimeDuration::FromSeconds(0.0),
0.0,
},
{
10.0,
1.0,
0.0,
TimeDuration::FromSeconds(3.0),
3.0,
},
{
10.0,
1.0,
0.0,
TimeDuration::FromSeconds(10.0),
10.0,
},
// position is clamped to the duration
{
10.0,
1.0,
0.0,
TimeDuration::FromSeconds(20.0),
10.0,
},
{
10.0,
1.0,
5.0,
TimeDuration::FromSeconds(-1.0),
4.0,
},
{
10.0,
1.0,
5.0,
TimeDuration::FromSeconds(-6.0),
0.0,
},
{
10.0,
1.0,
5.0,
TimeDuration::FromSeconds(6.0),
10.0,
},
// expected: 5s + 2 * 2s
{
10.0,
2.0,
5.0,
TimeDuration::FromSeconds(2.0),
9.0,
},
// expected: 5s + 0.5 * 2s
{
10.0,
0.5,
5.0,
TimeDuration::FromSeconds(2.0),
6.0,
},
{
5.0,
4.0,
10.0,
TimeDuration::FromSeconds(20.0),
5.0,
},
// empty media (0s)
{
0.0,
4.0,
5.0,
TimeDuration::FromSeconds(20.0),
0.0,
},
};
TEST_P(CurrentPlaybackPositionTest, Run) {

View File

@ -88,7 +88,8 @@ typedef mozilla::layers::PlanarYCbCrImage PlanarYCbCrImage;
namespace mozilla {
#ifdef MOZ_USE_HWDECODE
nsTArray<AVCodecID> FFmpegVideoDecoder<LIBAV_VER>::mAcceleratedFormats;
MOZ_RUNINIT nsTArray<AVCodecID>
FFmpegVideoDecoder<LIBAV_VER>::mAcceleratedFormats;
#endif
using media::TimeUnit;

View File

@ -139,7 +139,7 @@ class MediaFoundationInitializer final {
// WMF from threads with the same COM compartment model.
HRESULT MFShutdown();
static inline UniquePtr<MediaFoundationInitializer> sInitializer;
MOZ_RUNINIT static inline UniquePtr<MediaFoundationInitializer> sInitializer;
static inline StaticMutex sCreateMutex;
static inline Atomic<bool> sIsShutdown{false};
const bool mHasInitialized;

View File

@ -61,8 +61,9 @@ namespace mozilla {
using media::ShutdownBlockingTicket;
namespace camera {
std::map<uint32_t, const char*> sDeviceUniqueIDs;
std::map<uint32_t, webrtc::VideoCaptureCapability> sAllRequestedCapabilities;
MOZ_RUNINIT std::map<uint32_t, const char*> sDeviceUniqueIDs;
MOZ_RUNINIT std::map<uint32_t, webrtc::VideoCaptureCapability>
sAllRequestedCapabilities;
uint32_t ResolutionFeasibilityDistance(int32_t candidate, int32_t requested) {
// The purpose of this function is to find a smallest resolution

View File

@ -27,7 +27,7 @@ using namespace mozilla;
using namespace webrtc;
using namespace videocapturemodule;
static NSArray* camera_presets = @[
MOZ_RUNINIT static NSArray* camera_presets = @[
AVCaptureSessionPreset352x288, AVCaptureSessionPreset640x480,
AVCaptureSessionPreset1280x720
];

View File

@ -4846,6 +4846,6 @@ std::unique_ptr<NrSocketProxyConfig> PeerConnectionImpl::GetProxyConfig()
net::WebrtcProxyConfig(id, alpn, loadInfoArgs, mForceProxy)));
}
std::map<uint64_t, PeerConnectionAutoTimer>
MOZ_RUNINIT std::map<uint64_t, PeerConnectionAutoTimer>
PeerConnectionImpl::sCallDurationTimers;
} // namespace mozilla

View File

@ -67,7 +67,8 @@ class WebrtcContentParents {
static std::vector<RefPtr<WebrtcGlobalParent>> sContentParents;
};
std::vector<RefPtr<WebrtcGlobalParent>> WebrtcContentParents::sContentParents;
MOZ_RUNINIT std::vector<RefPtr<WebrtcGlobalParent>>
WebrtcContentParents::sContentParents;
WebrtcGlobalParent* WebrtcContentParents::Alloc() {
RefPtr<WebrtcGlobalParent> cp = new WebrtcGlobalParent;
@ -533,7 +534,7 @@ void WebrtcGlobalInformation::GetLogging(
}
static bool sLastAECDebug = false;
static Maybe<nsCString> sAecDebugLogDir;
MOZ_RUNINIT static Maybe<nsCString> sAecDebugLogDir;
void WebrtcGlobalInformation::SetAecDebug(const GlobalObject& aGlobal,
bool aEnable) {

View File

@ -17,7 +17,7 @@
namespace mozilla {
const std::string RsdparsaSdpAttributeList::kEmptyString = "";
MOZ_RUNINIT const std::string RsdparsaSdpAttributeList::kEmptyString = "";
RsdparsaSdpAttributeList::~RsdparsaSdpAttributeList() {
for (size_t i = 0; i < kNumAttributeTypes; ++i) {

View File

@ -18,7 +18,7 @@ namespace mozilla {
using InternalResults = SdpParser::InternalResults;
/* static */
const std::string SipccSdpAttributeList::kEmptyString = "";
MOZ_RUNINIT const std::string SipccSdpAttributeList::kEmptyString = "";
SipccSdpAttributeList::SipccSdpAttributeList(
const SipccSdpAttributeList* sessionLevel)

View File

@ -14,8 +14,8 @@
using namespace mozilla;
static mozilla::UniquePtr<SdpParser::Results> sdpPtr;
static SipccSdpParser mParser;
MOZ_RUNINIT static mozilla::UniquePtr<SdpParser::Results> sdpPtr;
MOZ_RUNINIT static SipccSdpParser mParser;
int FuzzingInitSdpParser(int* argc, char*** argv) { return 0; }

View File

@ -61,14 +61,14 @@ static unsigned int kDefaultTimeout = 7000;
// TODO: It would be nice to have a test STUN/TURN server that can run with
// gtest.
const std::string kDefaultStunServerHostname((char*)"");
const std::string kBogusStunServerHostname(
MOZ_RUNINIT const std::string kDefaultStunServerHostname((char*)"");
MOZ_RUNINIT const std::string kBogusStunServerHostname(
(char*)"stun-server-nonexistent.invalid");
const uint16_t kDefaultStunServerPort = 19305;
const std::string kBogusIceCandidate(
MOZ_RUNINIT const std::string kBogusIceCandidate(
(char*)"candidate:0 2 UDP 2113601790 192.168.178.20 50769 typ");
const std::string kUnreachableHostIceCandidate(
MOZ_RUNINIT const std::string kUnreachableHostIceCandidate(
(char*)"candidate:0 1 UDP 2113601790 192.168.178.20 50769 typ host");
namespace {

View File

@ -19,7 +19,8 @@
using namespace mozilla;
// update TestReadMultipleSizes if you change this
const std::string kHelloMessage = "HELLO IS IT ME YOU'RE LOOKING FOR?";
MOZ_RUNINIT const std::string kHelloMessage =
"HELLO IS IT ME YOU'RE LOOKING FOR?";
class NrTcpSocketTest : public MtransportTest {
public:

View File

@ -66,7 +66,7 @@ extern "C" {
using namespace mozilla;
static std::string kDummyTurnServer("192.0.2.1"); // From RFC 5737
MOZ_RUNINIT static std::string kDummyTurnServer("192.0.2.1"); // From RFC 5737
class TurnClient : public MtransportTest {
public:

View File

@ -19,7 +19,7 @@
static const uint32_t kDefaultTestTimeout = 2000;
static const char kReadData[] = "Hello, World!";
static const size_t kReadDataLength = sizeof(kReadData) - 1;
static const std::string kReadDataString =
MOZ_RUNINIT static const std::string kReadDataString =
std::string(kReadData, kReadDataLength);
static int kDataLargeOuterLoopCount = 128;
static int kDataLargeInnerLoopCount = 1024;

View File

@ -54,7 +54,8 @@ class SendRunnable : public MIDIBackgroundRunnable {
StaticMutex midirMIDIPlatformService::gOwnerThreadMutex;
// static
nsCOMPtr<nsISerialEventTarget> midirMIDIPlatformService::gOwnerThread;
MOZ_RUNINIT nsCOMPtr<nsISerialEventTarget>
midirMIDIPlatformService::gOwnerThread;
midirMIDIPlatformService::midirMIDIPlatformService()
: mImplementation(nullptr) {

View File

@ -159,7 +159,7 @@ void PromiseDebugging::GetFullfillmentStack(GlobalObject& aGlobal,
}
/*static */
nsString PromiseDebugging::sIDPrefix;
MOZ_RUNINIT nsString PromiseDebugging::sIDPrefix;
/* static */
void PromiseDebugging::Init() {

View File

@ -423,6 +423,7 @@ void QuotaManagerDependencyFixture::EnsureQuotaManager() {
[&resolver]() { return resolver->IsDone(); });
}
nsCOMPtr<nsISerialEventTarget> QuotaManagerDependencyFixture::sBackgroundTarget;
MOZ_RUNINIT nsCOMPtr<nsISerialEventTarget>
QuotaManagerDependencyFixture::sBackgroundTarget;
} // namespace mozilla::dom::quota::test

View File

@ -266,7 +266,8 @@ class DOM_Quota_EncryptedStream : public ::testing::Test {
struct NSSInitContextDeleter {
void operator()(NSSInitContext* p) { NSS_ShutdownContext(p); }
};
inline static std::unique_ptr<NSSInitContext, NSSInitContextDeleter>
MOZ_RUNINIT inline static std::unique_ptr<NSSInitContext,
NSSInitContextDeleter>
sNssContext;
};

View File

@ -183,7 +183,8 @@ class TestStorageConnection : public QuotaManagerDependencyFixture {
struct NSSInitContextDeleter {
void operator()(NSSInitContext* p) { NSS_ShutdownContext(p); }
};
inline static std::unique_ptr<NSSInitContext, NSSInitContextDeleter>
MOZ_RUNINIT inline static std::unique_ptr<NSSInitContext,
NSSInitContextDeleter>
sNssContext;
};

View File

@ -15,8 +15,8 @@
using namespace mozilla;
using namespace mozilla::dom;
static nsCOMPtr<nsIPrincipal> selfURIPrincipal;
static nsCOMPtr<nsIURI> selfURI;
MOZ_RUNINIT static nsCOMPtr<nsIPrincipal> selfURIPrincipal;
MOZ_RUNINIT static nsCOMPtr<nsIURI> selfURI;
static int LVVMFuzzerInitTest(int* argc, char*** argv) {
nsresult ret;

View File

@ -138,8 +138,8 @@ nsresult CreatePrincipalInfo(nsILineInputStream* aStream,
return NS_OK;
}
const IPCNavigationPreloadState gDefaultNavigationPreloadState(false,
"true"_ns);
MOZ_RUNINIT const IPCNavigationPreloadState
gDefaultNavigationPreloadState(false, "true"_ns);
} // namespace

View File

@ -13,8 +13,8 @@
namespace mozilla::dom {
static SVGAttrTearoffTable<SVGAnimatedTransformList,
DOMSVGAnimatedTransformList>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedTransformList,
DOMSVGAnimatedTransformList>
sSVGAnimatedTransformListTearoffTable;
NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGAnimatedTransformList,

View File

@ -22,7 +22,7 @@
namespace mozilla::dom {
static SVGAttrTearoffTable<SVGAnimatedLength, DOMSVGLength>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedLength, DOMSVGLength>
sBaseSVGLengthTearOffTable, sAnimSVGLengthTearOffTable;
// We could use NS_IMPL_CYCLE_COLLECTION(, except that in Unlink() we need to

View File

@ -37,7 +37,8 @@ class MOZ_RAII AutoChangePointNotifier {
DOMSVGPoint* const mValue;
};
static SVGAttrTearoffTable<SVGPoint, DOMSVGPoint> sSVGTranslateTearOffTable;
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGPoint, DOMSVGPoint>
sSVGTranslateTearOffTable;
// We could use NS_IMPL_CYCLE_COLLECTION(, except that in Unlink() we need to
// clear our list's weak ref to us to be safe. (The other option would be to

View File

@ -11,7 +11,8 @@
namespace mozilla {
static SVGAttrTearoffTable<SVGAnimatedClassOrString, dom::DOMSVGAnimatedString>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedClassOrString,
dom::DOMSVGAnimatedString>
sSVGAnimatedClassOrStringTearoffTable;
already_AddRefed<dom::DOMSVGAnimatedString>

View File

@ -44,8 +44,8 @@ class MOZ_RAII AutoChangeEnumNotifier {
bool mDoSetAttr;
};
static SVGAttrTearoffTable<SVGAnimatedEnumeration,
SVGAnimatedEnumeration::DOMAnimatedEnum>
MOZ_CONSTINIT static SVGAttrTearoffTable<
SVGAnimatedEnumeration, SVGAnimatedEnumeration::DOMAnimatedEnum>
sSVGAnimatedEnumTearoffTable;
const SVGEnumMapping* SVGAnimatedEnumeration::GetMapping(

View File

@ -45,8 +45,8 @@ class MOZ_RAII AutoChangeIntegerNotifier {
bool mDoSetAttr;
};
static SVGAttrTearoffTable<SVGAnimatedInteger,
SVGAnimatedInteger::DOMAnimatedInteger>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedInteger,
SVGAnimatedInteger::DOMAnimatedInteger>
sSVGAnimatedIntegerTearoffTable;
nsresult SVGAnimatedInteger::SetBaseValueString(const nsAString& aValueAsString,

View File

@ -58,11 +58,11 @@ class MOZ_RAII AutoChangeIntegerPairNotifier {
bool mDoSetAttr;
};
static SVGAttrTearoffTable<SVGAnimatedIntegerPair,
SVGAnimatedIntegerPair::DOMAnimatedInteger>
MOZ_CONSTINIT static SVGAttrTearoffTable<
SVGAnimatedIntegerPair, SVGAnimatedIntegerPair::DOMAnimatedInteger>
sSVGFirstAnimatedIntegerTearoffTable;
static SVGAttrTearoffTable<SVGAnimatedIntegerPair,
SVGAnimatedIntegerPair::DOMAnimatedInteger>
MOZ_CONSTINIT static SVGAttrTearoffTable<
SVGAnimatedIntegerPair, SVGAnimatedIntegerPair::DOMAnimatedInteger>
sSVGSecondAnimatedIntegerTearoffTable;
/* Implementation */

View File

@ -68,7 +68,8 @@ class MOZ_RAII AutoChangeLengthNotifier {
bool mDoSetAttr;
};
static SVGAttrTearoffTable<SVGAnimatedLength, DOMSVGAnimatedLength>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedLength,
DOMSVGAnimatedLength>
sSVGAnimatedLengthTearoffTable;
/* Helper functions */

View File

@ -42,8 +42,8 @@ class MOZ_RAII AutoChangeNumberNotifier {
SVGElement* const mSVGElement;
};
static SVGAttrTearoffTable<SVGAnimatedNumber,
SVGAnimatedNumber::DOMAnimatedNumber>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedNumber,
SVGAnimatedNumber::DOMAnimatedNumber>
sSVGAnimatedNumberTearoffTable;
static bool GetValueFromString(const nsAString& aString,

View File

@ -54,11 +54,11 @@ class MOZ_RAII AutoChangeNumberPairNotifier {
bool mDoSetAttr;
};
static SVGAttrTearoffTable<SVGAnimatedNumberPair,
SVGAnimatedNumberPair::DOMAnimatedNumber>
MOZ_CONSTINIT static SVGAttrTearoffTable<
SVGAnimatedNumberPair, SVGAnimatedNumberPair::DOMAnimatedNumber>
sSVGFirstAnimatedNumberTearoffTable;
static SVGAttrTearoffTable<SVGAnimatedNumberPair,
SVGAnimatedNumberPair::DOMAnimatedNumber>
MOZ_CONSTINIT static SVGAttrTearoffTable<
SVGAnimatedNumberPair, SVGAnimatedNumberPair::DOMAnimatedNumber>
sSVGSecondAnimatedNumberTearoffTable;
static nsresult ParseNumberOptionalNumber(const nsAString& aValue,

View File

@ -27,13 +27,14 @@ using namespace mozilla::dom::SVGMarkerElement_Binding;
namespace mozilla {
static SVGAttrTearoffTable<SVGAnimatedOrient, DOMSVGAnimatedEnumeration>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedOrient,
DOMSVGAnimatedEnumeration>
sSVGAnimatedEnumTearoffTable;
static SVGAttrTearoffTable<SVGAnimatedOrient, DOMSVGAnimatedAngle>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedOrient, DOMSVGAnimatedAngle>
sSVGAnimatedAngleTearoffTable;
static SVGAttrTearoffTable<SVGAnimatedOrient, DOMSVGAngle>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedOrient, DOMSVGAngle>
sBaseSVGAngleTearoffTable;
static SVGAttrTearoffTable<SVGAnimatedOrient, DOMSVGAngle>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedOrient, DOMSVGAngle>
sAnimSVGAngleTearoffTable;
/* Helper functions */

View File

@ -70,14 +70,14 @@ class MOZ_RAII AutoChangePreserveAspectRatioNotifier {
bool mDoSetAttr;
};
static SVGAttrTearoffTable<SVGAnimatedPreserveAspectRatio,
DOMSVGAnimatedPreserveAspectRatio>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedPreserveAspectRatio,
DOMSVGAnimatedPreserveAspectRatio>
sSVGAnimatedPAspectRatioTearoffTable;
static SVGAttrTearoffTable<SVGAnimatedPreserveAspectRatio,
DOMSVGPreserveAspectRatio>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedPreserveAspectRatio,
DOMSVGPreserveAspectRatio>
sBaseSVGPAspectRatioTearoffTable;
static SVGAttrTearoffTable<SVGAnimatedPreserveAspectRatio,
DOMSVGPreserveAspectRatio>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedPreserveAspectRatio,
DOMSVGPreserveAspectRatio>
sAnimSVGPAspectRatioTearoffTable;
already_AddRefed<DOMSVGPreserveAspectRatio>

View File

@ -66,11 +66,11 @@ nsresult SVGViewBox::FromString(const nsAString& aStr, SVGViewBox* aViewBox) {
return NS_OK;
}
static SVGAttrTearoffTable<SVGAnimatedViewBox, SVGRect>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedViewBox, SVGRect>
sBaseSVGViewBoxTearoffTable;
static SVGAttrTearoffTable<SVGAnimatedViewBox, SVGRect>
MOZ_CONSTINIT static SVGAttrTearoffTable<SVGAnimatedViewBox, SVGRect>
sAnimSVGViewBoxTearoffTable;
SVGAttrTearoffTable<SVGAnimatedViewBox, SVGAnimatedRect>
MOZ_CONSTINIT SVGAttrTearoffTable<SVGAnimatedViewBox, SVGAnimatedRect>
SVGAnimatedViewBox::sSVGAnimatedRectTearoffTable;
//----------------------------------------------------------------------

View File

@ -301,7 +301,7 @@ static void AssertParentProcessWithCallerLocation(GlobalObject& aGlobal) {
// IOUtils implementation
/* static */
IOUtils::StateMutex IOUtils::sState{"IOUtils::sState"};
MOZ_RUNINIT IOUtils::StateMutex IOUtils::sState{"IOUtils::sState"};
/* static */
template <typename Fn>

View File

@ -90,8 +90,8 @@ nsresult PathUtils::InitFileWithPath(nsIFile* aFile, const nsAString& aPath) {
return aFile->InitWithPath(aPath);
}
StaticDataMutex<Maybe<PathUtils::DirectoryCache>> PathUtils::sDirCache{
"sDirCache"};
MOZ_RUNINIT StaticDataMutex<Maybe<PathUtils::DirectoryCache>>
PathUtils::sDirCache{"sDirCache"};
/**
* Return the leaf name, including leading path separators in the case of

View File

@ -29,8 +29,9 @@
using namespace mozilla;
static const CLLocationAccuracy kHIGH_ACCURACY = kCLLocationAccuracyBest;
static const CLLocationAccuracy kDEFAULT_ACCURACY =
MOZ_RUNINIT static const CLLocationAccuracy kHIGH_ACCURACY =
kCLLocationAccuracyBest;
MOZ_RUNINIT static const CLLocationAccuracy kDEFAULT_ACCURACY =
kCLLocationAccuracyNearestTenMeters;
@interface LocationDelegate : NSObject <CLLocationManagerDelegate> {

View File

@ -135,25 +135,27 @@ HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
Text& aContentToInsert, const EditorDOMPoint& aPointToInsert,
SplitAtEdges aSplitAtEdges);
HTMLEditor::InitializeInsertingElement HTMLEditor::DoNothingForNewElement =
[](HTMLEditor&, Element&, const EditorDOMPoint&) { return NS_OK; };
MOZ_RUNINIT HTMLEditor::InitializeInsertingElement
HTMLEditor::DoNothingForNewElement =
[](HTMLEditor&, Element&, const EditorDOMPoint&) { return NS_OK; };
HTMLEditor::InitializeInsertingElement HTMLEditor::InsertNewBRElement =
[](HTMLEditor& aHTMLEditor, Element& aNewElement, const EditorDOMPoint&)
MOZ_CAN_RUN_SCRIPT_BOUNDARY {
MOZ_ASSERT(!aNewElement.IsInComposedDoc());
Result<CreateElementResult, nsresult> createBRElementResult =
aHTMLEditor.InsertBRElement(WithTransaction::No,
EditorDOMPoint(&aNewElement, 0u));
if (MOZ_UNLIKELY(createBRElementResult.isErr())) {
NS_WARNING_ASSERTION(
createBRElementResult.isOk(),
"HTMLEditor::InsertBRElement(WithTransaction::No) failed");
return createBRElementResult.unwrapErr();
}
createBRElementResult.unwrap().IgnoreCaretPointSuggestion();
return NS_OK;
};
MOZ_RUNINIT HTMLEditor::InitializeInsertingElement
HTMLEditor::InsertNewBRElement =
[](HTMLEditor& aHTMLEditor, Element& aNewElement, const EditorDOMPoint&)
MOZ_CAN_RUN_SCRIPT_BOUNDARY {
MOZ_ASSERT(!aNewElement.IsInComposedDoc());
Result<CreateElementResult, nsresult> createBRElementResult =
aHTMLEditor.InsertBRElement(WithTransaction::No,
EditorDOMPoint(&aNewElement, 0u));
if (MOZ_UNLIKELY(createBRElementResult.isErr())) {
NS_WARNING_ASSERTION(
createBRElementResult.isOk(),
"HTMLEditor::InsertBRElement(WithTransaction::No) failed");
return createBRElementResult.unwrapErr();
}
createBRElementResult.unwrap().IgnoreCaretPointSuggestion();
return NS_OK;
};
// static
Result<CreateElementResult, nsresult>
@ -186,25 +188,27 @@ HTMLEditor::AppendNewElementWithBRToInsertingElement(
return createNewElementWithBRResult;
}
HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributes =
MOZ_RUNINIT HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributes =
[](HTMLEditor&, const Element&, const Element&, int32_t, const nsAtom&,
nsString&) { return true; };
HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributesExceptId =
MOZ_RUNINIT HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributesExceptId =
[](HTMLEditor&, const Element&, const Element&, int32_t aNamespaceID,
const nsAtom& aAttrName, nsString&) {
return aNamespaceID != kNameSpaceID_None || &aAttrName != nsGkAtoms::id;
};
HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributesExceptDir =
MOZ_RUNINIT HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributesExceptDir =
[](HTMLEditor&, const Element&, const Element&, int32_t aNamespaceID,
const nsAtom& aAttrName, nsString&) {
return aNamespaceID != kNameSpaceID_None || &aAttrName != nsGkAtoms::dir;
};
HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributesExceptIdAndDir =
[](HTMLEditor&, const Element&, const Element&, int32_t aNamespaceID,
const nsAtom& aAttrName, nsString&) {
return !(aNamespaceID == kNameSpaceID_None &&
(&aAttrName == nsGkAtoms::id || &aAttrName == nsGkAtoms::dir));
};
MOZ_RUNINIT HTMLEditor::AttributeFilter
HTMLEditor::CopyAllAttributesExceptIdAndDir =
[](HTMLEditor&, const Element&, const Element&, int32_t aNamespaceID,
const nsAtom& aAttrName, nsString&) {
return !(
aNamespaceID == kNameSpaceID_None &&
(&aAttrName == nsGkAtoms::id || &aAttrName == nsGkAtoms::dir));
};
HTMLEditor::HTMLEditor(const Document& aDocument)
: EditorBase(EditorBase::EditorType::HTML),

View File

@ -30,8 +30,8 @@ using mozilla::dom::AutoJSAPI;
//*****************************************************************************
static JS::PersistentRooted<JSObject*> autoconfigSystemSb;
static JS::PersistentRooted<JSObject*> autoconfigSb;
MOZ_RUNINIT static JS::PersistentRooted<JSObject*> autoconfigSystemSb;
MOZ_RUNINIT static JS::PersistentRooted<JSObject*> autoconfigSb;
bool sandboxEnabled;
nsresult CentralizedAdminPrefManagerInit(bool aSandboxEnabled) {

View File

@ -77,10 +77,10 @@ uint32_t mozHunspellCallbacks::sCurrentFreshId = 0;
/* static */
mozilla::StaticRWLock mozHunspellCallbacks::sFileMgrMapLock;
/* static */
std::map<uint32_t, std::unique_ptr<mozHunspellFileMgrHost>>
MOZ_RUNINIT std::map<uint32_t, std::unique_ptr<mozHunspellFileMgrHost>>
mozHunspellCallbacks::sFileMgrMap;
/* static */
std::set<nsCString> mozHunspellCallbacks::sFileMgrAllowList;
MOZ_RUNINIT std::set<nsCString> mozHunspellCallbacks::sFileMgrAllowList;
/* static */
void mozHunspellCallbacks::AllowFile(const nsCString& aFilename) {

View File

@ -21,10 +21,10 @@ static Atomic<DWRITE_PIXEL_GEOMETRY> sPixelGeometry;
static Atomic<DWRITE_RENDERING_MODE> sRenderingMode;
static Atomic<DWRITE_MEASURING_MODE> sMeasuringMode;
static std::atomic<Float> sGDIGamma{1.4f};
StaticDataMutex<StaticRefPtr<IDWriteRenderingParams>> sStandardRenderingParams(
"StandardRenderingParams");
StaticDataMutex<StaticRefPtr<IDWriteRenderingParams>> sGDIRenderingParams(
"GDIRenderingParams");
MOZ_RUNINIT StaticDataMutex<StaticRefPtr<IDWriteRenderingParams>>
sStandardRenderingParams("StandardRenderingParams");
MOZ_RUNINIT StaticDataMutex<StaticRefPtr<IDWriteRenderingParams>>
sGDIRenderingParams("GDIRenderingParams");
static void ClearStandardRenderingParams() {
auto lockedParams = sStandardRenderingParams.Lock();

View File

@ -34,7 +34,7 @@ uint64_t DrawTargetD2D1::mVRAMUsageDT;
uint64_t DrawTargetD2D1::mVRAMUsageSS;
StaticRefPtr<ID2D1Factory1> DrawTargetD2D1::mFactory;
const D2D1_MATRIX_5X4_F kLuminanceMatrix =
MOZ_RUNINIT const D2D1_MATRIX_5X4_F kLuminanceMatrix =
D2D1::Matrix5x4F(0, 0, 0, 0.2125f, 0, 0, 0, 0.7154f, 0, 0, 0, 0.0721f, 0, 0,
0, 0, 0, 0, 0, 0);

View File

@ -19,7 +19,8 @@ namespace gfx {
static StaticMutex sFontFileStreamsMutex MOZ_UNANNOTATED;
static uint64_t sNextFontFileKey = 0;
static std::unordered_map<uint64_t, IDWriteFontFileStream*> sFontFileStreams;
MOZ_RUNINIT static std::unordered_map<uint64_t, IDWriteFontFileStream*>
sFontFileStreams;
class DWriteFontFileLoader : public IDWriteFontFileLoader {
public:

View File

@ -23,7 +23,8 @@ namespace mozilla {
namespace gfx {
#define FONT_NAME_MAX 32
static StaticDataMutex<std::unordered_map<void*, nsAutoCStringN<FONT_NAME_MAX>>>
MOZ_RUNINIT static StaticDataMutex<
std::unordered_map<void*, nsAutoCStringN<FONT_NAME_MAX>>>
sWeakFontDataMap("WeakFonts");
void FontDataDeallocate(void*, void* info) {

View File

@ -342,7 +342,7 @@ already_AddRefed<GLContext> GLContextProviderCGL::CreateHeadless(
return gl.forget();
}
static RefPtr<GLContext> gGlobalContext;
MOZ_RUNINIT static RefPtr<GLContext> gGlobalContext;
GLContext* GLContextProviderCGL::GetGlobalContext() {
static bool triedToCreateContext = false;

View File

@ -142,7 +142,7 @@ already_AddRefed<GLContext> GLContextProviderEAGL::CreateHeadless(
return CreateEAGLContext(desc, GetGlobalContextEAGL()).forget();
}
static RefPtr<GLContext> gGlobalContext;
MOZ_RUNINIT static RefPtr<GLContext> gGlobalContext;
GLContext* GLContextProviderEAGL::GetGlobalContext() {
static bool triedToCreateContext = false;

View File

@ -106,7 +106,7 @@ class WaylandOffscreenGLSurface {
struct wl_egl_window* mEGLWindow = nullptr;
};
static nsTHashMap<nsPtrHashKey<void>, WaylandOffscreenGLSurface*>
MOZ_RUNINIT static nsTHashMap<nsPtrHashKey<void>, WaylandOffscreenGLSurface*>
sWaylandOffscreenGLSurfaces;
void DeleteWaylandOffscreenGLSurface(EGLSurface surface) {

View File

@ -51,7 +51,7 @@ namespace mozilla::gl {
using namespace mozilla::gfx;
using namespace mozilla::widget;
GLXLibrary sGLXLibrary;
MOZ_RUNINIT GLXLibrary sGLXLibrary;
static inline bool HasExtension(const char* aExtensions,
const char* aRequiredExtension) {

View File

@ -30,7 +30,7 @@ namespace gl {
using namespace mozilla::gfx;
using namespace mozilla::widget;
WGLLibrary sWGLLib;
MOZ_RUNINIT WGLLibrary sWGLLib;
/*
ScopedWindow::~ScopedWindow()

View File

@ -389,7 +389,7 @@ class AngleErrorReporting {
nsACString* mFailureId;
};
AngleErrorReporting gAngleErrorReporter;
MOZ_RUNINIT AngleErrorReporting gAngleErrorReporter;
static std::shared_ptr<EglDisplay> GetAndInitDisplayForAccelANGLE(
GLLibraryEGL& egl, nsACString* const out_failureId,

View File

@ -23,7 +23,7 @@
namespace mozilla::gfx {
CanvasManagerParent::ManagerSet CanvasManagerParent::sManagers;
MOZ_RUNINIT CanvasManagerParent::ManagerSet CanvasManagerParent::sManagers;
/* static */ void CanvasManagerParent::Init(
Endpoint<PCanvasManagerParent>&& aEndpoint,

View File

@ -18,7 +18,7 @@ using namespace mozilla::dom;
namespace mozilla::gfx {
StaticMutex CanvasShutdownManager::sManagersMutex;
std::set<CanvasShutdownManager*> CanvasShutdownManager::sManagers;
MOZ_RUNINIT std::set<CanvasShutdownManager*> CanvasShutdownManager::sManagers;
// The owning thread will tell us to close when it is shutdown, either via
// CanvasShutdownManager::Shutdown for the main thread, or via a shutdown

View File

@ -20,7 +20,7 @@ using namespace mozilla::gl;
namespace mozilla::layers {
static RefPtr<GLContext> sSnapshotContext;
MOZ_RUNINIT static RefPtr<GLContext> sSnapshotContext;
nsresult GLImage::ReadIntoBuffer(uint8_t* aData, int32_t aStride,
const gfx::IntSize& aSize,

View File

@ -19,7 +19,7 @@ namespace layers {
// stopped moving. Some input devices do not send move events in the
// case where a pointer has stopped. We need to detect this case so that we can
// accurately predict the velocity after the pointer starts moving again.
static const TimeDuration kAssumePointerMoveStoppedTime =
MOZ_RUNINIT static const TimeDuration kAssumePointerMoveStoppedTime =
TimeDuration::FromMilliseconds(40);
// The degree of the approximation.

View File

@ -21,7 +21,8 @@ namespace layers {
// delta can be really small, which can make the velocity computation very
// volatile. To avoid this we impose a minimum time delta below which we do
// not recompute the velocity.
const TimeDuration MIN_VELOCITY_SAMPLE_TIME = TimeDuration::FromMilliseconds(5);
MOZ_RUNINIT const TimeDuration MIN_VELOCITY_SAMPLE_TIME =
TimeDuration::FromMilliseconds(5);
extern StaticAutoPtr<StyleComputedTimingFunction> gVelocityCurveFunction;

View File

@ -9,7 +9,7 @@
namespace mozilla {
namespace layers {
ScrollableLayerGuid InputAPZContext::sGuid;
MOZ_RUNINIT ScrollableLayerGuid InputAPZContext::sGuid;
uint64_t InputAPZContext::sBlockId = 0;
nsEventStatus InputAPZContext::sApzResponse = nsEventStatus_eSentinel;
bool InputAPZContext::sPendingLayerization = false;

Some files were not shown because too many files have changed in this diff Show More