tor-browser

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

commit caaed8b17d4f14a0d705c3f2e5fcb43b82b7c0bc
parent bf3b8d787faaf12a0574ec578f0ae5316d70a2cc
Author: serge-sans-paille <sguelton@mozilla.com>
Date:   Fri,  3 Oct 2025 13:12:46 +0000

Bug 1991861 - Cleanup mozilla/EnumeratedArray.h, mfbt/EnumTypeTraits.h, mfbt/EnumeratedRange.h r=emilio,media-playback-reviewers,firefox-style-system-reviewers,layout-reviewers,padenot

- Remove unused inclusion
- use in-class definition for stream operators
- use some type alias

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

Diffstat:
Mdom/animation/EffectSet.h | 1-
Mdom/canvas/WebGLContext.cpp | 1-
Mdom/media/ipc/RemoteMediaManagerChild.h | 1-
Mdom/performance/PerformanceTimingIPCUtils.h | 1-
Mdom/webgpu/ipc/WebGPUChild.cpp | 1-
Mgfx/layers/Effects.h | 1-
Mgfx/layers/d3d11/CompositorD3D11.cpp | 1-
Mgfx/vr/gfxVR.h | 1-
Mjs/src/gc/Tenuring.h | 1-
Mlayout/painting/nsDisplayList.h | 1-
Mlayout/style/nsStyleTransformMatrix.h | 1-
Mmfbt/EnumTypeTraits.h | 10+++-------
Mmfbt/EnumeratedRange.h | 85+++++++++++++++++++++++++++----------------------------------------------------
13 files changed, 32 insertions(+), 74 deletions(-)

diff --git a/dom/animation/EffectSet.h b/dom/animation/EffectSet.h @@ -10,7 +10,6 @@ #include "mozilla/AnimationTarget.h" #include "mozilla/DebugOnly.h" #include "mozilla/EffectCompositor.h" -#include "mozilla/EnumeratedArray.h" #include "mozilla/TimeStamp.h" #include "mozilla/dom/KeyframeEffect.h" #include "nsHashKeys.h" // For nsPtrHashKey diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp @@ -32,7 +32,6 @@ #include "gfxEnv.h" #include "gfxPattern.h" #include "mozilla/EnumeratedArrayCycleCollection.h" -#include "mozilla/EnumeratedRange.h" #include "mozilla/Preferences.h" #include "mozilla/ProcessPriorityManager.h" #include "mozilla/ResultVariant.h" diff --git a/dom/media/ipc/RemoteMediaManagerChild.h b/dom/media/ipc/RemoteMediaManagerChild.h @@ -12,7 +12,6 @@ #include "PDMFactory.h" #include "PlatformEncoderModule.h" #include "ipc/EnumSerializer.h" -#include "mozilla/EnumTypeTraits.h" #include "mozilla/PRemoteMediaManagerChild.h" #include "mozilla/ipc/UtilityProcessSandboxing.h" #include "mozilla/layers/VideoBridgeUtils.h" diff --git a/dom/performance/PerformanceTimingIPCUtils.h b/dom/performance/PerformanceTimingIPCUtils.h @@ -7,7 +7,6 @@ #define _mozilla_dom_PerformanceTimingIPCUtils_h #include "ipc/EnumSerializer.h" -#include "mozilla/EnumTypeTraits.h" #include "nsITimedChannel.h" namespace IPC { diff --git a/dom/webgpu/ipc/WebGPUChild.cpp b/dom/webgpu/ipc/WebGPUChild.cpp @@ -20,7 +20,6 @@ #include "js/Warnings.h" // JS::WarnUTF8 #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" -#include "mozilla/EnumTypeTraits.h" #include "mozilla/ProfilerMarkers.h" #include "mozilla/dom/GPUUncapturedErrorEvent.h" #include "mozilla/dom/Promise.h" diff --git a/gfx/layers/Effects.h b/gfx/layers/Effects.h @@ -17,7 +17,6 @@ #include "mozilla/layers/TextureHost.h" // for CompositingRenderTarget, etc #include "mozilla/mozalloc.h" // for operator delete, etc #include "nscore.h" // for nsACString -#include "mozilla/EnumeratedArray.h" namespace mozilla { namespace layers { diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp @@ -24,7 +24,6 @@ #include "mozilla/gfx/StackArray.h" #include "mozilla/widget/WinCompositorWidget.h" -#include "mozilla/EnumeratedArray.h" #include "mozilla/ProfilerState.h" #include "mozilla/StaticPrefs_gfx.h" #include "mozilla/StaticPrefs_layers.h" diff --git a/gfx/vr/gfxVR.h b/gfx/vr/gfxVR.h @@ -14,7 +14,6 @@ #include "mozilla/RefPtr.h" #include "mozilla/gfx/2D.h" #include "mozilla/Atomics.h" -#include "mozilla/EnumeratedArray.h" #include "mozilla/TiedFields.h" #include "mozilla/TimeStamp.h" #include "mozilla/TypedEnumBits.h" diff --git a/js/src/gc/Tenuring.h b/js/src/gc/Tenuring.h @@ -7,7 +7,6 @@ #ifndef gc_Tenuring_h #define gc_Tenuring_h -#include "mozilla/EnumeratedArray.h" #include "mozilla/HashTable.h" #include "mozilla/Maybe.h" diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h @@ -32,7 +32,6 @@ #include "mozilla/DebugOnly.h" #include "mozilla/EffectCompositor.h" #include "mozilla/EnumSet.h" -#include "mozilla/EnumeratedArray.h" #include "mozilla/Logging.h" #include "mozilla/Maybe.h" #include "mozilla/MotionPathUtils.h" diff --git a/layout/style/nsStyleTransformMatrix.h b/layout/style/nsStyleTransformMatrix.h @@ -14,7 +14,6 @@ #include <limits> #include "Units.h" // for CSSPoint -#include "mozilla/EnumeratedArray.h" #include "mozilla/ServoStyleConsts.h" #include "mozilla/gfx/Matrix.h" #include "nsSize.h" diff --git a/mfbt/EnumTypeTraits.h b/mfbt/EnumTypeTraits.h @@ -8,7 +8,7 @@ #ifndef mozilla_EnumTypeTraits_h #define mozilla_EnumTypeTraits_h -#include <stddef.h> +#include <cstddef> #include <type_traits> namespace mozilla { @@ -116,17 +116,13 @@ inline constexpr auto UnderlyingValue(const T v) { */ template <typename T> -struct MinContiguousEnumValue { - static constexpr T value = static_cast<T>(0); -}; +struct MinContiguousEnumValue : std::integral_constant<T, T(0)> {}; template <typename T> struct MaxContiguousEnumValue; template <typename T> -struct MaxEnumValue { - static constexpr auto value = MaxContiguousEnumValue<T>::value; -}; +struct MaxEnumValue : MaxContiguousEnumValue<T> {}; // Provides the min and max values for a contiguous enum (requires at least // MaxContiguousEnumValue to be defined). diff --git a/mfbt/EnumeratedRange.h b/mfbt/EnumeratedRange.h @@ -33,7 +33,7 @@ namespace detail { template <typename EnumTypeT> class EnumeratedIterator { public: - typedef typename std::underlying_type<EnumTypeT>::type IntTypeT; + typedef std::underlying_type_t<EnumTypeT> IntTypeT; template <typename EnumType> constexpr explicit EnumeratedIterator(EnumType aCurrent) @@ -68,64 +68,37 @@ class EnumeratedIterator { /* Comparison operators */ - template <typename EnumType> - friend bool operator==(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - template <typename EnumType> - friend bool operator!=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - template <typename EnumType> - friend bool operator<(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - template <typename EnumType> - friend bool operator<=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - template <typename EnumType> - friend bool operator>(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - template <typename EnumType> - friend bool operator>=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - - private: - EnumTypeT mCurrent; -}; - -template <typename EnumType> -bool operator==(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) { - return aIter1.mCurrent == aIter2.mCurrent; -} - -template <typename EnumType> -bool operator!=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) { - return aIter1.mCurrent != aIter2.mCurrent; -} + friend bool operator==(const EnumeratedIterator<EnumTypeT>& aIter1, + const EnumeratedIterator<EnumTypeT>& aIter2) { + return aIter1.mCurrent == aIter2.mCurrent; + } -template <typename EnumType> -bool operator<(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) { - return aIter1.mCurrent < aIter2.mCurrent; -} + friend bool operator!=(const EnumeratedIterator<EnumTypeT>& aIter1, + const EnumeratedIterator<EnumTypeT>& aIter2) { + return aIter1.mCurrent != aIter2.mCurrent; + } -template <typename EnumType> -bool operator<=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) { - return aIter1.mCurrent <= aIter2.mCurrent; -} + friend bool operator<(const EnumeratedIterator<EnumTypeT>& aIter1, + const EnumeratedIterator<EnumTypeT>& aIter2) { + return aIter1.mCurrent < aIter2.mCurrent; + } -template <typename EnumType> -bool operator>(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) { - return aIter1.mCurrent > aIter2.mCurrent; -} + friend bool operator<=(const EnumeratedIterator<EnumTypeT>& aIter1, + const EnumeratedIterator<EnumTypeT>& aIter2) { + return aIter1.mCurrent <= aIter2.mCurrent; + } + friend bool operator>(const EnumeratedIterator<EnumTypeT>& aIter1, + const EnumeratedIterator<EnumTypeT>& aIter2) { + return aIter1.mCurrent > aIter2.mCurrent; + } + friend bool operator>=(const EnumeratedIterator<EnumTypeT>& aIter1, + const EnumeratedIterator<EnumTypeT>& aIter2) { + return aIter1.mCurrent >= aIter2.mCurrent; + } -template <typename EnumType> -bool operator>=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) { - return aIter1.mCurrent >= aIter2.mCurrent; -} + private: + EnumTypeT mCurrent; +}; template <typename EnumTypeT> class EnumeratedRange { @@ -189,7 +162,7 @@ constexpr detail::EnumeratedRange<EnumType> MakeEnumeratedRange(EnumType aEnd) { template <typename EnumType> constexpr detail::EnumeratedRange<EnumType> MakeInclusiveEnumeratedRange( EnumType aBegin, EnumType aEnd) { - using EnumUnderlyingType = typename std::underlying_type_t<EnumType>; + using EnumUnderlyingType = std::underlying_type_t<EnumType>; const auto end = static_cast<EnumUnderlyingType>(aEnd); MOZ_ASSERT(end != std::numeric_limits<EnumUnderlyingType>::max(),