Bug 722661 - Prevent animation of restored OOM tabs. r=mfinkle

This commit is contained in:
Brian Nicholson 2012-11-07 18:34:54 -08:00
parent 4dbcec42c7
commit 3de3c4fed4
4 changed files with 16 additions and 16 deletions

View File

@ -378,9 +378,9 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
}
break;
case RESTORED:
updateTabCount(Tabs.getInstance().getCount());
break;
case SELECTED:
// We should not animate the lock icon when switching or
// restoring tabs.
mAnimateSiteSecurity = false;
// fall through
case LOCATION_CHANGE:

View File

@ -1686,8 +1686,12 @@ abstract public class GeckoApp
}
}
// Move the session file if it exists
if (mRestoreMode != RESTORE_OOM) {
if (mRestoreMode == RESTORE_OOM) {
// If we successfully did an OOM restore, we now have tab stubs
// from the last session. Any future tabs should be animated.
Tabs.getInstance().notifyListeners(null, Tabs.TabEvents.RESTORED);
} else {
// Move the session file if it exists
getProfile().moveSessionFile();
}
@ -1695,6 +1699,7 @@ abstract public class GeckoApp
// Show telemetry door hanger if we aren't restoring a session
if (mRestoreMode == RESTORE_NONE) {
Tabs.getInstance().notifyListeners(null, Tabs.TabEvents.RESTORED);
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Telemetry:Prompt", null));
}

View File

@ -30,7 +30,7 @@ public class Tabs implements GeckoEventListener {
private Tab mSelectedTab;
private final HashMap<Integer, Tab> mTabs = new HashMap<Integer, Tab>();
private final CopyOnWriteArrayList<Tab> mOrder = new CopyOnWriteArrayList<Tab>();
private boolean mRestoringSession;
private volatile boolean mInitialTabsAdded;
// Keeps track of how much has happened since we last updated our persistent tab store.
private volatile int mScore = 0;
@ -63,7 +63,6 @@ public class Tabs implements GeckoEventListener {
registerEventListener("Tab:Close");
registerEventListener("Tab:Select");
registerEventListener("Content:LocationChange");
registerEventListener("Session:RestoreBegin");
registerEventListener("Session:RestoreEnd");
registerEventListener("Reader:Added");
registerEventListener("Reader:Removed");
@ -102,7 +101,8 @@ public class Tabs implements GeckoEventListener {
mTabs.put(id, tab);
mOrder.add(tab);
if (!mRestoringSession) {
// Suppress the ADDED event to prevent animation of tabs created via session restore
if (mInitialTabsAdded) {
notifyListeners(tab, TabEvents.ADDED);
}
@ -284,10 +284,7 @@ public class Tabs implements GeckoEventListener {
if (tab != null) {
tab.handleLocationChange(message);
}
} else if (event.equals("Session:RestoreBegin")) {
mRestoringSession = true;
} else if (event.equals("Session:RestoreEnd")) {
mRestoringSession = false;
notifyListeners(null, TabEvents.RESTORED);
} else if (event.equals("Reader:Added")) {
final boolean success = message.getBoolean("success");
@ -406,6 +403,9 @@ public class Tabs implements GeckoEventListener {
case LOCATION_CHANGE:
mScore += SCORE_INCREMENT_TAB_LOCATION_CHANGE;
break;
case RESTORED:
mInitialTabsAdded = true;
break;
// When one tab is deselected, another one is always selected, so only
// increment the score once. When tabs are added/closed, they are also

View File

@ -308,12 +308,6 @@ var BrowserApp = {
},
restoreSession: function (restoringOOM, sessionString) {
sendMessageToJava({
gecko: {
type: "Session:RestoreBegin"
}
});
// Be ready to handle any restore failures by making sure we have a valid tab opened
let restoreCleanup = {
observe: function (aSubject, aTopic, aData) {
@ -326,6 +320,7 @@ var BrowserApp = {
});
}
// Let Java know we're done restoring tabs so tabs added after this can be animated
sendMessageToJava({
gecko: {
type: "Session:RestoreEnd"