Bug 951776 - Remove graphical corruption when tapping Google search suggestion. r=sriram, a=lsblakk
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 14 Nov 2013 14:13:54 -0800
changeset 162117 b84d04cf97c5
parent 162116 461ca599b662
child 162118 91b88e38da1e
child 162120 fea4ff79bb20
push id418
push usermichael.l.comella@gmail.com
push date2013-12-19 20:15 +0000
treeherdermozilla-release@b84d04cf97c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram, lsblakk
bugs951776
milestone26.0
Bug 951776 - Remove graphical corruption when tapping Google search suggestion. r=sriram, a=lsblakk
mobile/android/base/BrowserApp.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -1411,17 +1411,16 @@ abstract public class BrowserApp extends
     }
 
     private void commitEditingMode() {
         if (!mBrowserToolbar.isEditing()) {
             return;
         }
 
         final String url = mBrowserToolbar.commitEdit();
-        animateHideHomePager();
         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.
@@ -1500,32 +1499,32 @@ 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);
+        // Since the underlying LayerView is set visible in hideHomePager, we would
+        // ordinarily want to call it first. However, hideBrowserSearch changes the
+        // visibility of the HomePager and hideHomePager will take no action if the
+        // HomePager is hidden, so we want to call hideBrowserSearch to restore the
+        // HomePager visibility first.
+        hideBrowserSearch();
         animateHideHomePager();
-        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) {
@@ -1648,16 +1647,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();
@@ -1666,16 +1668,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 {