Bug 835022 - Switch to correct tab when a tab is closed. r=mfinkle

This commit is contained in:
Brian Nicholson 2013-03-11 16:09:14 -07:00
parent e5e5a90814
commit ca84939aa6
3 changed files with 14 additions and 7 deletions

View File

@ -798,7 +798,7 @@ abstract public class BrowserApp extends GeckoApp
}
private void showTabs(TabsPanel.Panel panel) {
if (Tabs.getInstance().getCount() == 0)
if (Tabs.getInstance().getDisplayCount() == 0)
return;
mTabsPanel.show(panel);

View File

@ -449,7 +449,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
}
break;
case RESTORED:
updateTabCount(Tabs.getInstance().getCount());
updateTabCount(Tabs.getInstance().getDisplayCount());
break;
case SELECTED:
mAnimateSiteSecurity = false;
@ -463,7 +463,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
break;
case CLOSED:
case ADDED:
updateTabCountAndAnimate(Tabs.getInstance().getCount());
updateTabCountAndAnimate(Tabs.getInstance().getDisplayCount());
if (Tabs.getInstance().isSelectedTab(tab)) {
updateBackButton(tab.canDoBack());
updateForwardButton(tab.canDoForward());
@ -1313,7 +1313,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
setSecurityMode(tab.getSecurityMode());
setReaderMode(tab.getReaderEnabled());
setShadowVisibility(true);
updateTabCount(Tabs.getInstance().getCount());
updateTabCount(Tabs.getInstance().getDisplayCount());
updateBackButton(tab.canDoBack());
updateForwardButton(tab.canDoForward());

View File

@ -104,8 +104,15 @@ public class Tabs implements GeckoEventListener {
}
}
public int getCount() {
return mTabs.size();
public int getDisplayCount() {
boolean getPrivate = mSelectedTab != null && mSelectedTab.isPrivate();
int count = 0;
for (Tab tab : mTabs.values()) {
if (tab.isPrivate() == getPrivate) {
count++;
}
}
return count;
}
private void lazyRegisterBookmarkObserver() {
@ -206,7 +213,7 @@ public class Tabs implements GeckoEventListener {
}
public Tab getTab(int id) {
if (getCount() == 0)
if (mTabs.size() == 0)
return null;
if (!mTabs.containsKey(id))