Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1466168: Remove mozilla::Forward in favor of std::forward. r=froydnj
Browse files Browse the repository at this point in the history
Same approach as the other bug, mostly replacing automatically by removing
'using mozilla::Forward;' and then:

  s/mozilla::Forward/std::forward/
  s/Forward</std::forward</

The only file that required manual fixup was TestTreeTraversal.cpp, which had
a class called TestNodeForward with template parameters :)

MozReview-Commit-ID: A88qFG5AccP
  • Loading branch information
emilio committed Jun 2, 2018
1 parent d14619c commit 0d25298
Show file tree
Hide file tree
Showing 122 changed files with 409 additions and 439 deletions.
2 changes: 1 addition & 1 deletion accessible/xpcom/xpcAccessibleTextRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class xpcAccessibleTextRange final : public nsIAccessibleTextRange

private:
explicit xpcAccessibleTextRange(TextRange&& aRange) :
mRange(Forward<TextRange>(aRange)) {}
mRange(std::forward<TextRange>(aRange)) {}
xpcAccessibleTextRange() {}

~xpcAccessibleTextRange() {}
Expand Down
4 changes: 2 additions & 2 deletions devtools/shared/heapsnapshot/HeapSnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,13 +918,13 @@ class TwoByteString : public Variant<JSAtom*, const char16_t*, JS::ubi::EdgeName

public:
template<typename T>
MOZ_IMPLICIT TwoByteString(T&& rhs) : Base(Forward<T>(rhs)) { }
MOZ_IMPLICIT TwoByteString(T&& rhs) : Base(std::forward<T>(rhs)) { }

template<typename T>
TwoByteString& operator=(T&& rhs) {
MOZ_ASSERT(this != &rhs, "self-move disallowed");
this->~TwoByteString();
new (this) TwoByteString(Forward<T>(rhs));
new (this) TwoByteString(std::forward<T>(rhs));
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion dom/animation/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "mozilla/AutoRestore.h"
#include "mozilla/AsyncEventDispatcher.h" // For AsyncEventDispatcher
#include "mozilla/Maybe.h" // For Maybe
#include "mozilla/TypeTraits.h" // For Forward<>
#include "mozilla/TypeTraits.h" // For std::forward<>
#include "nsAnimationManager.h" // For CSSAnimation
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
#include "nsIDocument.h" // For nsIDocument
Expand Down
2 changes: 1 addition & 1 deletion dom/animation/EffectCompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "mozilla/ServoBindings.h" // Servo_GetProperties_Overriding_Animation
#include "mozilla/ServoStyleSet.h"
#include "mozilla/StyleAnimationValue.h"
#include "mozilla/TypeTraits.h" // For Forward<>
#include "mozilla/TypeTraits.h" // For std::forward<>
#include "nsContentUtils.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSPropertyIDSet.h"
Expand Down
2 changes: 1 addition & 1 deletion dom/bindings/BindingDeclarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class Optional_base
template<typename... Args>
InternalType& Construct(Args&&... aArgs)
{
mImpl.emplace(Forward<Args>(aArgs)...);
mImpl.emplace(std::forward<Args>(aArgs)...);
return *mImpl;
}

Expand Down
10 changes: 5 additions & 5 deletions dom/bindings/ErrorResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ inline bool
ThrowErrorMessage(JSContext* aCx, const ErrNum aErrorNumber, Ts&&... aArgs)
{
binding_detail::ThrowErrorMessage(aCx, static_cast<unsigned>(aErrorNumber),
mozilla::Forward<Ts>(aArgs)...);
std::forward<Ts>(aArgs)...);
return false;
}

Expand All @@ -97,7 +97,7 @@ struct StringArrayAppender
return;
}
aArgs.AppendElement(aFirst);
Append(aArgs, aCount - 1, Forward<Ts>(aOtherArgs)...);
Append(aArgs, aCount - 1, std::forward<Ts>(aOtherArgs)...);
}
};

Expand Down Expand Up @@ -293,14 +293,14 @@ class TErrorResult {
void ThrowTypeError(Ts&&... messageArgs)
{
ThrowErrorWithMessage<errorNumber>(NS_ERROR_INTERNAL_ERRORRESULT_TYPEERROR,
Forward<Ts>(messageArgs)...);
std::forward<Ts>(messageArgs)...);
}

template<dom::ErrNum errorNumber, typename... Ts>
void ThrowRangeError(Ts&&... messageArgs)
{
ThrowErrorWithMessage<errorNumber>(NS_ERROR_INTERNAL_ERRORRESULT_RANGEERROR,
Forward<Ts>(messageArgs)...);
std::forward<Ts>(messageArgs)...);
}

bool IsErrorWithMessage() const
Expand Down Expand Up @@ -434,7 +434,7 @@ class TErrorResult {
nsTArray<nsString>& messageArgsArray = CreateErrorMessageHelper(errorNumber, errorType);
uint16_t argCount = dom::GetErrorArgCount(errorNumber);
dom::StringArrayAppender::Append(messageArgsArray, argCount,
Forward<Ts>(messageArgs)...);
std::forward<Ts>(messageArgs)...);
#ifdef DEBUG
mUnionState = HasMessage;
#endif // DEBUG
Expand Down
2 changes: 1 addition & 1 deletion dom/clients/manager/ClientManagerOpParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ClientManagerOpParent::DoServiceOp(Method aMethod, Args&&... aArgs)
{
// Note, we need perfect forarding of the template type in order
// to allow already_AddRefed<> to be passed as an arg.
RefPtr<ClientOpPromise> p = (mService->*aMethod)(Forward<Args>(aArgs)...);
RefPtr<ClientOpPromise> p = (mService->*aMethod)(std::forward<Args>(aArgs)...);

// Capturing `this` is safe here because we disconnect the promise in
// ActorDestroy() which ensures neither lambda is called if the actor
Expand Down
2 changes: 1 addition & 1 deletion dom/console/nsIConsoleReportCollector.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class NS_NO_VTABLE nsIConsoleReportCollector : public nsISupports
{
nsTArray<nsString> params;
mozilla::dom::StringArrayAppender::Append(params, sizeof...(Params),
mozilla::Forward<Params>(aParams)...);
std::forward<Params>(aParams)...);
AddConsoleReport(aErrorFlags, aCategory, aPropertiesFile, aSourceFileURI,
aLineNumber, aColumnNumber, aMessageName, params);
}
Expand Down
2 changes: 1 addition & 1 deletion dom/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4855,7 +4855,7 @@ HTMLMediaElement::SetupDecoder(DecoderType* aDecoder, LoadArgs&&... aArgs)
aDecoder,
aDecoder->ContainerType().OriginalString().Data()));

nsresult rv = aDecoder->Load(Forward<LoadArgs>(aArgs)...);
nsresult rv = aDecoder->Load(std::forward<LoadArgs>(aArgs)...);
if (NS_FAILED(rv)) {
aDecoder->Shutdown();
LOG(LogLevel::Debug, ("%p Failed to load for decoder %p", this, aDecoder));
Expand Down
2 changes: 1 addition & 1 deletion dom/media/AudioStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ template <typename Function, typename... Args>
int AudioStream::InvokeCubeb(Function aFunction, Args&&... aArgs)
{
MonitorAutoUnlock mon(mMonitor);
return aFunction(mCubebStream.get(), Forward<Args>(aArgs)...);
return aFunction(mCubebStream.get(), std::forward<Args>(aArgs)...);
}

nsresult
Expand Down
10 changes: 5 additions & 5 deletions dom/media/Intervals.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ class Interval

template<typename StartArg, typename EndArg>
Interval(StartArg&& aStart, EndArg&& aEnd)
: mStart(Forward<StartArg>(aStart))
, mEnd(Forward<EndArg>(aEnd))
: mStart(std::forward<StartArg>(aStart))
, mEnd(std::forward<EndArg>(aEnd))
, mFuzz()
{
MOZ_ASSERT(aStart <= aEnd);
}

template<typename StartArg, typename EndArg, typename FuzzArg>
Interval(StartArg&& aStart, EndArg&& aEnd, FuzzArg&& aFuzz)
: mStart(Forward<StartArg>(aStart))
, mEnd(Forward<EndArg>(aEnd))
, mFuzz(Forward<FuzzArg>(aFuzz))
: mStart(std::forward<StartArg>(aStart))
, mEnd(std::forward<EndArg>(aEnd))
, mFuzz(std::forward<FuzzArg>(aFuzz))
{
MOZ_ASSERT(aStart <= aEnd);
}
Expand Down
2 changes: 1 addition & 1 deletion dom/media/MediaDecoderStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class MediaDecoderStateMachine::StateObject
// So we 1) pass the parameters by reference, but then 2) immediately copy
// them into a Tuple to be safe against modification, and finally 3) move
// the elements of the Tuple into the final function call.
auto copiedArgs = MakeTuple(Forward<Ts>(aArgs)...);
auto copiedArgs = MakeTuple(std::forward<Ts>(aArgs)...);

// Copy mMaster which will reset to null.
auto master = mMaster;
Expand Down
2 changes: 1 addition & 1 deletion dom/media/MediaDecoderStateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct MediaPlaybackEvent
template<typename T>
MediaPlaybackEvent(EventType aType, T&& aArg)
: mType(aType)
, mData(Forward<T>(aArg))
, mData(std::forward<T>(aArg))
{
}
};
Expand Down
14 changes: 7 additions & 7 deletions dom/media/MediaEventSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Listener : public RevocableToken
"detail::Listener::ApplyWithArgs",
this,
&Listener::ApplyWithArgs,
Forward<Ts>(aEvents)...));
std::forward<Ts>(aEvents)...));
} else {
DispatchTask(NewRunnableMethod(
"detail::Listener::ApplyWithNoArgs", this, &Listener::ApplyWithNoArgs));
Expand Down Expand Up @@ -178,7 +178,7 @@ class ListenerImpl : public Listener<As...>
template <typename F>
ListenerImpl(Target* aTarget, F&& aFunction)
: mTarget(aTarget)
, mFunction(Forward<F>(aFunction))
, mFunction(std::forward<F>(aFunction))
{
}

Expand Down Expand Up @@ -345,7 +345,7 @@ class MediaEventSourceImpl {
MOZ_ASSERT(Lp == ListenerPolicy::NonExclusive || mListeners.IsEmpty());
auto l = mListeners.AppendElement();
*l = new ListenerImpl<Target, Function>(
aTarget, Forward<Function>(aFunction));
aTarget, std::forward<Function>(aFunction));
return MediaEventListener(*l);
}

Expand Down Expand Up @@ -383,13 +383,13 @@ class MediaEventSourceImpl {
template<typename Function>
MediaEventListener
Connect(AbstractThread* aTarget, Function&& aFunction) {
return ConnectInternal(aTarget, Forward<Function>(aFunction));
return ConnectInternal(aTarget, std::forward<Function>(aFunction));
}

template<typename Function>
MediaEventListener
Connect(nsIEventTarget* aTarget, Function&& aFunction) {
return ConnectInternal(aTarget, Forward<Function>(aFunction));
return ConnectInternal(aTarget, std::forward<Function>(aFunction));
}

/**
Expand Down Expand Up @@ -430,7 +430,7 @@ class MediaEventSourceImpl {
mListeners.RemoveElementAt(i);
continue;
}
l->Dispatch(Forward<Ts>(aEvents)...);
l->Dispatch(std::forward<Ts>(aEvents)...);
}
}

Expand Down Expand Up @@ -482,7 +482,7 @@ class MediaEventProducerExc : public MediaEventSourceExc<Es...> {
public:
template <typename... Ts>
void Notify(Ts&&... aEvents) {
this->NotifyInternal(Forward<Ts>(aEvents)...);
this->NotifyInternal(std::forward<Ts>(aEvents)...);
}
};

Expand Down
4 changes: 2 additions & 2 deletions dom/media/MediaInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class EncryptionInfo
template<typename AInitDatas>
InitData(const nsAString& aType, AInitDatas&& aInitData)
: mType(aType)
, mInitData(Forward<AInitDatas>(aInitData))
, mInitData(std::forward<AInitDatas>(aInitData))
{
}

Expand All @@ -463,7 +463,7 @@ class EncryptionInfo
template<typename AInitDatas>
void AddInitData(const nsAString& aType, AInitDatas&& aInitData)
{
mInitDatas.AppendElement(InitData(aType, Forward<AInitDatas>(aInitData)));
mInitDatas.AppendElement(InitData(aType, std::forward<AInitDatas>(aInitData)));
mEncrypted = true;
}

Expand Down
2 changes: 1 addition & 1 deletion dom/media/MediaManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ MediaManager::PostTask(const char* aName, FunctionType&& aFunction)
MozPromiseHolder<MozPromiseType> holder;
RefPtr<MozPromiseType> promise = holder.Ensure(aName);
MediaManager::PostTask(NS_NewRunnableFunction(aName,
[h = std::move(holder), func = Forward<FunctionType>(aFunction)]() mutable
[h = std::move(holder), func = std::forward<FunctionType>(aFunction)]() mutable
{
func(h);
}));
Expand Down
2 changes: 1 addition & 1 deletion dom/media/MediaSegment.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class MediaSegment {
*/
void SetLastPrincipalHandle(PrincipalHandle aLastPrincipalHandle)
{
mLastPrincipalHandle = Forward<PrincipalHandle>(aLastPrincipalHandle);
mLastPrincipalHandle = std::forward<PrincipalHandle>(aLastPrincipalHandle);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions dom/media/MediaTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ class DelayedScheduler {
mTarget = aTarget;
mMediaTimer->WaitUntil(mTarget, __func__)->Then(
mTargetThread, __func__,
Forward<ResolveFunc>(aResolver),
Forward<RejectFunc>(aRejector))
std::forward<ResolveFunc>(aResolver),
std::forward<RejectFunc>(aRejector))
->Track(mRequest);
}

Expand Down
2 changes: 1 addition & 1 deletion dom/media/VideoSegment.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class VideoFrame {
bool GetForceBlack() const { return mForceBlack; }
void SetPrincipalHandle(PrincipalHandle aPrincipalHandle)
{
mPrincipalHandle = Forward<PrincipalHandle>(aPrincipalHandle);
mPrincipalHandle = std::forward<PrincipalHandle>(aPrincipalHandle);
}
const PrincipalHandle& GetPrincipalHandle() const { return mPrincipalHandle; }
const gfx::IntSize& GetIntrinsicSize() const { return mIntrinsicSize; }
Expand Down
12 changes: 6 additions & 6 deletions dom/media/doctor/DecoderDoctorLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class DecoderDoctorLogger
aSubjectPointer,
aCategory,
aLabel,
DDLogValue{ Forward<Value>(aValue) });
DDLogValue{ std::forward<Value>(aValue) });
}

template<typename Subject, typename Value>
Expand All @@ -100,7 +100,7 @@ class DecoderDoctorLogger
aSubject,
aCategory,
aLabel,
Forward<Value>(aValue));
std::forward<Value>(aValue));
}

// EagerLogValue that can explicitly take strings, as the templated function
Expand Down Expand Up @@ -154,7 +154,7 @@ class DecoderDoctorLogger
aCategory,
aLabel,
DDLogValue{
nsCString{ nsPrintfCString(aFormat, Forward<Args>(aArgs)...) } });
nsCString{ nsPrintfCString(aFormat, std::forward<Args>(aArgs)...) } });
}

template<typename Subject>
Expand Down Expand Up @@ -182,7 +182,7 @@ class DecoderDoctorLogger
aCategory,
aLabel,
aFormat,
Forward<Args>(aArgs)...);
std::forward<Args>(aArgs)...);
}

static void MozLogPrintf(const char* aSubjectTypeName,
Expand All @@ -209,7 +209,7 @@ class DecoderDoctorLogger
const char* aFormat,
Args&&... aArgs)
{
nsCString printed = nsPrintfCString(aFormat, Forward<Args>(aArgs)...);
nsCString printed = nsPrintfCString(aFormat, std::forward<Args>(aArgs)...);
Log(aSubjectTypeName,
aSubjectPointer,
CategoryForMozLogLevel(aLogLevel),
Expand Down Expand Up @@ -245,7 +245,7 @@ class DecoderDoctorLogger
aLogModule,
aLogLevel,
aFormat,
Forward<Args>(aArgs)...);
std::forward<Args>(aArgs)...);
}

// Special logging functions. Consider using DecoderDoctorLifeLogger to
Expand Down
2 changes: 1 addition & 1 deletion dom/media/gmp/ChromiumCDMCallbackProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void ChromiumCDMCallbackProxy::DispatchToMainThread(const char* const aLabel,
aLabel,
mProxy,
aFunc,
Forward<Args>(aArgs)...),
std::forward<Args>(aArgs)...),
NS_DISPATCH_NORMAL);
}

Expand Down
6 changes: 3 additions & 3 deletions dom/media/gmp/ChromiumCDMChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ ChromiumCDMChild::CallMethod(MethodType aMethod, ParamType&&... aParams)
MOZ_ASSERT(IsOnMessageLoopThread());
// Avoid calling member function after destroy.
if (!mDestroyed) {
Unused << (this->*aMethod)(Forward<ParamType>(aParams)...);
Unused << (this->*aMethod)(std::forward<ParamType>(aParams)...);
}
}

Expand All @@ -208,7 +208,7 @@ ChromiumCDMChild::CallOnMessageLoopThread(const char* const aName,
ParamType&&... aParams)
{
if (IsOnMessageLoopThread()) {
CallMethod(aMethod, Forward<ParamType>(aParams)...);
CallMethod(aMethod, std::forward<ParamType>(aParams)...);
} else {
auto m = &ChromiumCDMChild::CallMethod<
decltype(aMethod), const typename RemoveReference<ParamType>::Type&...>;
Expand All @@ -219,7 +219,7 @@ ChromiumCDMChild::CallOnMessageLoopThread(const char* const aName,
this,
m,
aMethod,
Forward<ParamType>(aParams)...);
std::forward<ParamType>(aParams)...);
mPlugin->GMPMessageLoop()->PostTask(t.forget());
}
}
Expand Down
2 changes: 1 addition & 1 deletion dom/media/mp4/MP4Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class MP4Metadata : public DecoderDoctorLifeLogger<MP4Metadata>
public:
template <typename M2, typename T2>
ResultAndType(M2&& aM, T2&& aT)
: mResult(Forward<M2>(aM)), mT(Forward<T2>(aT))
: mResult(std::forward<M2>(aM)), mT(std::forward<T2>(aT))
{
}
ResultAndType(const ResultAndType&) = default;
Expand Down
2 changes: 1 addition & 1 deletion dom/media/platforms/PDMFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SupportChecker
void
AddToCheckList(Func&& aChecker)
{
mCheckerList.AppendElement(mozilla::Forward<Func>(aChecker));
mCheckerList.AppendElement(std::forward<Func>(aChecker));
}

void
Expand Down
Loading

0 comments on commit 0d25298

Please sign in to comment.