Backout bug 828349, bug 835022 for robocop orange and exception from Tabs.getDisplayCount.

This commit is contained in:
Ms2ger 2013-02-16 10:36:05 +01:00
Родитель f19a26b30b
Коммит c3d8c3db2b
3 изменённых файлов: 16 добавлений и 45 удалений

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

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

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

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

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

@ -99,15 +99,8 @@ public class Tabs implements GeckoEventListener {
}
}
public int getDisplayCount() {
boolean getPrivate = mSelectedTab != null && mSelectedTab.isPrivate();
int count = 0;
for (Tab tab : mTabs.values()) {
if (tab.isPrivate() == getPrivate) {
count++;
}
}
return count;
public int getCount() {
return mTabs.size();
}
private void lazyRegisterBookmarkObserver() {
@ -175,31 +168,14 @@ public class Tabs implements GeckoEventListener {
return tab;
}
private int getIndexOf(Tab tab) {
public int getIndexOf(Tab tab) {
return mOrder.lastIndexOf(tab);
}
private Tab getNextTabFrom(Tab tab, boolean getPrivate) {
int numTabs = mOrder.size();
int index = getIndexOf(tab);
for (int i = index + 1; i < numTabs; i++) {
Tab next = mOrder.get(i);
if (next.isPrivate() == getPrivate) {
return next;
}
}
return null;
}
private Tab getPreviousTabFrom(Tab tab, boolean getPrivate) {
int numTabs = mOrder.size();
int index = getIndexOf(tab);
for (int i = index - 1; i >= 0; i--) {
Tab prev = mOrder.get(i);
if (prev.isPrivate() == getPrivate) {
return prev;
}
}
public Tab getTabAt(int index) {
if (index >= 0 && index < mOrder.size())
return mOrder.get(index);
else
return null;
}
@ -223,7 +199,7 @@ public class Tabs implements GeckoEventListener {
}
public Tab getTab(int id) {
if (mTabs.size() == 0)
if (getCount() == 0)
return null;
if (!mTabs.containsKey(id))
@ -262,15 +238,10 @@ public class Tabs implements GeckoEventListener {
if (selectedTab != tab)
return selectedTab;
boolean getPrivate = tab.isPrivate();
Tab nextTab = getNextTabFrom(tab, getPrivate);
int index = getIndexOf(tab);
Tab nextTab = getTabAt(index + 1);
if (nextTab == null)
nextTab = getPreviousTabFrom(tab, getPrivate);
if (nextTab == null && getPrivate) {
// If there are no private tabs remaining, get the last normal tab
Tab lastTab = mOrder.get(mOrder.size() - 1);
nextTab = getPreviousTabFrom(lastTab, false);
}
nextTab = getTabAt(index - 1);
Tab parent = getTab(tab.getParentId());
if (parent != null) {