Backout bug 828349, bug 835022 for robocop orange and exception from Tabs.getDisplayCount.
authorMs2ger <ms2ger@gmail.com>
Sat, 16 Feb 2013 10:36:05 +0100
changeset 131994 00c09b326fee9d461fe6409b6df90ce521557725
parent 131988 c3e41bbb40a58d0e77d27c49a4baba8edf6e5588
child 131995 014e88baa216ccf0234687b038b79920fcd59427
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs828349, 835022
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backout bug 828349, bug 835022 for robocop orange and exception from Tabs.getDisplayCount.
mobile/android/base/BrowserApp.java
mobile/android/base/BrowserToolbar.java
mobile/android/base/Tabs.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -511,17 +511,17 @@ abstract public class BrowserApp extends
         showTabs(TabsPanel.Panel.PRIVATE_TABS);
     }
 
     public void showRemoteTabs() {
         showTabs(TabsPanel.Panel.REMOTE_TABS);
     }
 
     private void showTabs(TabsPanel.Panel panel) {
-        if (Tabs.getInstance().getDisplayCount() == 0)
+        if (Tabs.getInstance().getCount() == 0)
             return;
 
         mTabsPanel.show(panel);
     }
 
     public void hideTabs() {
         mTabsPanel.hide();
     }
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -396,31 +396,31 @@ public class BrowserToolbar implements V
             case STOP:
                 if (Tabs.getInstance().isSelectedTab(tab)) {
                     updateBackButton(tab.canDoBack());
                     updateForwardButton(tab.canDoForward());
                     setProgressVisibility(false);
                 }
                 break;
             case RESTORED:
-                updateTabCount(Tabs.getInstance().getDisplayCount());
+                updateTabCount(Tabs.getInstance().getCount());
                 break;
             case SELECTED:
                 mAnimateSiteSecurity = false;
                 // fall through
             case LOCATION_CHANGE:
             case LOAD_ERROR:
                 if (Tabs.getInstance().isSelectedTab(tab)) {
                     refresh();
                 }
                 mAnimateSiteSecurity = true;
                 break;
             case CLOSED:
             case ADDED:
-                updateTabCountAndAnimate(Tabs.getInstance().getDisplayCount());
+                updateTabCountAndAnimate(Tabs.getInstance().getCount());
                 if (Tabs.getInstance().isSelectedTab(tab)) {
                     updateBackButton(tab.canDoBack());
                     updateForwardButton(tab.canDoForward());
                 }
                 break;
         }
     }
 
@@ -1151,17 +1151,17 @@ public class BrowserToolbar implements V
         if (tab != null) {
             String url = tab.getURL();
             setTitle(tab.getDisplayTitle());
             setFavicon(tab.getFavicon());
             setProgressVisibility(tab.getState() == Tab.STATE_LOADING);
             setSecurityMode(tab.getSecurityMode());
             setReaderMode(tab.getReaderEnabled());
             setShadowVisibility(true);
-            updateTabCount(Tabs.getInstance().getDisplayCount());
+            updateTabCount(Tabs.getInstance().getCount());
             updateBackButton(tab.canDoBack());
             updateForwardButton(tab.canDoForward());
 
             mAddressBarBg.setPrivateMode(tab.isPrivate());
 
             if (mAwesomeBar instanceof GeckoButton)
                 ((GeckoButton) mAwesomeBar).setPrivateMode(tab.isPrivate());
             else if (mAwesomeBar instanceof GeckoRelativeLayout)
--- a/mobile/android/base/Tabs.java
+++ b/mobile/android/base/Tabs.java
@@ -94,25 +94,18 @@ public class Tabs implements GeckoEventL
             mAccountManager.removeOnAccountsUpdatedListener(mAccountListener);
             mAccountListener = null;
         }
         if (mContentObserver != null) {
             BrowserDB.unregisterContentObserver(getContentResolver(), mContentObserver);
         }
     }
 
-    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() {
         if (mContentObserver == null) {
             mContentObserver = new ContentObserver(null) {
                 public void onChange(boolean selfChange) {
                     for (Tab tab : mTabs.values()) {
                         tab.updateBookmark();
@@ -170,42 +163,25 @@ public class Tabs implements GeckoEventL
             }
         });
 
         // Pass a message to Gecko to update tab state in BrowserApp
         GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Tab:Selected", String.valueOf(tab.getId())));
         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;
-            }
-        }
-        return null;
+    public Tab getTabAt(int index) {
+        if (index >= 0 && index < mOrder.size())
+            return mOrder.get(index);
+        else
+            return null;
     }
 
     /**
      * Gets the selected tab.
      *
      * The selected tab can be null if we're doing a session restore after a
      * crash and Gecko isn't ready yet.
      *
@@ -218,17 +194,17 @@ public class Tabs implements GeckoEventL
     public boolean isSelectedTab(Tab tab) {
         if (mSelectedTab == null)
             return false;
 
         return tab == mSelectedTab;
     }
 
     public Tab getTab(int id) {
-        if (mTabs.size() == 0)
+        if (getCount() == 0)
             return null;
 
         if (!mTabs.containsKey(id))
            return null;
 
         return mTabs.get(id);
     }
 
@@ -257,25 +233,20 @@ public class Tabs implements GeckoEventL
     }
 
     /** Return the tab that will be selected by default after this one is closed */
     public Tab getNextTab(Tab tab) {
         Tab selectedTab = getSelectedTab();
         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) {
             // If the next tab is a sibling, switch to it. Otherwise go back to the parent.
             if (nextTab != null && nextTab.getParentId() == tab.getParentId())
                 return nextTab;
             else
                 return parent;