Bug 1448016 - make some Android widget constructors explicit; r=snorp

Attempting to stand up the static analysis for Android builds revealed
that we weren't being explicit enough.
This commit is contained in:
Nathan Froyd
2018-03-27 10:51:32 -04:00
parent f2ba27ebae
commit c415bb3846
12 changed files with 32 additions and 32 deletions

View File

@@ -76,7 +76,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSICURSORCONTINUECALLBACK
MessageCursorContinueCallback(int aRequestId)
explicit MessageCursorContinueCallback(int aRequestId)
: mRequestId(aRequestId)
{
}
@@ -258,7 +258,7 @@ public:
class AutoJObject {
public:
AutoJObject(JNIEnv* aJNIEnv = nullptr) : mObject(nullptr)
explicit AutoJObject(JNIEnv* aJNIEnv = nullptr) : mObject(nullptr)
{
mJNIEnv = aJNIEnv ? aJNIEnv : jni::GetGeckoThreadEnv();
}
@@ -292,7 +292,7 @@ private:
class AutoLocalJNIFrame {
public:
AutoLocalJNIFrame(int nEntries = 15)
explicit AutoLocalJNIFrame(int nEntries = 15)
: mEntries(nEntries)
, mJNIEnv(jni::GetGeckoThreadEnv())
, mHasFrameBeenPushed(false)
@@ -301,7 +301,7 @@ public:
Push();
}
AutoLocalJNIFrame(JNIEnv* aJNIEnv, int nEntries = 15)
explicit AutoLocalJNIFrame(JNIEnv* aJNIEnv, int nEntries = 15)
: mEntries(nEntries)
, mJNIEnv(aJNIEnv ? aJNIEnv : jni::GetGeckoThreadEnv())
, mHasFrameBeenPushed(false)

View File

@@ -131,7 +131,7 @@ class AndroidUiTask : public LinkedListElement<AndroidUiTask> {
using TimeDuration = mozilla::TimeDuration;
public:
AndroidUiTask(already_AddRefed<nsIRunnable> aTask)
explicit AndroidUiTask(already_AddRefed<nsIRunnable> aTask)
: mTask(aTask)
, mRunTime() // Null timestamp representing no delay.
{}

View File

@@ -583,7 +583,7 @@ class JavaCallbackDelegate final : public nsIAndroidEventCallback
}
public:
JavaCallbackDelegate(java::EventCallback::Param aCallback)
explicit JavaCallbackDelegate(java::EventCallback::Param aCallback)
: mCallback(jni::GetGeckoThreadEnv(), aCallback)
{}

View File

@@ -49,7 +49,7 @@ class GeckoEditableSupport final
{
GeckoEditableSupport* const mGES;
public:
AutoIMESynchronize(GeckoEditableSupport* ges) : mGES(ges) {}
explicit AutoIMESynchronize(GeckoEditableSupport* ges) : mGES(ges) {}
~AutoIMESynchronize() { mGES->OnImeSynchronize(); }
};
@@ -59,7 +59,7 @@ class GeckoEditableSupport final
IMETextChange() :
mStart(-1), mOldEnd(-1), mNewEnd(-1) {}
IMETextChange(const IMENotification& aIMENotification)
explicit IMETextChange(const IMENotification& aIMENotification)
: mStart(aIMENotification.mTextChangeData.mStartOffset)
, mOldEnd(aIMENotification.mTextChangeData.mRemovedEndOffset)
, mNewEnd(aIMENotification.mTextChangeData.mAddedEndOffset)
@@ -143,7 +143,7 @@ public:
{
struct IMEEvent : nsAppShell::LambdaEvent<Functor>
{
IMEEvent(Functor&& l) : nsAppShell::LambdaEvent<Functor>(Move(l)) {}
explicit IMEEvent(Functor&& l) : nsAppShell::LambdaEvent<Functor>(Move(l)) {}
nsAppShell::Event::Type ActivityType() const override
{
@@ -189,7 +189,7 @@ public:
}
// Constructor for content process GeckoEditableChild.
GeckoEditableSupport(java::GeckoEditableChild::Param aEditableChild)
explicit GeckoEditableSupport(java::GeckoEditableChild::Param aEditableChild)
: GeckoEditableSupport(nullptr, nullptr, aEditableChild)
{
}

View File

@@ -200,7 +200,7 @@ public:
bool mIdlePass;
public:
IdleEvent(Functor&& aCall)
explicit IdleEvent(Functor&& aCall)
: Runnable("ThumbnailHelperIdle")
, mLambda(Move(aCall))
, mIdlePass(false)

View File

@@ -16,15 +16,15 @@ namespace detail {
// Helper class to convert an arbitrary type to a jvalue, e.g. Value(123).val.
struct Value
{
Value(jboolean z) { val.z = z; }
Value(jbyte b) { val.b = b; }
Value(jchar c) { val.c = c; }
Value(jshort s) { val.s = s; }
Value(jint i) { val.i = i; }
Value(jlong j) { val.j = j; }
Value(jfloat f) { val.f = f; }
Value(jdouble d) { val.d = d; }
Value(jobject l) { val.l = l; }
explicit Value(jboolean z) { val.z = z; }
explicit Value(jbyte b) { val.b = b; }
explicit Value(jchar c) { val.c = c; }
explicit Value(jshort s) { val.s = s; }
explicit Value(jint i) { val.i = i; }
explicit Value(jlong j) { val.j = j; }
explicit Value(jfloat f) { val.f = f; }
explicit Value(jdouble d) { val.d = d; }
explicit Value(jobject l) { val.l = l; }
jvalue val;
};

View File

@@ -86,7 +86,7 @@ public:
JNIEnv* const mEnv;
Type mInstance;
AutoLock(Type aInstance)
explicit AutoLock(Type aInstance)
: mEnv(FindEnv())
, mInstance(mEnv->NewLocalRef(aInstance))
{
@@ -678,7 +678,7 @@ class DependentRef : public Cls::Ref
using Ref = typename Cls::Ref;
public:
DependentRef(typename Ref::JNIType instance)
explicit DependentRef(typename Ref::JNIType instance)
: Ref(instance)
{}

View File

@@ -297,7 +297,7 @@ void DispatchToGeckoPriorityQueue(already_AddRefed<nsIRunnable> aCall)
{
nsCOMPtr<nsIRunnable> mCall;
public:
RunnableEvent(already_AddRefed<nsIRunnable> aCall) : mCall(aCall) {}
explicit RunnableEvent(already_AddRefed<nsIRunnable> aCall) : mCall(aCall) {}
void Run() override { NS_ENSURE_SUCCESS_VOID(mCall->Run()); }
};

View File

@@ -21,7 +21,7 @@ using namespace mozilla;
class AndroidInputStream : public nsIInputStream
{
public:
AndroidInputStream(jni::Object::Param connection) {
explicit AndroidInputStream(jni::Object::Param connection) {
mBridgeInputStream = java::GeckoAppShell::CreateInputStream(connection);
mBridgeChannel = AndroidBridge::ChannelCreate(mBridgeInputStream);
}

View File

@@ -77,7 +77,7 @@ public:
T lambda;
public:
LambdaEvent(T&& l) : lambda(mozilla::Move(l)) {}
explicit LambdaEvent(T&& l) : lambda(mozilla::Move(l)) {}
void Run() override { return lambda(); }
};
@@ -87,7 +87,7 @@ public:
mozilla::UniquePtr<Event> baseEvent;
public:
ProxyEvent(mozilla::UniquePtr<Event>&& event)
explicit ProxyEvent(mozilla::UniquePtr<Event>&& event)
: baseEvent(mozilla::Move(event))
{}
@@ -182,7 +182,7 @@ protected:
nsAppShell* const appShell;
public:
NativeCallbackEvent(nsAppShell* as) : appShell(as) {}
explicit NativeCallbackEvent(nsAppShell* as) : appShell(as) {}
void Run() override { appShell->NativeEventCallback(); }
};

View File

@@ -147,7 +147,7 @@ public:
, mInstance(Forward<InstanceType>(aInstance))
{}
WindowEvent(Lambda&& aLambda)
explicit WindowEvent(Lambda&& aLambda)
: Runnable("nsWindowEvent")
, mLambda(mozilla::Move(aLambda))
, mInstance(mLambda.GetThisArg())
@@ -229,7 +229,7 @@ class nsWindow::NativePtr<Impl>::Locked final : private MutexAutoLock
Impl* const mImpl;
public:
Locked(NativePtr<Impl>& aPtr)
explicit Locked(NativePtr<Impl>& aPtr)
: MutexAutoLock(aPtr.mImplLock)
, mImpl(aPtr.mImpl)
{}
@@ -795,7 +795,7 @@ class nsWindow::LayerViewSupport final
return MakeUnique<LayerViewEvent>(mozilla::Move(event));
}
LayerViewEvent(UniquePtr<Event>&& event)
explicit LayerViewEvent(UniquePtr<Event>&& event)
: nsAppShell::ProxyEvent(mozilla::Move(event))
{}
@@ -978,7 +978,7 @@ public:
LayerSession::Compositor::GlobalRef mCompositor;
public:
OnResumedEvent(LayerSession::Compositor::GlobalRef&& aCompositor)
explicit OnResumedEvent(LayerSession::Compositor::GlobalRef&& aCompositor)
: mCompositor(mozilla::Move(aCompositor))
{}

View File

@@ -120,7 +120,7 @@ public:
nsWindow* const mWindow;
public:
Locked(WindowPtr<Impl>& aPtr)
explicit Locked(WindowPtr<Impl>& aPtr)
: mozilla::MutexAutoLock(aPtr.mWindowLock)
, mWindow(aPtr.mWindow)
{}