Back out 5a56a56a6481:a5969a01955b (bug 834414) to investigate whether it caused reftest-4 failures

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2013-01-25 20:03:50 -08:00
Родитель ab97cf0e00
Коммит ecc6770ff4
12 изменённых файлов: 73 добавлений и 113 удалений

Просмотреть файл

@ -232,8 +232,6 @@ abstract public class BrowserApp extends GeckoApp
super.onDestroy();
if (mAboutHomeContent != null)
mAboutHomeContent.onDestroy();
if (mBrowserToolbar != null)
mBrowserToolbar.onDestroy();
unregisterEventListener("CharEncoding:Data");
unregisterEventListener("CharEncoding:State");

Просмотреть файл

@ -1161,8 +1161,10 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
}
}
public void onDestroy() {
Tabs.unregisterOnTabsChangedListener(this);
public void destroy() {
// The action-items views are reused on rotation.
// Remove them from their parent, so they can be re-attached to new parent.
mActionItemBar.removeAllViews();
}
public boolean openOptionsMenu() {

Просмотреть файл

@ -1569,8 +1569,6 @@ abstract public class GeckoApp
LayerView layerView = (LayerView) findViewById(R.id.layer_view);
layerView.initializeView(GeckoAppShell.getEventDispatcher());
mLayerView = layerView;
// bind the GeckoEditable instance to the new LayerView
GeckoAppShell.notifyIMEEnabled(GeckoEditableListener.IME_STATE_DISABLED, "", "", "", false);
}
}
@ -2282,7 +2280,6 @@ abstract public class GeckoApp
mPromptService.destroy();
if (mTextSelection != null)
mTextSelection.destroy();
SiteIdentityPopup.clearInstance();
Tabs.getInstance().detachFromActivity(this);

Просмотреть файл

@ -533,6 +533,8 @@ public class GeckoAppShell
}
public static void runGecko(String apkPath, String args, String url, String type) {
WebAppAllocator.getInstance();
Looper.prepare();
sGeckoHandler = new Handler();

Просмотреть файл

@ -20,7 +20,6 @@ import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.util.Log;
import android.view.View;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@ -78,10 +77,9 @@ final class GeckoEditable
private final SpannableStringBuilder mText;
private final SpannableStringBuilder mChangedText;
private final Editable mProxy;
private final GeckoEditableListener mListener;
private final ActionQueue mActionQueue;
private View mCurrentView;
private GeckoEditableListener mListener;
private int mSavedSelectionStart;
private volatile int mGeckoUpdateSeqno;
private int mUIUpdateSeqno;
@ -258,8 +256,8 @@ final class GeckoEditable
Editable.class.getClassLoader(),
PROXY_INTERFACES, this);
mCurrentView = GeckoApp.mAppContext.getLayerView();
mListener = GeckoInputConnection.create(mCurrentView, this);
LayerView v = GeckoApp.mAppContext.getLayerView();
mListener = GeckoInputConnection.create(v, this);
}
private static void geckoPostToUI(Runnable runnable) {
@ -547,8 +545,10 @@ final class GeckoEditable
@Override
public void notifyIMEEnabled(final int state, final String typeHint,
final String modeHint, final String actionHint) {
// Because we want to be able to bind GeckoEditable to the newest LayerView instance,
// this can be called from the Java UI thread in addition to the Gecko thread.
if (DEBUG) {
// GeckoEditableListener methods should all be called from the Gecko thread
GeckoApp.assertOnGeckoThread();
}
geckoPostToUI(new Runnable() {
public void run() {
// Make sure there are no other things going on
@ -558,13 +558,10 @@ final class GeckoEditable
// InputConnectionHandler.onCreateInputConnection
LayerView v = GeckoApp.mAppContext.getLayerView();
if (v != null) {
if (v != mCurrentView) {
mCurrentView = v;
mListener = GeckoInputConnection.create(v, GeckoEditable.this);
v.setInputConnectionHandler((InputConnectionHandler)mListener);
}
mListener.notifyIMEEnabled(state, typeHint, modeHint, actionHint);
v.setInputConnectionHandler((InputConnectionHandler)mListener);
}
mListener.notifyIMEEnabled(state, typeHint,
modeHint, actionHint);
}
});
}

Просмотреть файл

@ -31,7 +31,7 @@ public class GeckoThread extends Thread implements GeckoEventListener {
private static LaunchState sLaunchState = LaunchState.Launching;
private Intent mIntent;
private final Intent mIntent;
private final String mUri;
GeckoThread(Intent intent, String uri) {
@ -41,44 +41,8 @@ public class GeckoThread extends Thread implements GeckoEventListener {
GeckoAppShell.getEventDispatcher().registerEventListener("Gecko:Ready", this);
}
private String initGeckoEnvironment() {
// At some point while loading the gecko libs our default locale gets set
// so just save it to locale here and reset it as default after the join
Locale locale = Locale.getDefault();
GeckoApp app = GeckoApp.mAppContext;
String resourcePath = app.getApplication().getPackageResourcePath();
GeckoAppShell.setupGeckoEnvironment(app);
GeckoAppShell.loadSQLiteLibs(app, resourcePath);
GeckoAppShell.loadNSSLibs(app, resourcePath);
GeckoAppShell.loadGeckoLibs(resourcePath);
Locale.setDefault(locale);
Resources res = app.getBaseContext().getResources();
Configuration config = res.getConfiguration();
config.locale = locale;
res.updateConfiguration(config, res.getDisplayMetrics());
return resourcePath;
}
private String getTypeFromAction(String action) {
if (action != null && action.startsWith(GeckoApp.ACTION_WEBAPP_PREFIX)) {
return "-webapp";
}
if (GeckoApp.ACTION_BOOKMARK.equals(action)) {
return "-bookmark";
}
return null;
}
private String addCustomProfileArg(String args) {
String profile = GeckoApp.sIsUsingCustomProfile ? "" : (" -P " + GeckoApp.mAppContext.getProfile().getName());
return (args != null ? args : "") + profile;
}
public void run() {
// Here we start the GfxInfo thread, which will query OpenGL
// system information for Gecko. This must be done early enough that the data will be
// ready by the time it's needed to initialize the LayerManager (it takes about 100 ms
@ -88,17 +52,46 @@ public class GeckoThread extends Thread implements GeckoEventListener {
GeckoAppShell.sGfxInfoThread = new GfxInfoThread();
GeckoAppShell.sGfxInfoThread.start();
String path = initGeckoEnvironment();
final GeckoApp app = GeckoApp.mAppContext;
// At some point while loading the gecko libs our default locale gets set
// so just save it to locale here and reset it as default after the join
Locale locale = Locale.getDefault();
String resourcePath = app.getApplication().getPackageResourcePath();
GeckoAppShell.setupGeckoEnvironment(app);
GeckoAppShell.loadSQLiteLibs(app, resourcePath);
GeckoAppShell.loadNSSLibs(app, resourcePath);
GeckoAppShell.loadGeckoLibs(resourcePath);
Locale.setDefault(locale);
Resources res = app.getBaseContext().getResources();
Configuration config = res.getConfiguration();
config.locale = locale;
res.updateConfiguration(config, res.getDisplayMetrics());
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - runGecko");
String args = addCustomProfileArg(mIntent.getStringExtra("args"));
String type = getTypeFromAction(mIntent.getAction());
mIntent = null;
// find the right intent type
final String action = mIntent.getAction();
String type = null;
if (action != null && action.startsWith(GeckoApp.ACTION_WEBAPP_PREFIX))
type = "-webapp";
else if (GeckoApp.ACTION_BOOKMARK.equals(action))
type = "-bookmark";
String args = mIntent.getStringExtra("args");
String profile = GeckoApp.sIsUsingCustomProfile ? "" : (" -P " + app.getProfile().getName());
args = (args != null ? args : "") + profile;
// and then fire us up
Log.i(LOGTAG, "RunGecko - args = " + args);
GeckoAppShell.runGecko(path, args, mUri, type);
GeckoAppShell.runGecko(app.getApplication().getPackageResourcePath(),
args,
mUri,
type);
}
public void handleMessage(String event, JSONObject message) {

Просмотреть файл

@ -29,8 +29,6 @@ public class SiteIdentityPopup extends PopupWindow {
public static final String VERIFIED = "verified";
public static final String IDENTIFIED = "identified";
private static SiteIdentityPopup sInstance;
private Resources mResources;
private boolean mInflated;
@ -50,15 +48,12 @@ public class SiteIdentityPopup extends PopupWindow {
mInflated = false;
}
public static synchronized SiteIdentityPopup getInstance() {
if (sInstance == null) {
sInstance = new SiteIdentityPopup();
}
return sInstance;
private static class InstanceHolder {
private static final SiteIdentityPopup INSTANCE = new SiteIdentityPopup();
}
public static synchronized void clearInstance() {
sInstance = null;
public static SiteIdentityPopup getInstance() {
return SiteIdentityPopup.InstanceHolder.INSTANCE;
}
private void init() {

Просмотреть файл

@ -12,6 +12,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import android.content.ContentResolver;
import android.database.ContentObserver;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
@ -53,6 +54,8 @@ public class Tab {
private ZoomConstraints mZoomConstraints;
private ArrayList<View> mPluginViews;
private HashMap<Object, Layer> mPluginLayers;
private ContentResolver mContentResolver;
private ContentObserver mContentObserver;
private int mBackgroundColor = Color.WHITE;
private int mState;
private Bitmap mThumbnailBitmap;
@ -89,13 +92,17 @@ public class Tab {
mPluginViews = new ArrayList<View>();
mPluginLayers = new HashMap<Object, Layer>();
mState = GeckoApp.shouldShowProgress(url) ? STATE_SUCCESS : STATE_LOADING;
}
private ContentResolver getContentResolver() {
return Tabs.getInstance().getContentResolver();
mContentResolver = Tabs.getInstance().getContentResolver();
mContentObserver = new ContentObserver(null) {
public void onChange(boolean selfChange) {
updateBookmark();
}
};
BrowserDB.registerBookmarkObserver(mContentResolver, mContentObserver);
}
public void onDestroy() {
BrowserDB.unregisterContentObserver(mContentResolver, mContentObserver);
Tabs.getInstance().notifyListeners(this, Tabs.TabEvents.CLOSED);
}
@ -339,7 +346,7 @@ public class Tab {
Tabs.getInstance().notifyListeners(this, Tabs.TabEvents.MENU_UPDATED);
}
void updateBookmark() {
private void updateBookmark() {
GeckoAppShell.getHandler().post(new Runnable() {
public void run() {
final String url = getURL();
@ -347,8 +354,8 @@ public class Tab {
return;
if (url.equals(getURL())) {
mBookmark = BrowserDB.isBookmark(getContentResolver(), url);
mReadingListItem = BrowserDB.isReadingListItem(getContentResolver(), url);
mBookmark = BrowserDB.isBookmark(mContentResolver, url);
mReadingListItem = BrowserDB.isReadingListItem(mContentResolver, url);
}
Tabs.getInstance().notifyListeners(Tab.this, Tabs.TabEvents.MENU_UPDATED);
@ -363,7 +370,7 @@ public class Tab {
if (url == null)
return;
BrowserDB.addBookmark(getContentResolver(), mTitle, url);
BrowserDB.addBookmark(mContentResolver, mTitle, url);
}
});
}
@ -375,7 +382,7 @@ public class Tab {
if (url == null)
return;
BrowserDB.removeBookmarksWithURL(getContentResolver(), url);
BrowserDB.removeBookmarksWithURL(mContentResolver, url);
}
});
}
@ -509,7 +516,7 @@ public class Tab {
if (url == null)
return;
BrowserDB.updateThumbnailForUrl(getContentResolver(), url, mThumbnail);
BrowserDB.updateThumbnailForUrl(mContentResolver, url, mThumbnail);
} catch (Exception e) {
// ignore
}

Просмотреть файл

@ -16,7 +16,6 @@ import android.accounts.AccountManager;
import android.accounts.OnAccountsUpdateListener;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.ContentObserver;
import android.net.Uri;
import android.util.Log;
import android.widget.Toast;
@ -56,7 +55,6 @@ public class Tabs implements GeckoEventListener {
private static AtomicInteger sTabId = new AtomicInteger(0);
private GeckoApp mActivity;
private ContentObserver mContentObserver;
private Tabs() {
registerEventListener("SessionHistory:New");
@ -84,9 +82,6 @@ public class Tabs implements GeckoEventListener {
persistAllTabs();
}
}, GeckoAppShell.getHandler(), false);
if (mContentObserver != null) {
BrowserDB.registerBookmarkObserver(getContentResolver(), mContentObserver);
}
}
public void detachFromActivity(GeckoApp activity) {
@ -94,31 +89,13 @@ public class Tabs implements GeckoEventListener {
mAccountManager.removeOnAccountsUpdatedListener(mAccountListener);
mAccountListener = null;
}
if (mContentObserver != null) {
BrowserDB.unregisterContentObserver(getContentResolver(), mContentObserver);
}
}
public int getCount() {
return mTabs.size();
}
private void lazyRegisterBookmarkObserver() {
if (mContentObserver == null) {
mContentObserver = new ContentObserver(null) {
public void onChange(boolean selfChange) {
for (Tab tab : mTabs.values()) {
tab.updateBookmark();
}
}
};
BrowserDB.registerBookmarkObserver(getContentResolver(), mContentObserver);
}
}
private Tab addTab(int id, String url, boolean external, int parentId, String title, boolean isPrivate) {
lazyRegisterBookmarkObserver();
final Tab tab = isPrivate ? new PrivateTab(id, url, external, parentId, title) :
new Tab(id, url, external, parentId, title);
mTabs.put(id, tab);

Просмотреть файл

@ -183,7 +183,6 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
if (mFrameRateLayer != null) {
mFrameRateLayer.destroy();
}
Tabs.unregisterOnTabsChangedListener(this);
}
void onSurfaceCreated(EGLConfig config) {

Просмотреть файл

@ -123,9 +123,6 @@ public class LayerView extends FrameLayout {
if (mRenderer != null) {
mRenderer.destroy();
}
if (mTouchEventHandler != null) {
mTouchEventHandler.destroy();
}
}
@Override

Просмотреть файл

@ -141,10 +141,6 @@ public final class TouchEventHandler implements Tabs.OnTabsChangedListener {
Tabs.registerOnTabsChangedListener(this);
}
void destroy() {
Tabs.unregisterOnTabsChangedListener(this);
}
/* This function MUST be called on the UI thread */
public boolean handleEvent(MotionEvent event) {
// if we don't have gecko listeners, just dispatch the event