зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1365599 - Make Tabs use the window event dispatcher rather than global in some instances. r=jchen
This commit is contained in:
Родитель
0adcd1d3e9
Коммит
3ee02fbbea
|
@ -1418,7 +1418,7 @@ public abstract class GeckoApp extends GeckoActivity
|
|||
"ToggleChrome:Show",
|
||||
null);
|
||||
|
||||
Tabs.getInstance().attachToContext(this, mLayerView);
|
||||
Tabs.getInstance().attachToContext(this, mLayerView, getAppEventDispatcher());
|
||||
Tabs.registerOnTabsChangedListener(this);
|
||||
|
||||
// Use global layout state change to kick off additional initialization
|
||||
|
@ -1512,7 +1512,7 @@ public abstract class GeckoApp extends GeckoActivity
|
|||
|
||||
// If we are doing a restore, send the parsed session data to Gecko.
|
||||
if (!mIsRestoringActivity) {
|
||||
EventDispatcher.getInstance().dispatch("Session:Restore", restoreMessage);
|
||||
getAppEventDispatcher().dispatch("Session:Restore", restoreMessage);
|
||||
}
|
||||
|
||||
// Make sure sessionstore.old is either updated or deleted as necessary.
|
||||
|
@ -2489,6 +2489,7 @@ public abstract class GeckoApp extends GeckoActivity
|
|||
super.onDestroy();
|
||||
|
||||
Tabs.unregisterOnTabsChangedListener(this);
|
||||
Tabs.getInstance().detachFromContext();
|
||||
|
||||
if (mShutdownOnDestroy) {
|
||||
GeckoApplication.shutdown(!mRestartOnShutdown ? null : new Intent(
|
||||
|
|
|
@ -101,6 +101,7 @@ public class Tabs implements BundleEventListener {
|
|||
private volatile boolean mInitialTabsAdded;
|
||||
|
||||
private Context mAppContext;
|
||||
private EventDispatcher mEventDispatcher;
|
||||
private LayerView mLayerView;
|
||||
private ContentObserver mBookmarksContentObserver;
|
||||
private PersistTabsRunnable mPersistTabsRunnable;
|
||||
|
@ -165,18 +166,11 @@ public class Tabs implements BundleEventListener {
|
|||
mPrivateClearColor = Color.RED;
|
||||
}
|
||||
|
||||
public synchronized void attachToContext(Context context, LayerView layerView) {
|
||||
public synchronized void attachToContext(Context context, LayerView layerView, EventDispatcher eventDispatcher) {
|
||||
final Context appContext = context.getApplicationContext();
|
||||
if (mAppContext == appContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAppContext != null) {
|
||||
// This should never happen.
|
||||
Log.w(LOGTAG, "The application context has changed!");
|
||||
}
|
||||
|
||||
mAppContext = appContext;
|
||||
mEventDispatcher = eventDispatcher;
|
||||
mLayerView = layerView;
|
||||
mPrivateClearColor = ContextCompat.getColor(context, R.color.tabs_tray_grey_pressed);
|
||||
mAccountManager = AccountManager.get(appContext);
|
||||
|
@ -198,6 +192,10 @@ public class Tabs implements BundleEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void detachFromContext() {
|
||||
mLayerView = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tab count corresponding to the category and private state of the
|
||||
* selected tab.
|
||||
|
@ -332,6 +330,7 @@ public class Tabs implements BundleEventListener {
|
|||
// Pass a message to Gecko to update tab state in BrowserApp.
|
||||
final GeckoBundle data = new GeckoBundle(1);
|
||||
data.putInt("id", tab.getId());
|
||||
mEventDispatcher.dispatch("Tab:Selected", data);
|
||||
EventDispatcher.getInstance().dispatch("Tab:Selected", data);
|
||||
return tab;
|
||||
}
|
||||
|
@ -473,7 +472,7 @@ public class Tabs implements BundleEventListener {
|
|||
final GeckoBundle data = new GeckoBundle(2);
|
||||
data.putInt("tabId", tabId);
|
||||
data.putBoolean("showUndoToast", showUndoToast);
|
||||
EventDispatcher.getInstance().dispatch("Tab:Closed", data);
|
||||
mEventDispatcher.dispatch("Tab:Closed", data);
|
||||
}
|
||||
|
||||
/** Return the tab that will be selected by default after this one is closed */
|
||||
|
@ -1083,7 +1082,7 @@ public class Tabs implements BundleEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
EventDispatcher.getInstance().dispatch("Tab:Load", data);
|
||||
mEventDispatcher.dispatch("Tab:Load", data);
|
||||
|
||||
if (tabToSelect == null) {
|
||||
return null;
|
||||
|
@ -1277,7 +1276,7 @@ public class Tabs implements BundleEventListener {
|
|||
data.putInt("fromPosition", fromPosition);
|
||||
data.putInt("toTabId", toTabId);
|
||||
data.putInt("toPosition", toPosition);
|
||||
EventDispatcher.getInstance().dispatch("Tab:Move", data);
|
||||
mEventDispatcher.dispatch("Tab:Move", data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -87,7 +87,7 @@ var FindHelper = {
|
|||
this._initialViewport = JSON.stringify(this._targetTab.getViewport());
|
||||
this._viewportChanged = false;
|
||||
|
||||
GlobalEventDispatcher.registerListener(this, [
|
||||
WindowEventDispatcher.registerListener(this, [
|
||||
"Tab:Selected",
|
||||
]);
|
||||
},
|
||||
|
@ -109,7 +109,7 @@ var FindHelper = {
|
|||
this._initialViewport = null;
|
||||
this._viewportChanged = false;
|
||||
|
||||
GlobalEventDispatcher.unregisterListener(this, [
|
||||
WindowEventDispatcher.unregisterListener(this, [
|
||||
"Tab:Selected",
|
||||
]);
|
||||
},
|
||||
|
|
|
@ -389,11 +389,15 @@ var BrowserApp = {
|
|||
|
||||
Services.androidBridge.browserApp = this;
|
||||
|
||||
GlobalEventDispatcher.registerListener(this, [
|
||||
WindowEventDispatcher.registerListener(this, [
|
||||
"Session:Restore",
|
||||
"Tab:Load",
|
||||
"Tab:Selected",
|
||||
"Tab:Closed",
|
||||
"Tab:Move",
|
||||
]);
|
||||
|
||||
GlobalEventDispatcher.registerListener(this, [
|
||||
"Browser:LoadManifest",
|
||||
"Browser:Quit",
|
||||
"Fonts:Reload",
|
||||
|
@ -1851,6 +1855,10 @@ var BrowserApp = {
|
|||
break;
|
||||
}
|
||||
|
||||
case "Session:Restore":
|
||||
GlobalEventDispatcher.dispatch("Session:Restore", data);
|
||||
break;
|
||||
|
||||
case "Session:Stop":
|
||||
browser.stop();
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче