Bug 1299922 - Keep surface covered until it has been painted when switching tabs in Fennec r=jchen
authorRandall Barker <rbarker@mozilla.com>
Thu, 01 Sep 2016 16:31:15 -0700
changeset 312930 eb90834c4f107ebdeb369702d66e5257ff352d36
parent 312929 a981c221c363453eac4fefff27073ce41c1edf02
child 312931 5aabb19fcdfe384ced77636f8556d3488e37d51f
push id30665
push usercbook@mozilla.com
push dateWed, 07 Sep 2016 15:20:43 +0000
treeherdermozilla-central@95acb9299faf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1299922
milestone51.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
Bug 1299922 - Keep surface covered until it has been painted when switching tabs in Fennec r=jchen
mobile/android/base/java/org/mozilla/gecko/Tabs.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/LayerView.java
--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -254,17 +254,17 @@ public class Tabs implements GeckoEventL
         if (tab == null || oldTab == tab) {
             return null;
         }
 
         mSelectedTab = tab;
         notifyListeners(tab, TabEvents.SELECTED);
 
         if (mLayerView != null) {
-            mLayerView.setClearColor(tab.isPrivate() ? mPrivateClearColor : Color.WHITE);
+            mLayerView.setClearColor(getTabColor(tab));
         }
 
         if (oldTab != null) {
             notifyListeners(oldTab, TabEvents.UNSELECTED);
         }
 
         // Pass a message to Gecko to update tab state in BrowserApp.
         GeckoAppShell.notifyObservers("Tab:Selected", String.valueOf(tab.getId()));
@@ -667,16 +667,20 @@ public class Tabs implements GeckoEventL
                 mInitialTabsAdded = true;
                 break;
 
             // When one tab is deselected, another one is always selected, so only
             // queue a single persist operation. When tabs are added/closed, they
             // are also selected/unselected, so it would be redundant to also listen
             // for ADDED/CLOSED events.
             case SELECTED:
+                if (mLayerView != null) {
+                    mLayerView.setSurfaceBackgroundColor(getTabColor(tab));
+                    mLayerView.setPaintState(LayerView.PAINT_START);
+                }
                 queuePersistAllTabs();
             case UNSELECTED:
                 tab.onChange();
                 break;
             default:
                 break;
         }
     }
@@ -978,9 +982,17 @@ public class Tabs implements GeckoEventL
 
     /**
      * Gets the next tab ID.
      */
     @JNITarget
     public static int getNextTabId() {
         return sTabId.getAndIncrement();
     }
+
+    private int getTabColor(Tab tab) {
+        if (tab != null) {
+            return tab.isPrivate() ? mPrivateClearColor : Color.WHITE;
+        }
+
+        return Color.WHITE;
+    }
 }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/LayerView.java
@@ -389,17 +389,17 @@ public class LayerView extends ScrollVie
     public PointF convertViewPointToLayerPoint(PointF viewPoint) {
         return mLayerClient.convertViewPointToLayerPoint(viewPoint);
     }
 
     public Matrix getMatrixForLayerRectToViewRect() {
         return mLayerClient.getMatrixForLayerRectToViewRect();
     }
 
-    void setSurfaceBackgroundColor(int newColor) {
+    public void setSurfaceBackgroundColor(int newColor) {
         if (mSurfaceView != null) {
             mSurfaceView.setBackgroundColor(newColor);
         }
     }
 
     public void setIsRTL(boolean aIsRTL) {
         mLayerClient.setIsRTL(aIsRTL);
     }