Bug 1294482 - Move onFullScreenPluginHidden out of AndroidJNI.cpp; r=snorp

Move onFullScreenPluginHidden out of AndroidJNI.cpp and into a new-style
native method in nsAppShell.cpp.
This commit is contained in:
Jim Chen 2016-08-18 18:04:11 -04:00
parent 16c96d39f8
commit f78bb41597
8 changed files with 54 additions and 45 deletions

View File

@ -260,7 +260,7 @@ public:
void RequestFullScreen();
void ExitFullScreen();
// Called from AndroidJNI when we removed the fullscreen view.
// Called from nsAppShell when we removed the fullscreen view.
static void ExitFullScreen(jobject view);
#endif

View File

@ -250,8 +250,6 @@ public class GeckoAppShell
public static native void addPresentationSurface(Surface surface);
public static native void removePresentationSurface(Surface surface);
public static native void onFullScreenPluginHidden(View view);
private static LayerView sLayerView;
private static Rect sScreenSize;
@ -1489,6 +1487,9 @@ public class GeckoAppShell
}
}
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko")
public static native void onFullScreenPluginHidden(View view);
@WrapForJNI(calledFrom = "gecko")
public static void addFullScreenPluginView(View view) {
if (getGeckoInterface() != null)

View File

@ -115,25 +115,6 @@ Java_org_mozilla_gecko_GeckoAppShell_removePresentationSurface(JNIEnv * arg0, jc
#ifdef JNI_STUBS
typedef void (*Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden_t)(JNIEnv *, jclass, jobject);
static Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden_t f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden;
extern "C" NS_EXPORT void MOZ_JNICALL
Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden(JNIEnv * arg0, jclass arg1, jobject arg2) {
if (!f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden) {
arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
"JNI Function called before it was loaded");
return ;
}
f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden(arg0, arg1, arg2);
}
#endif
#ifdef JNI_BINDINGS
xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden", &f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden);
#endif
#ifdef JNI_STUBS
typedef void (*Java_org_mozilla_gecko_GeckoAppShell_syncNotifyObservers_t)(JNIEnv *, jclass, jstring, jstring);
static Java_org_mozilla_gecko_GeckoAppShell_syncNotifyObservers_t f_Java_org_mozilla_gecko_GeckoAppShell_syncNotifyObservers;
extern "C" NS_EXPORT void MOZ_JNICALL
@ -229,6 +210,25 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyAlertListener(JNIEnv * arg0, jclass a
#ifdef JNI_STUBS
typedef void (*Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden_t)(JNIEnv *, jclass, jobject);
static Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden_t f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden;
extern "C" NS_EXPORT void MOZ_JNICALL
Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden(JNIEnv * arg0, jclass arg1, jobject arg2) {
if (!f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden) {
arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
"JNI Function called before it was loaded");
return ;
}
f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden(arg0, arg1, arg2);
}
#endif
#ifdef JNI_BINDINGS
xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden", &f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden);
#endif
#ifdef JNI_STUBS
typedef void (*Java_org_mozilla_gecko_GeckoAppShell_cameraCallbackBridge_t)(JNIEnv *, jclass, jbyteArray);
static Java_org_mozilla_gecko_GeckoAppShell_cameraCallbackBridge_t f_Java_org_mozilla_gecko_GeckoAppShell_cameraCallbackBridge;
extern "C" NS_EXPORT void MOZ_JNICALL

View File

@ -90,28 +90,6 @@ Java_org_mozilla_gecko_GeckoAppShell_removePresentationSurface(JNIEnv* jenv, jcl
}
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden(JNIEnv* jenv, jclass, jobject view)
{
class ExitFullScreenRunnable : public Runnable {
public:
ExitFullScreenRunnable(jobject view) : mView(view) {}
NS_IMETHOD Run() override {
JNIEnv* const env = jni::GetGeckoThreadEnv();
nsPluginInstanceOwner::ExitFullScreen(mView);
env->DeleteGlobalRef(mView);
return NS_OK;
}
private:
jobject mView;
};
nsCOMPtr<nsIRunnable> runnable = new ExitFullScreenRunnable(jenv->NewGlobalRef(view));
NS_DispatchToMainThread(runnable);
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable(JNIEnv* jenv, jclass, jobject surfaceTexture, jint id)
{

View File

@ -78,7 +78,7 @@ template<class Impl>
class GeckoAppShell::Natives : public mozilla::jni::NativeImpl<GeckoAppShell, Impl>
{
public:
static const JNINativeMethod methods[6];
static const JNINativeMethod methods[7];
};
template<class Impl>
@ -96,6 +96,10 @@ const JNINativeMethod GeckoAppShell::Natives<Impl>::methods[] = {
mozilla::jni::NativeStub<GeckoAppShell::NotifyUriVisited_t, Impl>
::template Wrap<&Impl::NotifyUriVisited>),
mozilla::jni::MakeNativeMethod<GeckoAppShell::OnFullScreenPluginHidden_t>(
mozilla::jni::NativeStub<GeckoAppShell::OnFullScreenPluginHidden_t, Impl>
::template Wrap<&Impl::OnFullScreenPluginHidden>),
mozilla::jni::MakeNativeMethod<GeckoAppShell::OnLocationChanged_t>(
mozilla::jni::NativeStub<GeckoAppShell::OnLocationChanged_t, Impl>
::template Wrap<&Impl::OnLocationChanged>),

View File

@ -607,6 +607,9 @@ auto GeckoAppShell::NotifyWakeLockChanged(mozilla::jni::String::Param a0, mozill
return mozilla::jni::Method<NotifyWakeLockChanged_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1);
}
constexpr char GeckoAppShell::OnFullScreenPluginHidden_t::name[];
constexpr char GeckoAppShell::OnFullScreenPluginHidden_t::signature[];
constexpr char GeckoAppShell::OnLocationChanged_t::name[];
constexpr char GeckoAppShell::OnLocationChanged_t::signature[];

View File

@ -1630,6 +1630,24 @@ public:
static auto NotifyWakeLockChanged(mozilla::jni::String::Param, mozilla::jni::String::Param) -> void;
struct OnFullScreenPluginHidden_t {
typedef GeckoAppShell Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<
mozilla::jni::Object::Param> Args;
static constexpr char name[] = "onFullScreenPluginHidden";
static constexpr char signature[] =
"(Landroid/view/View;)V";
static const bool isStatic = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::UI;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::GECKO;
};
struct OnLocationChanged_t {
typedef GeckoAppShell Owner;
typedef void ReturnType;

View File

@ -323,6 +323,11 @@ public:
AndroidAlerts::NotifyListener(
aName->ToString(), aTopic->ToCString().get());
}
static void OnFullScreenPluginHidden(jni::Object::Param aView)
{
nsPluginInstanceOwner::ExitFullScreen(aView.Get());
}
};
nsAppShell::nsAppShell()