mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 852704 - Part 2: Fix JNI crash caused by DomKeyLocation's change from int to enum. r=blassey
This commit is contained in:
parent
5335cded7a
commit
0a2d8d2c6c
@ -6,6 +6,7 @@
|
||||
#include "AndroidJavaWrappers.h"
|
||||
#include "AndroidBridge.h"
|
||||
#include "nsIAndroidBridge.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -54,6 +55,9 @@ jfieldID AndroidGeckoEvent::jByteBufferField = 0;
|
||||
jfieldID AndroidGeckoEvent::jWidthField = 0;
|
||||
jfieldID AndroidGeckoEvent::jHeightField = 0;
|
||||
|
||||
jclass AndroidGeckoEvent::jDomKeyLocationClass = 0;
|
||||
jfieldID AndroidGeckoEvent::jDomKeyLocationValueField = 0;
|
||||
|
||||
jclass AndroidPoint::jPointClass = 0;
|
||||
jfieldID AndroidPoint::jXField = 0;
|
||||
jfieldID AndroidPoint::jYField = 0;
|
||||
@ -248,6 +252,10 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
|
||||
jByteBufferField = getField("mBuffer", "Ljava/nio/ByteBuffer;");
|
||||
jWidthField = getField("mWidth", "I");
|
||||
jHeightField = getField("mHeight", "I");
|
||||
|
||||
// Init GeckoEvent.DomKeyLocation enum
|
||||
jDomKeyLocationClass = getClassGlobalRef("org/mozilla/gecko/GeckoEvent$DomKeyLocation");
|
||||
jDomKeyLocationValueField = getField("value", "I");
|
||||
}
|
||||
|
||||
void
|
||||
@ -497,6 +505,18 @@ AndroidGeckoEvent::Init(int aType, nsIntRect const& aRect)
|
||||
mRect = aRect;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
AndroidGeckoEvent::ReadDomKeyLocation(JNIEnv* jenv, jobject jGeckoEventObj)
|
||||
{
|
||||
jobject enumObject = jenv->GetObjectField(jGeckoEventObj,
|
||||
jDomKeyLocationField);
|
||||
MOZ_ASSERT(enumObject);
|
||||
int enumValue = jenv->GetIntField(enumObject, jDomKeyLocationValueField);
|
||||
MOZ_ASSERT(enumValue >= nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD &&
|
||||
enumValue <= nsIDOMKeyEvent::DOM_KEY_LOCATION_JOYSTICK);
|
||||
return static_cast<uint32_t>(enumValue);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
|
||||
{
|
||||
@ -520,7 +540,7 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
|
||||
case IME_KEY_EVENT:
|
||||
mTime = jenv->GetLongField(jobj, jTimeField);
|
||||
mMetaState = jenv->GetIntField(jobj, jMetaStateField);
|
||||
mDomKeyLocation = jenv->GetIntField(jobj, jDomKeyLocationField);
|
||||
mDomKeyLocation = ReadDomKeyLocation(jenv, jobj);
|
||||
mFlags = jenv->GetIntField(jobj, jFlagsField);
|
||||
mKeyCode = jenv->GetIntField(jobj, jKeyCodeField);
|
||||
mUnicodeChar = jenv->GetIntField(jobj, jUnicodeCharField);
|
||||
|
@ -633,7 +633,7 @@ public:
|
||||
nsAString& CharactersExtra() { return mCharactersExtra; }
|
||||
int KeyCode() { return mKeyCode; }
|
||||
int MetaState() { return mMetaState; }
|
||||
int DomKeyLocation() { return mDomKeyLocation; }
|
||||
uint32_t DomKeyLocation() { return mDomKeyLocation; }
|
||||
bool IsAltPressed() const { return (mMetaState & AndroidKeyEvent::META_ALT_MASK) != 0; }
|
||||
bool IsShiftPressed() const { return (mMetaState & AndroidKeyEvent::META_SHIFT_MASK) != 0; }
|
||||
bool IsCtrlPressed() const { return (mMetaState & AndroidKeyEvent::META_CTRL_MASK) != 0; }
|
||||
@ -673,7 +673,7 @@ protected:
|
||||
nsTArray<float> mPressures;
|
||||
nsIntRect mRect;
|
||||
int mFlags, mMetaState;
|
||||
int mDomKeyLocation;
|
||||
uint32_t mDomKeyLocation;
|
||||
int mKeyCode, mUnicodeChar, mBaseUnicodeChar;
|
||||
int mRepeatCount;
|
||||
int mCount;
|
||||
@ -707,6 +707,8 @@ protected:
|
||||
void ReadCharactersField(JNIEnv *jenv);
|
||||
void ReadCharactersExtraField(JNIEnv *jenv);
|
||||
|
||||
uint32_t ReadDomKeyLocation(JNIEnv* jenv, jobject jGeckoEventObj);
|
||||
|
||||
static jclass jGeckoEventClass;
|
||||
static jfieldID jActionField;
|
||||
static jfieldID jTypeField;
|
||||
@ -755,6 +757,9 @@ protected:
|
||||
static jfieldID jWidthField;
|
||||
static jfieldID jHeightField;
|
||||
|
||||
static jclass jDomKeyLocationClass;
|
||||
static jfieldID jDomKeyLocationValueField;
|
||||
|
||||
public:
|
||||
enum {
|
||||
NATIVE_POKE = 0,
|
||||
|
Loading…
Reference in New Issue
Block a user