Bug 906088 - part 3 - add Preferences events to AndroidGeckoEvent; r=blassey

This is just the C++ side of things; it's simpler to have this code split out as
a separate patch to review.
This commit is contained in:
Nathan Froyd
2013-09-04 09:58:08 -04:00
parent d6fe2ec206
commit 60c54e4e7f
2 changed files with 33 additions and 0 deletions

View File

@@ -61,6 +61,7 @@ jfieldID AndroidGeckoEvent::jScreenOrientationField = 0;
jfieldID AndroidGeckoEvent::jByteBufferField = 0;
jfieldID AndroidGeckoEvent::jWidthField = 0;
jfieldID AndroidGeckoEvent::jHeightField = 0;
jfieldID AndroidGeckoEvent::jPrefNamesField = 0;
jclass AndroidGeckoEvent::jDomKeyLocationClass = 0;
jfieldID AndroidGeckoEvent::jDomKeyLocationValueField = 0;
@@ -204,6 +205,7 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
jByteBufferField = getField("mBuffer", "Ljava/nio/ByteBuffer;");
jWidthField = getField("mWidth", "I");
jHeightField = getField("mHeight", "I");
jPrefNamesField = getField("mPrefNames", "[Ljava/lang/String;");
// Init GeckoEvent.DomKeyLocation enum
jDomKeyLocationClass = getClassGlobalRef("org/mozilla/gecko/GeckoEvent$DomKeyLocation");
@@ -413,6 +415,21 @@ AndroidGeckoEvent::ReadFloatArray(nsTArray<float> &aVals,
jenv->ReleaseFloatArrayElements(jFloatArray, vals, JNI_ABORT);
}
void
AndroidGeckoEvent::ReadStringArray(nsTArray<nsString> &array,
JNIEnv *jenv,
jfieldID field)
{
jarray jArray = (jarray)jenv->GetObjectField(wrapped_obj, field);
jsize length = jenv->GetArrayLength(jArray);
jobjectArray jStringArray = (jobjectArray)jArray;
nsString *strings = array.AppendElements(length);
for (jsize i = 0; i < length; ++i) {
jstring javastring = (jstring) jenv->GetObjectArrayElement(jStringArray, i);
ReadStringFromJString(strings[i], jenv, javastring);
}
}
void
AndroidGeckoEvent::ReadRectField(JNIEnv *jenv)
{
@@ -648,6 +665,13 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
break;
}
case PREFERENCES_OBSERVE:
case PREFERENCES_GET: {
ReadStringArray(mPrefNames, jenv, jPrefNamesField);
mCount = jenv->GetIntField(jobj, jCountField);
break;
}
default:
break;
}