Backed out changeset 2e8206d7352e (bug 1200426) for Android Perma Failures

This commit is contained in:
Carsten "Tomcat" Book 2015-10-08 10:07:11 +02:00
parent 5dce766f74
commit 9fbe1f3c37
9 changed files with 45 additions and 41 deletions

View File

@ -73,6 +73,7 @@ public class GeckoEvent {
KEY_EVENT(1),
MOTION_EVENT(2),
SENSOR_EVENT(3),
PROCESS_OBJECT(4),
LOCATION_EVENT(5),
IME_EVENT(6),
SIZE_CHANGED(8),
@ -158,6 +159,8 @@ public class GeckoEvent {
public static final int ACTION_GAMEPAD_BUTTON = 1;
public static final int ACTION_GAMEPAD_AXES = 2;
public static final int ACTION_OBJECT_LAYER_CLIENT = 1;
private final int mType;
private int mAction;
private boolean mAckNeeded;
@ -219,6 +222,8 @@ public class GeckoEvent {
private float mGamepadButtonValue;
private float[] mGamepadValues;
private Object mObject;
private GeckoEvent(NativeGeckoEvent event) {
mType = event.value;
}
@ -579,6 +584,13 @@ public class GeckoEvent {
return event;
}
public static GeckoEvent createObjectEvent(final int action, final Object object) {
GeckoEvent event = GeckoEvent.get(NativeGeckoEvent.PROCESS_OBJECT);
event.mAction = action;
event.mObject = object;
return event;
}
public static GeckoEvent createLocationEvent(Location l) {
GeckoEvent event = GeckoEvent.get(NativeGeckoEvent.LOCATION_EVENT);
event.mLocation = l;

View File

@ -110,7 +110,6 @@ public class GeckoView extends LayerView
@WrapForJNI
private static final class Window extends JNIObject {
static native void open(Window instance, int width, int height);
static native void setLayerClient(Object client);
@Override protected native void disposeNative();
}
@ -143,14 +142,8 @@ public class GeckoView extends LayerView
GeckoAppShell.setLayerView(this);
initializeView(EventDispatcher.getInstance());
if (GeckoThread.isStateAtLeast(GeckoThread.State.JNI_READY)) {
Window.setLayerClient(getLayerClientObject());
} else {
GeckoThread.queueNativeCallUntil(GeckoThread.State.JNI_READY,
Window.class, "setLayerClient",
Object.class, getLayerClientObject());
}
GeckoAppShell.sendEventToGecko(GeckoEvent.createObjectEvent(
GeckoEvent.ACTION_OBJECT_LAYER_CLIENT, getLayerClientObject()));
// TODO: Fennec currently takes care of its own initialization, so this
// flag is a hack used in Fennec to prevent GeckoView initialization.

View File

@ -70,6 +70,7 @@ jfieldID AndroidGeckoEvent::jGamepadButtonField = 0;
jfieldID AndroidGeckoEvent::jGamepadButtonPressedField = 0;
jfieldID AndroidGeckoEvent::jGamepadButtonValueField = 0;
jfieldID AndroidGeckoEvent::jGamepadValuesField = 0;
jfieldID AndroidGeckoEvent::jObjectField = 0;
jclass AndroidPoint::jPointClass = 0;
jfieldID AndroidPoint::jXField = 0;
@ -177,6 +178,7 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
jGamepadButtonPressedField = geckoEvent.getField("mGamepadButtonPressed", "Z");
jGamepadButtonValueField = geckoEvent.getField("mGamepadButtonValue", "F");
jGamepadValuesField = geckoEvent.getField("mGamepadValues", "[F");
jObjectField = geckoEvent.getField("mObject", "Ljava/lang/Object;");
}
void
@ -471,6 +473,13 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
mMetaState = jenv->GetIntField(jobj, jMetaStateField);
break;
case PROCESS_OBJECT: {
const jobject obj = jenv->GetObjectField(jobj, jObjectField);
mObject.Init(obj, jenv);
jenv->DeleteLocalRef(obj);
break;
}
case LOCATION_EVENT: {
jobject location = jenv->GetObjectField(jobj, jLocationField);
mGeoPosition = AndroidLocation::CreateGeoPosition(jenv, location);

View File

@ -571,6 +571,7 @@ public:
float GamepadButtonValue() { return mGamepadButtonValue; }
const nsTArray<float>& GamepadValues() { return mGamepadValues; }
int RequestId() { return mCount; } // for convenience
const AutoGlobalWrappedJavaObject& Object() { return mObject; }
bool CanCoalesceWith(AndroidGeckoEvent* ae);
WidgetTouchEvent MakeTouchEvent(nsIWidget* widget);
MultiTouchInput MakeMultiTouchInput(nsIWidget* widget);
@ -623,6 +624,7 @@ protected:
mozilla::layers::ScrollableLayerGuid mApzGuid;
uint64_t mApzInputBlockId;
nsEventStatus mApzEventStatus;
AutoGlobalWrappedJavaObject mObject;
void ReadIntArray(nsTArray<int> &aVals,
JNIEnv *jenv,
@ -705,12 +707,15 @@ protected:
static jfieldID jGamepadButtonValueField;
static jfieldID jGamepadValuesField;
static jfieldID jObjectField;
public:
enum {
NATIVE_POKE = 0,
KEY_EVENT = 1,
MOTION_EVENT = 2,
SENSOR_EVENT = 3,
PROCESS_OBJECT = 4,
LOCATION_EVENT = 5,
IME_EVENT = 6,
SIZE_CHANGED = 8,
@ -781,6 +786,11 @@ public:
ACTION_GAMEPAD_BUTTON = 1,
ACTION_GAMEPAD_AXES = 2
};
enum {
ACTION_OBJECT_LAYER_CLIENT = 1,
dummy_object_enum_list_end
};
};
class nsJNIString : public nsString

View File

@ -93,11 +93,7 @@ public:
mozilla::jni::MakeNativeMethod<GeckoView::Window::Open_t>(
mozilla::jni::NativeStub<GeckoView::Window::Open_t, Impl>
::template Wrap<&Impl::Open>),
mozilla::jni::MakeNativeMethod<GeckoView::Window::SetLayerClient_t>(
mozilla::jni::NativeStub<GeckoView::Window::SetLayerClient_t, Impl>
::template Wrap<&Impl::SetLayerClient>)
::template Wrap<&Impl::Open>)
};
};

View File

@ -985,9 +985,6 @@ constexpr char GeckoView::Window::DisposeNative_t::signature[];
constexpr char GeckoView::Window::Open_t::name[];
constexpr char GeckoView::Window::Open_t::signature[];
constexpr char GeckoView::Window::SetLayerClient_t::name[];
constexpr char GeckoView::Window::SetLayerClient_t::signature[];
constexpr char PrefsHelper::name[];
constexpr char PrefsHelper::GetPrefsById_t::name[];

View File

@ -2394,22 +2394,6 @@ public:
mozilla::jni::ExceptionMode::ABORT;
};
public:
struct SetLayerClient_t {
typedef Window Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<
mozilla::jni::Object::Param> Args;
static constexpr char name[] = "setLayerClient";
static constexpr char signature[] =
"(Ljava/lang/Object;)V";
static const bool isStatic = true;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
public:
template<class Impl> class Natives;
};

View File

@ -434,6 +434,17 @@ nsAppShell::LegacyGeckoEvent::Run()
}
break;
case AndroidGeckoEvent::PROCESS_OBJECT: {
switch (curEvent->Action()) {
case AndroidGeckoEvent::ACTION_OBJECT_LAYER_CLIENT:
AndroidBridge::Bridge()->SetLayerClient(
widget::GeckoLayerClient::Ref::From(curEvent->Object().wrappedObject()));
break;
}
break;
}
case AndroidGeckoEvent::LOCATION_EVENT: {
if (!gLocationCallback)
break;

View File

@ -187,14 +187,6 @@ public:
static void Open(const jni::ClassObject::LocalRef& cls,
GeckoView::Window::Param gvWindow,
int32_t width, int32_t height);
// Set the active layer client object
static void SetLayerClient(jni::Object::Param client)
{
MOZ_ASSERT(NS_IsMainThread());
AndroidBridge::Bridge()->SetLayerClient(
widget::GeckoLayerClient::Ref::From(client.Get()));
}
};
void