Bug 908919 - Backout 1117002f074f:c03239a1493a (bug 906088) for causing Ts regressions; r=performance-is-job-1

This commit is contained in:
Nathan Froyd 2013-08-26 14:07:34 -04:00
parent c5e387c60c
commit 7ec6b9edf1
18 changed files with 166 additions and 230 deletions

View File

@ -48,22 +48,6 @@ public interface Actions {
*/
void sendGeckoEvent(String geckoEvent, String data);
/**
* Sends a preferences get event to Gecko.
*
* @param requestId The id of this request.
* @param prefNames The preferences being requested.
*/
void sendPreferencesGetEvent(int requestId, String[] prefNames);
/**
* Sends a preferences observe event to Gecko.
*
* @param requestId The id of this request.
* @param prefNames The preferences being requested.
*/
void sendPreferencesObserveEvent(int requestId, String[] prefNames);
/**
* Listens for a gecko event to be sent from the Gecko instance.
* The returned object can be used to test if the event has been

View File

@ -44,8 +44,6 @@ public class FennecNativeActions implements Actions {
private Method mRegisterEventListener;
private Method mUnregisterEventListener;
private Method mBroadcastEvent;
private Method mPreferencesGetEvent;
private Method mPreferencesObserveEvent;
private Method mSetDrawListener;
private Method mQuerySql;
private Object mRobocopApi;
@ -68,8 +66,6 @@ public class FennecNativeActions implements Actions {
mRegisterEventListener = mApiClass.getMethod("registerEventListener", String.class, mEventListenerClass);
mUnregisterEventListener = mApiClass.getMethod("unregisterEventListener", String.class, mEventListenerClass);
mBroadcastEvent = mApiClass.getMethod("broadcastEvent", String.class, String.class);
mPreferencesGetEvent = mApiClass.getMethod("preferencesGetEvent", Integer.TYPE, String[].class);
mPreferencesObserveEvent = mApiClass.getMethod("preferencesObserveEvent", Integer.TYPE, String[].class);
mSetDrawListener = mApiClass.getMethod("setDrawListener", mDrawListenerClass);
mQuerySql = mApiClass.getMethod("querySql", String.class, String.class);
@ -269,24 +265,6 @@ public class FennecNativeActions implements Actions {
}
}
private void sendPreferencesEvent(Method method, int requestId, String[] prefNames) {
try {
method.invoke(mRobocopApi, requestId, prefNames);
} catch (IllegalAccessException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
} catch (InvocationTargetException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
}
}
public void sendPreferencesGetEvent(int requestId, String[] prefNames) {
sendPreferencesEvent(mPreferencesGetEvent, requestId, prefNames);
}
public void sendPreferencesObserveEvent(int requestId, String[] prefNames) {
sendPreferencesEvent(mPreferencesObserveEvent, requestId, prefNames);
}
class DrawListenerProxy implements InvocationHandler {
private final PaintExpecter mPaintExpecter;

View File

@ -67,9 +67,7 @@ public class GeckoEvent {
REMOVE_OBSERVER(34),
LOW_MEMORY(35),
NETWORK_LINK_CHANGE(36),
TELEMETRY_HISTOGRAM_ADD(37),
PREFERENCES_OBSERVE(38),
PREFERENCES_GET(39);
TELEMETRY_HISTOGRAM_ADD(37);
public final int value;
@ -188,8 +186,6 @@ public class GeckoEvent {
private int mWidth;
private int mHeight;
private String[] mPrefNames;
private GeckoEvent(NativeGeckoEvent event) {
mType = event.value;
}
@ -693,20 +689,6 @@ public class GeckoEvent {
return event;
}
public static GeckoEvent createPreferencesObserveEvent(int requestId, String[] prefNames) {
GeckoEvent event = new GeckoEvent(NativeGeckoEvent.PREFERENCES_OBSERVE);
event.mCount = requestId;
event.mPrefNames = prefNames;
return event;
}
public static GeckoEvent createPreferencesGetEvent(int requestId, String[] prefNames) {
GeckoEvent event = new GeckoEvent(NativeGeckoEvent.PREFERENCES_GET);
event.mCount = requestId;
event.mPrefNames = prefNames;
return event;
}
public static GeckoEvent createLowMemoryEvent(int level) {
GeckoEvent event = new GeckoEvent(NativeGeckoEvent.LOW_MEMORY);
event.mMetaState = level;

View File

@ -664,7 +664,9 @@ public class GeckoPreferences
// Initialize preferences by requesting the preference values from Gecko
private int getGeckoPreferences(final PreferenceGroup screen, ArrayList<String> prefs) {
return PrefsHelper.getPrefs(prefs, new PrefsHelper.PrefHandlerBase() {
JSONArray jsonPrefs = new JSONArray(prefs);
return PrefsHelper.getPrefs(jsonPrefs, new PrefsHelper.PrefHandlerBase() {
private Preference getField(String prefName) {
return screen.findPreference(prefName);
}

View File

@ -13,7 +13,6 @@ import org.json.JSONObject;
import android.util.Log;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@ -28,18 +27,20 @@ public final class PrefsHelper {
private static int sUniqueRequestId = 1;
public static int getPref(String prefName, PrefHandler callback) {
return getPrefsInternal(new String[] { prefName }, callback);
JSONArray prefs = new JSONArray();
prefs.put(prefName);
return getPrefs(prefs, callback);
}
public static int getPrefs(String[] prefNames, PrefHandler callback) {
return getPrefsInternal(prefNames, callback);
JSONArray prefs = new JSONArray();
for (String p : prefNames) {
prefs.put(p);
}
return getPrefs(prefs, callback);
}
public static int getPrefs(ArrayList<String> prefNames, PrefHandler callback) {
return getPrefsInternal(prefNames.toArray(new String[prefNames.size()]), callback);
}
private static int getPrefsInternal(String[] prefNames, PrefHandler callback) {
public static int getPrefs(JSONArray prefNames, PrefHandler callback) {
int requestId;
synchronized (PrefsHelper.class) {
ensureRegistered();
@ -49,12 +50,25 @@ public final class PrefsHelper {
}
GeckoEvent event;
if (callback.isObserver()) {
event = GeckoEvent.createPreferencesObserveEvent(requestId, prefNames);
} else {
event = GeckoEvent.createPreferencesGetEvent(requestId, prefNames);
try {
JSONObject message = new JSONObject();
message.put("requestId", Integer.toString(requestId));
message.put("preferences", prefNames);
event = GeckoEvent.createBroadcastEvent(callback.isObserver() ?
"Preferences:Observe" : "Preferences:Get", message.toString());
GeckoAppShell.sendEventToGecko(event);
} catch (Exception e) {
Log.e(LOGTAG, "Error while composing Preferences:" +
(callback.isObserver() ? "Observe" : "Get") + " message", e);
// if we failed to send the message, drop our reference to the callback because
// otherwise it will leak since we will never get the response
synchronized (PrefsHelper.class) {
sCallbacks.remove(requestId);
}
return -1;
}
GeckoAppShell.sendEventToGecko(event);
return requestId;
}

View File

@ -35,14 +35,6 @@ public class RobocopAPI {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent(subject, data));
}
public void preferencesGetEvent(int requestId, String[] prefNames) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createPreferencesGetEvent(requestId, prefNames));
}
public void preferencesObserveEvent(int requestId, String[] prefNames) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createPreferencesObserveEvent(requestId, prefNames));
}
public void setDrawListener(GeckoLayerClient.DrawListener listener) {
GeckoAppShell.getLayerView().getLayerClient().setDrawListener(listener);
}

View File

@ -64,12 +64,13 @@ abstract class Axis {
}
static void initPrefs() {
final String[] prefs = { PREF_SCROLLING_FRICTION_FAST,
PREF_SCROLLING_FRICTION_SLOW,
PREF_SCROLLING_MAX_EVENT_ACCELERATION,
PREF_SCROLLING_OVERSCROLL_DECEL_RATE,
PREF_SCROLLING_OVERSCROLL_SNAP_LIMIT,
PREF_SCROLLING_MIN_SCROLLABLE_DISTANCE };
JSONArray prefs = new JSONArray();
prefs.put(PREF_SCROLLING_FRICTION_FAST);
prefs.put(PREF_SCROLLING_FRICTION_SLOW);
prefs.put(PREF_SCROLLING_MAX_EVENT_ACCELERATION);
prefs.put(PREF_SCROLLING_OVERSCROLL_DECEL_RATE);
prefs.put(PREF_SCROLLING_OVERSCROLL_SNAP_LIMIT);
prefs.put(PREF_SCROLLING_MIN_SCROLLABLE_DISTANCE);
PrefsHelper.getPrefs(prefs, new PrefsHelper.PrefHandlerBase() {
Map<String, Integer> mPrefs = new HashMap<String, Integer>();

View File

@ -61,18 +61,19 @@ final class DisplayPortCalculator {
}
static void initPrefs() {
final String[] prefs = { PREF_DISPLAYPORT_STRATEGY,
PREF_DISPLAYPORT_FM_MULTIPLIER,
PREF_DISPLAYPORT_FM_DANGER_X,
PREF_DISPLAYPORT_FM_DANGER_Y,
PREF_DISPLAYPORT_VB_MULTIPLIER,
PREF_DISPLAYPORT_VB_VELOCITY_THRESHOLD,
PREF_DISPLAYPORT_VB_REVERSE_BUFFER,
PREF_DISPLAYPORT_VB_DANGER_X_BASE,
PREF_DISPLAYPORT_VB_DANGER_Y_BASE,
PREF_DISPLAYPORT_VB_DANGER_X_INCR,
PREF_DISPLAYPORT_VB_DANGER_Y_INCR,
PREF_DISPLAYPORT_PB_VELOCITY_THRESHOLD };
JSONArray prefs = new JSONArray();
prefs.put(PREF_DISPLAYPORT_STRATEGY);
prefs.put(PREF_DISPLAYPORT_FM_MULTIPLIER);
prefs.put(PREF_DISPLAYPORT_FM_DANGER_X);
prefs.put(PREF_DISPLAYPORT_FM_DANGER_Y);
prefs.put(PREF_DISPLAYPORT_VB_MULTIPLIER);
prefs.put(PREF_DISPLAYPORT_VB_VELOCITY_THRESHOLD);
prefs.put(PREF_DISPLAYPORT_VB_REVERSE_BUFFER);
prefs.put(PREF_DISPLAYPORT_VB_DANGER_X_BASE);
prefs.put(PREF_DISPLAYPORT_VB_DANGER_Y_BASE);
prefs.put(PREF_DISPLAYPORT_VB_DANGER_X_INCR);
prefs.put(PREF_DISPLAYPORT_VB_DANGER_Y_INCR);
prefs.put(PREF_DISPLAYPORT_PB_VELOCITY_THRESHOLD);
PrefsHelper.getPrefs(prefs, new PrefsHelper.PrefHandlerBase() {
private Map<String, Integer> mValues = new HashMap<String, Integer>();

View File

@ -59,18 +59,21 @@ public class testAddonManager extends PixelTest {
mActions.sendGeckoEvent("Preferences:Set", jsonPref.toString());
// Wait for confirmation of the pref change before proceeding with the test.
final String[] prefNames = { "extensions.getAddons.browseAddons" };
final int ourRequestId = 0x7357;
JSONArray getPrefData = new JSONArray();
getPrefData.put("extensions.getAddons.browseAddons");
JSONObject message = new JSONObject();
message.put("requestId", "testAddonManager");
message.put("preferences", getPrefData);
Actions.RepeatedEventExpecter eventExpecter = mActions.expectGeckoEvent("Preferences:Data");
mActions.sendPreferencesGetEvent(ourRequestId, prefNames);
mActions.sendGeckoEvent("Preferences:Get", message.toString());
JSONObject data = null;
int requestId = -1;
String requestId = "";
// Wait until we get the correct "Preferences:Data" event
while (requestId != ourRequestId) {
while (!requestId.equals("testAddonManager")) {
data = new JSONObject(eventExpecter.blockForEventData());
requestId = data.getInt("requestId");
requestId = data.getString("requestId");
}
eventExpecter.unregisterListener();

View File

@ -29,7 +29,7 @@ import org.json.JSONObject;
*/
public class testDistribution extends ContentProviderTest {
private static final String MOCK_PACKAGE = "mock-package.zip";
private static final int PREF_REQUEST_ID = 0x7357;
private static final String PREF_REQUEST_ID = "testDistribution";
private Activity mActivity;
@ -86,23 +86,28 @@ public class testDistribution extends ContentProviderTest {
String prefTestInt = "distribution.test.int";
try {
final String[] prefNames = { prefID,
prefAbout,
prefVersion,
prefTestBoolean,
prefTestString,
prefTestInt };
JSONArray getPrefData = new JSONArray();
getPrefData.put(prefID);
getPrefData.put(prefAbout);
getPrefData.put(prefVersion);
getPrefData.put(prefTestBoolean);
getPrefData.put(prefTestString);
getPrefData.put(prefTestInt);
JSONObject message = new JSONObject();
message.put("requestId", PREF_REQUEST_ID);
message.put("preferences", getPrefData);
Actions.RepeatedEventExpecter eventExpecter = mActions.expectGeckoEvent("Preferences:Data");
mActions.sendPreferencesGetEvent(PREF_REQUEST_ID, prefNames);
mActions.sendGeckoEvent("Preferences:Get", message.toString());
JSONObject data = null;
int requestId = -1;
String requestId = "";
// Wait until we get the correct "Preferences:Data" event
while (requestId != PREF_REQUEST_ID) {
while (!requestId.equals(PREF_REQUEST_ID)) {
data = new JSONObject(eventExpecter.blockForEventData());
requestId = data.getInt("requestId");
requestId = data.getString("requestId");
}
eventExpecter.unregisterListener();
@ -167,18 +172,23 @@ public class testDistribution extends ContentProviderTest {
mActions.sendGeckoEvent("Preferences:Set", jsonPref.toString());
// Wait for confirmation of the pref change.
final String[] prefNames = { prefUseragentLocale };
JSONArray getPrefData = new JSONArray();
getPrefData.put(prefUseragentLocale);
JSONObject message = new JSONObject();
message.put("requestId", PREF_REQUEST_ID);
message.put("preferences", getPrefData);
Actions.RepeatedEventExpecter eventExpecter = mActions.expectGeckoEvent("Preferences:Data");
mActions.sendPreferencesGetEvent(PREF_REQUEST_ID, prefNames);
mActions.sendGeckoEvent("Preferences:Get", message.toString());
JSONObject data = null;
int requestId = -1;
String requestId = "";
// Wait until we get the correct "Preferences:Data" event
while (requestId != PREF_REQUEST_ID) {
while (!requestId.equals(PREF_REQUEST_ID)) {
data = new JSONObject(eventExpecter.blockForEventData());
requestId = data.getInt("requestId");
requestId = data.getString("requestId");
}
eventExpecter.unregisterListener();
@ -194,18 +204,25 @@ public class testDistribution extends ContentProviderTest {
String prefLocalizeableOverride = "distribution.test.localizeable-override";
try {
final String[] prefNames = { prefAbout, prefLocalizeable, prefLocalizeableOverride };
JSONArray getPrefData = new JSONArray();
getPrefData.put(prefAbout);
getPrefData.put(prefLocalizeable);
getPrefData.put(prefLocalizeableOverride);
JSONObject message = new JSONObject();
message.put("requestId", PREF_REQUEST_ID);
message.put("preferences", getPrefData);
Actions.RepeatedEventExpecter eventExpecter = mActions.expectGeckoEvent("Preferences:Data");
mActions.sendPreferencesGetEvent(PREF_REQUEST_ID, prefNames);
mActions.sendGeckoEvent("Preferences:Get", message.toString());
JSONObject data = null;
int requestId = -1;
String requestId = "";
// Wait until we get the correct "Preferences:Data" event
while (requestId != PREF_REQUEST_ID) {
while (!requestId.equals(PREF_REQUEST_ID)) {
data = new JSONObject(eventExpecter.blockForEventData());
requestId = data.getInt("requestId");
requestId = data.getString("requestId");
}
eventExpecter.unregisterListener();

View File

@ -81,19 +81,22 @@ public class testDoorHanger extends BaseTest {
boolean offlineAllowedByDefault = true;
try {
// Save offline-allow-by-default preferences first
final String[] prefNames = { "offline-apps.allow_by_default" };
final int ourRequestId = 0x7357;
JSONArray getPrefData = new JSONArray();
getPrefData.put("offline-apps.allow_by_default");
JSONObject message = new JSONObject();
message.put("requestId", "testDoorHanger");
message.put("preferences", getPrefData);
Actions.RepeatedEventExpecter eventExpecter = mActions.expectGeckoEvent("Preferences:Data");
mActions.sendPreferencesGetEvent(ourRequestId, prefNames);
mActions.sendGeckoEvent("Preferences:Get", message.toString());
JSONObject data = null;
int requestId = -1;
String requestId = "";
// Wait until we get the correct "Preferences:Data" event
while (requestId != ourRequestId) {
while (!requestId.equals("testDoorHanger")) {
data = new JSONObject(eventExpecter.blockForEventData());
requestId = data.getInt("requestId");
requestId = data.getString("requestId");
}
eventExpecter.unregisterListener();

View File

@ -126,18 +126,21 @@ public class testPasswordEncrypt extends BaseTest {
mActions.sendGeckoEvent("Preferences:Set", jsonPref.toString());
// Wait for confirmation of the pref change before proceeding with the test.
final String[] prefNames = { "privacy.masterpassword.enabled" };
final int ourRequestId = 0x73577;
JSONArray getPrefData = new JSONArray();
getPrefData.put("privacy.masterpassword.enabled");
JSONObject message = new JSONObject();
message.put("requestId", "testPasswordEncrypt");
message.put("preferences", getPrefData);
Actions.RepeatedEventExpecter eventExpecter = mActions.expectGeckoEvent("Preferences:Data");
mActions.sendPreferencesGetEvent(ourRequestId, prefNames);
mActions.sendGeckoEvent("Preferences:Get", message.toString());
JSONObject data = null;
int requestId = -1;
String requestId = "";
// Wait until we get the correct "Preferences:Data" event
while (requestId != ourRequestId) {
while (!requestId.equals("testPasswordEncrypt")) {
data = new JSONObject(eventExpecter.blockForEventData());
requestId = data.getInt("requestId");
requestId = data.getString("requestId");
}
} catch (Exception ex) {
mAsserter.ok(false, "exception in toggleMasterPassword", ex.toString());

View File

@ -16,7 +16,6 @@ import org.json.JSONObject;
*/
public class testPrefsObserver extends BaseTest {
private static final String PREF_TEST_PREF = "robocop.tests.dummy";
private static final int PREF_OBSERVE_REQUEST_ID = 0x7357;
private static final String PREF_REQUEST_ID = "testPrefsObserver";
private static final long PREF_TIMEOUT = 10000;
@ -41,15 +40,15 @@ public class testPrefsObserver extends BaseTest {
mAsserter.dumpLog("Waiting to check pref");
JSONObject data = null;
int requestId = -1;
String requestId = "";
while (requestId != PREF_OBSERVE_REQUEST_ID) {
while (!requestId.equals(PREF_REQUEST_ID)) {
data = new JSONObject(mExpecter.blockForEventData());
if (!mExpecter.eventReceived()) {
mAsserter.ok(false, "Checking pref is correct value", "Didn't receive pref");
return;
}
requestId = data.getInt("requestId");
requestId = data.getString("requestId");
}
JSONObject pref = data.getJSONArray("preferences").getJSONObject(0);
@ -81,14 +80,19 @@ public class testPrefsObserver extends BaseTest {
mAsserter.dumpLog("Setting up pref observer");
// Setup the pref observer
JSONArray getPrefData = new JSONArray();
getPrefData.put(PREF_TEST_PREF);
JSONObject message = new JSONObject();
message.put("requestId", PREF_REQUEST_ID);
message.put("preferences", getPrefData);
mExpecter = mActions.expectGeckoEvent("Preferences:Data");
mActions.sendPreferencesObserveEvent(PREF_OBSERVE_REQUEST_ID, new String[] { PREF_TEST_PREF });
mActions.sendGeckoEvent("Preferences:Observe", message.toString());
}
public void removePrefObserver() {
mAsserter.dumpLog("Removing pref observer");
mActions.sendGeckoEvent("Preferences:RemoveObservers", Integer.toString(PREF_OBSERVE_REQUEST_ID));
mActions.sendGeckoEvent("Preferences:RemoveObservers", PREF_REQUEST_ID);
}
public void testPrefsObserver() {

View File

@ -278,7 +278,9 @@ var BrowserApp = {
Services.obs.addObserver(this, "Session:Stop", false);
Services.obs.addObserver(this, "SaveAs:PDF", false);
Services.obs.addObserver(this, "Browser:Quit", false);
Services.obs.addObserver(this, "Preferences:Get", false);
Services.obs.addObserver(this, "Preferences:Set", false);
Services.obs.addObserver(this, "Preferences:Observe", false);
Services.obs.addObserver(this, "Preferences:RemoveObservers", false);
Services.obs.addObserver(this, "ScrollTo:FocusedInput", false);
Services.obs.addObserver(this, "Sanitize:ClearData", false);
@ -986,17 +988,16 @@ var BrowserApp = {
notifyPrefObservers: function(aPref) {
this._prefObservers[aPref].forEach(function(aRequestId) {
this.getPreferences(aRequestId, [aPref], 1);
let request = { requestId : aRequestId,
preferences : [aPref] };
this.getPreferences(request);
}, this);
},
handlePreferencesRequest: function handlePreferencesRequest(aRequestId,
aPrefNames,
aListen) {
getPreferences: function getPreferences(aPrefsRequest, aListen) {
let prefs = [];
for (let prefName of aPrefNames) {
for (let prefName of aPrefsRequest.preferences) {
let pref = {
name: prefName,
type: "",
@ -1005,9 +1006,9 @@ var BrowserApp = {
if (aListen) {
if (this._prefObservers[prefName])
this._prefObservers[prefName].push(aRequestId);
this._prefObservers[prefName].push(aPrefsRequest.requestId);
else
this._prefObservers[prefName] = [ aRequestId ];
this._prefObservers[prefName] = [ aPrefsRequest.requestId ];
Services.prefs.addObserver(prefName, this, false);
}
@ -1114,7 +1115,7 @@ var BrowserApp = {
sendMessageToJava({
type: "Preferences:Data",
requestId: aRequestId, // opaque request identifier, can be any string/int/whatever
requestId: aPrefsRequest.requestId, // opaque request identifier, can be any string/int/whatever
preferences: prefs
});
},
@ -1437,10 +1438,18 @@ var BrowserApp = {
this.saveAsPDF(browser);
break;
case "Preferences:Get":
this.getPreferences(JSON.parse(aData));
break;
case "Preferences:Set":
this.setPreferences(aData);
break;
case "Preferences:Observe":
this.getPreferences(JSON.parse(aData), true);
break;
case "Preferences:RemoveObservers":
this.removePreferenceObservers(aData);
break;
@ -1518,14 +1527,6 @@ var BrowserApp = {
return this.getTabForId(tabId);
},
getPreferences: function getPreferences(requestId, prefNames, count) {
this.handlePreferencesRequest(requestId, prefNames, false);
},
observePreferences: function observePreferences(requestId, prefNames, count) {
this.handlePreferencesRequest(requestId, prefNames, true);
},
// This method will print a list from fromIndex to toIndex, optionally
// selecting selIndex(if fromIndex<=selIndex<=toIndex)
showHistory: function(fromIndex, toIndex, selIndex) {

View File

@ -60,7 +60,6 @@ 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;
@ -267,7 +266,6 @@ 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");
@ -477,21 +475,6 @@ 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)
{
@ -507,38 +490,45 @@ AndroidGeckoEvent::ReadRectField(JNIEnv *jenv)
}
void
AndroidGeckoEvent::ReadStringFromJString(nsString &aString, JNIEnv *jenv,
jstring s)
AndroidGeckoEvent::ReadCharactersField(JNIEnv *jenv)
{
jstring s = (jstring) jenv->GetObjectField(wrapped_obj, jCharactersField);
if (!s) {
aString.SetIsVoid(true);
mCharacters.SetIsVoid(true);
return;
}
int len = jenv->GetStringLength(s);
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);
mCharacters.SetLength(len);
jenv->GetStringRegion(s, 0, len, mCharacters.BeginWriting());
}
void
AndroidGeckoEvent::ReadCharactersExtraField(JNIEnv *jenv)
{
jstring s = (jstring) jenv->GetObjectField(wrapped_obj, jCharactersExtraField);
ReadStringFromJString(mCharactersExtra, jenv, s);
if (!s) {
mCharactersExtra.SetIsVoid(true);
return;
}
int len = jenv->GetStringLength(s);
mCharactersExtra.SetLength(len);
jenv->GetStringRegion(s, 0, len, mCharactersExtra.BeginWriting());
}
void
AndroidGeckoEvent::ReadDataField(JNIEnv *jenv)
{
jstring s = (jstring) jenv->GetObjectField(wrapped_obj, jDataField);
ReadStringFromJString(mData, jenv, s);
if (!s) {
mData.SetIsVoid(true);
return;
}
int len = jenv->GetStringLength(s);
mData.SetLength(len);
jenv->GetStringRegion(s, 0, len, mData.BeginWriting());
}
void
@ -727,13 +717,6 @@ 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;
}

View File

@ -539,7 +539,6 @@ public:
const nsTArray<float>& Pressures() { return mPressures; }
const nsTArray<float>& Orientations() { return mOrientations; }
const nsTArray<nsIntPoint>& PointRadii() { return mPointRadii; }
const nsTArray<nsString>& PrefNames() { return mPrefNames; }
double X() { return mX; }
double Y() { return mY; }
double Z() { return mZ; }
@ -578,7 +577,6 @@ public:
RefCountedJavaObject* ByteBuffer() { return mByteBuffer; }
int Width() { return mWidth; }
int Height() { return mHeight; }
int RequestId() { return mCount; } // for convenience
nsTouchEvent MakeTouchEvent(nsIWidget* widget);
MultiTouchInput MakeMultiTouchInput(nsIWidget* widget);
void UnionRect(nsIntRect const& aRect);
@ -614,7 +612,6 @@ protected:
short mScreenOrientation;
nsRefPtr<RefCountedJavaObject> mByteBuffer;
int mWidth, mHeight;
nsTArray<nsString> mPrefNames;
void ReadIntArray(nsTArray<int> &aVals,
JNIEnv *jenv,
@ -628,14 +625,10 @@ protected:
JNIEnv *jenv,
jfieldID field,
int32_t count);
void ReadStringArray(nsTArray<nsString> &aStrings,
JNIEnv *jenv,
jfieldID field);
void ReadRectField(JNIEnv *jenv);
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);
@ -678,7 +671,6 @@ protected:
static jfieldID jRangeBackColorField;
static jfieldID jRangeLineColorField;
static jfieldID jLocationField;
static jfieldID jPrefNamesField;
static jfieldID jBandwidthField;
static jfieldID jCanBeMeteredField;
@ -725,8 +717,6 @@ public:
LOW_MEMORY = 35,
NETWORK_LINK_CHANGE = 36,
TELEMETRY_HISTOGRAM_ADD = 37,
PREFERENCES_OBSERVE = 38,
PREFERENCES_GET = 39,
dummy_java_enum_list_end
};

View File

@ -541,22 +541,6 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
mObserversHash.Remove(curEvent->Characters());
break;
case AndroidGeckoEvent::PREFERENCES_GET:
case AndroidGeckoEvent::PREFERENCES_OBSERVE: {
const nsTArray<nsString> &prefNames = curEvent->PrefNames();
size_t count = prefNames.Length();
nsAutoArrayPtr<const PRUnichar*> prefNamePtrs(new const PRUnichar*[count]);
for (size_t i = 0; i < count; ++i) {
prefNamePtrs[i] = prefNames[i].get();
}
if (curEvent->Type() == AndroidGeckoEvent::PREFERENCES_GET) {
mBrowserApp->GetPreferences(curEvent->RequestId(), prefNamePtrs, count);
} else {
mBrowserApp->ObservePreferences(curEvent->RequestId(), prefNamePtrs, count);
}
}
case AndroidGeckoEvent::LOW_MEMORY:
// TODO hook in memory-reduction stuff for different levels here
if (curEvent->MetaState() >= AndroidGeckoEvent::MEMORY_PRESSURE_MEDIUM) {

View File

@ -11,15 +11,9 @@ interface nsIBrowserTab : nsISupports {
readonly attribute float scale;
};
[scriptable, uuid(6455c49b-7497-4eb6-b137-c9e9b68462ec)]
[scriptable, uuid(d10377b4-1c90-493a-a532-63cb3f16ee2b)]
interface nsIAndroidBrowserApp : nsISupports {
nsIBrowserTab getBrowserTab(in int32_t tabId);
void getPreferences(in int32_t requestId,
[array, size_is(count)] in wstring prefNames,
in unsigned long count);
void observePreferences(in int32_t requestId,
[array, size_is(count)] in wstring prefNames,
in unsigned long count);
};
[scriptable, uuid(59cfcb35-69b7-47b2-8155-32b193272666)]
interface nsIAndroidViewport : nsISupports {