Bug 1625138 - Part 38: Replace mozilla::IsSame with std::is_same in dom/. r=froydnj

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
André Bargull 2020-03-28 13:57:21 +00:00
parent f70fd1c1bd
commit 73a498ec0c
9 changed files with 38 additions and 29 deletions

View File

@ -209,9 +209,9 @@ MOZ_ALWAYS_INLINE nsresult UnwrapObjectInternal(V& obj, U& value,
prototypes::ID protoID,
uint32_t protoDepth,
const CxType& cx) {
static_assert(IsSame<CxType, JSContext*>::value ||
IsSame<CxType, BindingCallContext>::value ||
IsSame<CxType, decltype(nullptr)>::value,
static_assert(std::is_same_v<CxType, JSContext*> ||
std::is_same_v<CxType, BindingCallContext> ||
std::is_same_v<CxType, decltype(nullptr)>,
"Unexpected CxType");
/* First check to see whether we have a DOM object */
@ -239,7 +239,7 @@ MOZ_ALWAYS_INLINE nsresult UnwrapObjectInternal(V& obj, U& value,
}
JSObject* unwrappedObj;
if (IsSame<CxType, decltype(nullptr)>::value) {
if (std::is_same_v<CxType, decltype(nullptr)>) {
unwrappedObj = js::CheckedUnwrapStatic(obj);
} else {
unwrappedObj =
@ -249,7 +249,7 @@ MOZ_ALWAYS_INLINE nsresult UnwrapObjectInternal(V& obj, U& value,
return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
}
if (IsSame<CxType, decltype(nullptr)>::value) {
if (std::is_same_v<CxType, decltype(nullptr)>) {
// We might still have a windowproxy here. But it shouldn't matter, because
// that's not what the caller is looking for, so we're going to fail out
// anyway below once we do the recursive call to ourselves with wrapper
@ -988,7 +988,7 @@ struct TypeNeedsOuterization {
// nsGlobalWindow (which inherits from EventTarget itself).
static const bool value = std::is_base_of<nsGlobalWindowInner, T>::value ||
std::is_base_of<nsGlobalWindowOuter, T>::value ||
IsSame<EventTarget, T>::value;
std::is_same_v<EventTarget, T>;
};
#ifdef DEBUG
@ -2699,12 +2699,12 @@ class MOZ_STACK_CLASS BindingJSObjectCreator {
template <class T>
struct DeferredFinalizerImpl {
using SmartPtr = std::conditional_t<
IsSame<T, nsISupports>::value, nsCOMPtr<T>,
std::is_same_v<T, nsISupports>, nsCOMPtr<T>,
std::conditional_t<IsRefcounted<T>::value, RefPtr<T>, UniquePtr<T>>>;
typedef SegmentedVector<SmartPtr> SmartPtrArray;
static_assert(
IsSame<T, nsISupports>::value || !std::is_base_of<nsISupports, T>::value,
std::is_same_v<T, nsISupports> || !std::is_base_of<nsISupports, T>::value,
"nsISupports classes should all use the nsISupports instantiation");
static inline void AppendAndTake(

View File

@ -122,6 +122,7 @@
#include <algorithm>
#include <cmath>
#include <limits>
#include <type_traits>
mozilla::LazyLogModule gMediaElementLog("nsMediaElement");
static mozilla::LazyLogModule gMediaElementEventsLog("nsMediaElementEvents");
@ -4907,7 +4908,7 @@ nsresult HTMLMediaElement::SetupDecoder(DecoderType* aDecoder,
rv = FinishDecoderSetup(aDecoder);
// Only ChannelMediaDecoder supports resource cloning.
if (IsSame<DecoderType, ChannelMediaDecoder>::value && NS_SUCCEEDED(rv)) {
if (std::is_same_v<DecoderType, ChannelMediaDecoder> && NS_SUCCEEDED(rv)) {
AddMediaElementToURITable();
NS_ASSERTION(
MediaElementTableCount(this, mLoadingSrc) == 1,

View File

@ -370,9 +370,9 @@ class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
private:
template <class T>
std::enable_if_t<IsSame<T, IDBDatabase>::value ||
IsSame<T, IDBCursor>::value ||
IsSame<T, IDBMutableFile>::value,
std::enable_if_t<std::is_same_v<T, IDBDatabase> ||
std::is_same_v<T, IDBCursor> ||
std::is_same_v<T, IDBMutableFile>,
nsresult>
GetResult(JSContext* aCx, T* aDOMObject,
JS::MutableHandle<JS::Value> aResult) {

View File

@ -6,6 +6,8 @@
#if !defined(MediaQueue_h_)
# define MediaQueue_h_
# include <type_traits>
# include "mozilla/RecursiveMutex.h"
# include "mozilla/TaskQueue.h"
@ -161,7 +163,7 @@ class MediaQueue : private nsDeque {
}
uint32_t AudioFramesCount() {
static_assert(mozilla::IsSame<T, AudioData>::value,
static_assert(std::is_same_v<T, AudioData>,
"Only usable with MediaQueue<AudioData>");
RecursiveMutexAutoLock lock(mRecursiveMutex);
uint32_t frames = 0;

View File

@ -7,6 +7,8 @@
#ifndef DDLifetimes_h_
#define DDLifetimes_h_
#include <type_traits>
#include "DDLifetime.h"
#include "DDLoggedTypeTraits.h"
#include "nsClassHashtable.h"
@ -59,7 +61,7 @@ class DDLifetimes {
}
continue;
}
static_assert(IsSame<decltype(aF(lifetime)), void>::value, "");
static_assert(std::is_same_v<decltype(aF(lifetime)), void>, "");
aF(lifetime);
}
}
@ -77,7 +79,7 @@ class DDLifetimes {
for (auto iter = mLifetimes.ConstIter(); !iter.Done(); iter.Next()) {
for (const DDLifetime& lifetime : *iter.UserData()) {
if (lifetime.mMediaElement == aMediaElement) {
static_assert(IsSame<decltype(aF(lifetime)), bool>::value, "");
static_assert(std::is_same_v<decltype(aF(lifetime)), bool>, "");
if (aF(lifetime)) {
return true;
}

View File

@ -12,6 +12,7 @@
#include "nsThreadUtils.h"
#include <gtest/gtest.h>
#include <type_traits>
using mozilla::MultiWriterQueue;
using mozilla::MultiWriterQueueDefaultBufferSize;
@ -226,9 +227,9 @@ TEST(MultiWriterQueue, MultiWriterSingleReader)
TEST(MultiWriterQueue, MultiWriterMultiReader)
{
static_assert(
mozilla::IsSame<MultiWriterQueue<int, 10>,
MultiWriterQueue<
int, 10, MultiWriterQueueReaderLocking_Mutex>>::value,
std::is_same_v<
MultiWriterQueue<int, 10>,
MultiWriterQueue<int, 10, MultiWriterQueueReaderLocking_Mutex>>,
"MultiWriterQueue reader locking should use Mutex by default");
// Small BufferSize, to exercize the buffer management code.

View File

@ -11,13 +11,14 @@
#include <cstdint>
#include <gtest/gtest.h>
#include <type_traits>
using RN8 = mozilla::RollingNumber<uint8_t>;
TEST(RollingNumber, Value)
{
// Value type should reflect template argument.
static_assert(mozilla::IsSame<RN8::ValueType, uint8_t>::value, "");
static_assert(std::is_same_v<RN8::ValueType, uint8_t>, "");
// Default init to 0.
const RN8 n;

View File

@ -8,6 +8,7 @@
#include "TimeUnits.h"
#include "Intervals.h"
#include <algorithm>
#include <type_traits>
#include <vector>
using namespace mozilla;
@ -704,14 +705,14 @@ TEST(IntervalSet, StaticAssert)
{
media::Interval<int> i;
static_assert(mozilla::IsSame<
nsTArray_RelocationStrategy<IntIntervals>::Type,
nsTArray_RelocateUsingMoveConstructor<IntIntervals>>::value,
"Must use copy constructor");
static_assert(
mozilla::IsSame<
std::is_same_v<nsTArray_RelocationStrategy<IntIntervals>::Type,
nsTArray_RelocateUsingMoveConstructor<IntIntervals>>,
"Must use copy constructor");
static_assert(
std::is_same_v<
nsTArray_RelocationStrategy<media::TimeIntervals>::Type,
nsTArray_RelocateUsingMoveConstructor<media::TimeIntervals>>::value,
nsTArray_RelocateUsingMoveConstructor<media::TimeIntervals>>,
"Must use copy constructor");
}

View File

@ -236,10 +236,11 @@ class Promise : public nsISupports, public SupportsWeakPtr<Promise> {
template <typename Callback, typename... Args>
using IsHandlerCallback =
IsSame<already_AddRefed<Promise>,
decltype(std::declval<Callback>()(
(JSContext*)(nullptr), std::declval<JS::Handle<JS::Value>>(),
std::declval<Args>()...))>;
std::is_same<already_AddRefed<Promise>,
decltype(std::declval<Callback>()(
(JSContext*)(nullptr),
std::declval<JS::Handle<JS::Value>>(),
std::declval<Args>()...))>;
template <typename Callback, typename... Args>
using ThenResult =