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
parent ab97cf0e00
commit ecc6770ff4
12 changed files with 73 additions and 113 deletions

View File

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

View File

@ -1161,8 +1161,10 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
} }
} }
public void onDestroy() { public void destroy() {
Tabs.unregisterOnTabsChangedListener(this); // 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() { public boolean openOptionsMenu() {

View File

@ -1569,8 +1569,6 @@ abstract public class GeckoApp
LayerView layerView = (LayerView) findViewById(R.id.layer_view); LayerView layerView = (LayerView) findViewById(R.id.layer_view);
layerView.initializeView(GeckoAppShell.getEventDispatcher()); layerView.initializeView(GeckoAppShell.getEventDispatcher());
mLayerView = layerView; 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(); mPromptService.destroy();
if (mTextSelection != null) if (mTextSelection != null)
mTextSelection.destroy(); mTextSelection.destroy();
SiteIdentityPopup.clearInstance();
Tabs.getInstance().detachFromActivity(this); Tabs.getInstance().detachFromActivity(this);

View File

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

View File

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

View File

@ -31,7 +31,7 @@ public class GeckoThread extends Thread implements GeckoEventListener {
private static LaunchState sLaunchState = LaunchState.Launching; private static LaunchState sLaunchState = LaunchState.Launching;
private Intent mIntent; private final Intent mIntent;
private final String mUri; private final String mUri;
GeckoThread(Intent intent, String uri) { GeckoThread(Intent intent, String uri) {
@ -41,44 +41,8 @@ public class GeckoThread extends Thread implements GeckoEventListener {
GeckoAppShell.getEventDispatcher().registerEventListener("Gecko:Ready", this); 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() { public void run() {
// Here we start the GfxInfo thread, which will query OpenGL // 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 // 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 // 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 = new GfxInfoThread();
GeckoAppShell.sGfxInfoThread.start(); 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"); Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - runGecko");
String args = addCustomProfileArg(mIntent.getStringExtra("args")); // find the right intent type
String type = getTypeFromAction(mIntent.getAction()); final String action = mIntent.getAction();
mIntent = null; 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 // and then fire us up
Log.i(LOGTAG, "RunGecko - args = " + args); 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) { public void handleMessage(String event, JSONObject message) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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