mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 906088 - part 2 - factor out reading an nsString from a Java string in AndroidJavaWrappers.cpp; r=blassey
We duplicate code in several places, and we're going to need this same code for reading a String[].
This commit is contained in:
parent
9b166be0c7
commit
5a8ea91082
@ -428,45 +428,38 @@ AndroidGeckoEvent::ReadRectField(JNIEnv *jenv)
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoEvent::ReadCharactersField(JNIEnv *jenv)
|
||||
AndroidGeckoEvent::ReadStringFromJString(nsString &aString, JNIEnv *jenv,
|
||||
jstring s)
|
||||
{
|
||||
jstring s = (jstring) jenv->GetObjectField(wrapped_obj, jCharactersField);
|
||||
if (!s) {
|
||||
mCharacters.SetIsVoid(true);
|
||||
aString.SetIsVoid(true);
|
||||
return;
|
||||
}
|
||||
|
||||
int len = jenv->GetStringLength(s);
|
||||
mCharacters.SetLength(len);
|
||||
jenv->GetStringRegion(s, 0, len, mCharacters.BeginWriting());
|
||||
aString.SetLength(len);
|
||||
jenv->GetStringRegion(s, 0, len, aString.BeginWriting());
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoEvent::ReadCharactersField(JNIEnv *jenv)
|
||||
{
|
||||
jstring s = (jstring) jenv->GetObjectField(wrapped_obj, jCharactersField);
|
||||
ReadStringFromJString(mCharacters, jenv, s);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoEvent::ReadCharactersExtraField(JNIEnv *jenv)
|
||||
{
|
||||
jstring s = (jstring) jenv->GetObjectField(wrapped_obj, jCharactersExtraField);
|
||||
if (!s) {
|
||||
mCharactersExtra.SetIsVoid(true);
|
||||
return;
|
||||
}
|
||||
|
||||
int len = jenv->GetStringLength(s);
|
||||
mCharactersExtra.SetLength(len);
|
||||
jenv->GetStringRegion(s, 0, len, mCharactersExtra.BeginWriting());
|
||||
ReadStringFromJString(mCharactersExtra, jenv, s);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoEvent::ReadDataField(JNIEnv *jenv)
|
||||
{
|
||||
jstring s = (jstring) jenv->GetObjectField(wrapped_obj, jDataField);
|
||||
if (!s) {
|
||||
mData.SetIsVoid(true);
|
||||
return;
|
||||
}
|
||||
|
||||
int len = jenv->GetStringLength(s);
|
||||
mData.SetLength(len);
|
||||
jenv->GetStringRegion(s, 0, len, mData.BeginWriting());
|
||||
ReadStringFromJString(mData, jenv, s);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -639,6 +639,7 @@ protected:
|
||||
void ReadCharactersField(JNIEnv *jenv);
|
||||
void ReadCharactersExtraField(JNIEnv *jenv);
|
||||
void ReadDataField(JNIEnv *jenv);
|
||||
void ReadStringFromJString(nsString &aString, JNIEnv *jenv, jstring s);
|
||||
|
||||
uint32_t ReadDomKeyLocation(JNIEnv* jenv, jobject jGeckoEventObj);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user