Bug 935604 - Part 2: Typing about:home directly does not break tab. r=sriram, a=lsblakk
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 14 Nov 2013 14:13:54 -0800
changeset 167482 bedeac830273c18e25bc5c573ef549ad7d03c568
parent 167481 bfa55569c7e9ce0de196e1dc452c1b2376d15773
child 167483 e75cd4c5c2a182b82bff4b8980520f489f101200
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram, lsblakk
bugs935604
milestone27.0a2
Bug 935604 - Part 2: Typing about:home directly does not break tab. r=sriram, a=lsblakk
mobile/android/base/BrowserApp.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -1426,30 +1426,30 @@ abstract public class BrowserApp extends
     }
 
     private void commitEditingMode() {
         if (!mBrowserToolbar.isEditing()) {
             return;
         }
 
         final String url = mBrowserToolbar.commitEdit();
+        hideBrowserSearch();
 
         // HACK: We don't know the url that will be loaded when hideHomePager is initially called
         // in BrowserToolbar's onStopEditing listener so on the awesomescreen, hideHomePager will
         // use the url "about:home" and return without taking any action. hideBrowserSearch is
         // then called, but since hideHomePager changes both HomePager and LayerView visibility
         // and exited without taking an action, no Views are displayed and graphical corruption is
         // visible instead.
         //
         // Here we call hideHomePager for the second time with the URL to be loaded so that
         // hideHomePager is called with the correct state for the upcoming page load.
         //
         // Expected to be fixed by bug 915825.
         hideHomePager(url);
-        hideBrowserSearch();
 
         // Don't do anything if the user entered an empty URL.
         if (TextUtils.isEmpty(url)) {
             return;
         }
 
         // If the URL doesn't look like a search query, just load it.
         if (!StringUtils.isSearchQuery(url, true)) {
@@ -1518,32 +1518,27 @@ abstract public class BrowserApp extends
 
     private boolean dismissEditingMode() {
         if (!mBrowserToolbar.isEditing()) {
             return false;
         }
 
         mBrowserToolbar.cancelEdit();
 
-        // Resetting the visibility of HomePager, which might have been hidden
-        // by the filterEditingMode().
-        mHomePager.setVisibility(View.VISIBLE);
         hideHomePager();
         hideBrowserSearch();
 
         return true;
     }
 
     void filterEditingMode(String searchTerm, AutocompleteHandler handler) {
         if (TextUtils.isEmpty(searchTerm)) {
-            mHomePager.setVisibility(View.VISIBLE);
             hideBrowserSearch();
         } else {
             showBrowserSearch();
-            mHomePager.setVisibility(View.INVISIBLE);
             mBrowserSearch.filter(searchTerm, handler);
         }
     }
 
     /**
      * Shows or hides the home pager for the given tab.
      */
     private void updateHomePagerForTab(Tab tab) {
@@ -1658,16 +1653,19 @@ abstract public class BrowserApp extends
 
     private void showBrowserSearch() {
         if (mBrowserSearch.getUserVisibleHint()) {
             return;
         }
 
         mBrowserSearchContainer.setVisibility(View.VISIBLE);
 
+        // Prevent overdraw by hiding the underlying HomePager View.
+        mHomePager.setVisibility(View.INVISIBLE);
+
         final FragmentManager fm = getSupportFragmentManager();
 
         // In certain situations, showBrowserSearch() can be called immediately after hideBrowserSearch()
         // (see bug 925012). Because of an Android bug (http://code.google.com/p/android/issues/detail?id=61179),
         // calling FragmentTransaction#add immediately after FragmentTransaction#remove won't add the fragment's
         // view to the layout. Calling FragmentManager#executePendingTransactions before re-adding the fragment
         // prevents this issue.
         fm.executePendingTransactions();
@@ -1676,16 +1674,20 @@ abstract public class BrowserApp extends
         mBrowserSearch.setUserVisibleHint(true);
     }
 
     private void hideBrowserSearch() {
         if (!mBrowserSearch.getUserVisibleHint()) {
             return;
         }
 
+        // To prevent overdraw, the HomePager is hidden when BrowserSearch is displayed:
+        // reverse that.
+        mHomePager.setVisibility(View.VISIBLE);
+
         mBrowserSearchContainer.setVisibility(View.INVISIBLE);
 
         getSupportFragmentManager().beginTransaction()
                 .remove(mBrowserSearch).commitAllowingStateLoss();
         mBrowserSearch.setUserVisibleHint(false);
     }
 
     private class HideTabsTouchListener implements TouchEventInterceptor {