Bug 936008 - Avoid NPE when getting a zoom constraints update before the LayerView is fully initialized. r=wesj, a=bajaj
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 16 Jan 2014 16:14:08 -0500
changeset 176007 5bfa3b09e612bf272c28610180484426dedeefaa
parent 176006 a36a9cb0a86f036f5fc0a61ff6ce513dad45888d
child 176008 1f932ab62bfedeb4fbdfa29b5994642e7a47cec3
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj, bajaj
bugs936008
milestone28.0a2
Bug 936008 - Avoid NPE when getting a zoom constraints update before the LayerView is fully initialized. r=wesj, a=bajaj
mobile/android/base/gfx/GeckoLayerClient.java
mobile/android/base/gfx/LayerView.java
--- a/mobile/android/base/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/gfx/GeckoLayerClient.java
@@ -116,18 +116,25 @@ public class GeckoLayerClient implements
         mProgressiveUpdateDisplayPort = new DisplayPortMetrics();
         mLastProgressiveUpdateWasLowPrecision = false;
         mProgressiveUpdateWasInDanger = false;
 
         mForceRedraw = true;
         DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
         mViewportMetrics = new ImmutableViewportMetrics(displayMetrics)
                            .setViewportSize(view.getWidth(), view.getHeight());
+        mZoomConstraints = new ZoomConstraints(false);
+
+        Tab tab = Tabs.getInstance().getSelectedTab();
+        if (tab != null) {
+            mZoomConstraints = tab.getZoomConstraints();
+            mViewportMetrics = mViewportMetrics.setIsRTL(tab.getIsRTL());
+        }
+
         mFrameMetrics = mViewportMetrics;
-        mZoomConstraints = new ZoomConstraints(false);
 
         mPanZoomController = PanZoomController.Factory.create(this, view, eventDispatcher);
         mMarginsAnimator = new LayerMarginsAnimator(this, view);
         mView = view;
         mView.setListener(this);
         mContentDocumentIsDisplayed = true;
     }
 
--- a/mobile/android/base/gfx/LayerView.java
+++ b/mobile/android/base/gfx/LayerView.java
@@ -678,14 +678,14 @@ public class LayerView extends FrameLayo
     }
 
     public boolean isFullScreen() {
         return mFullScreen;
     }
 
     @Override
     public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
-        if (msg == Tabs.TabEvents.VIEWPORT_CHANGE && Tabs.getInstance().isSelectedTab(tab)) {
+        if (msg == Tabs.TabEvents.VIEWPORT_CHANGE && Tabs.getInstance().isSelectedTab(tab) && mLayerClient != null) {
             setZoomConstraints(tab.getZoomConstraints());
             setIsRTL(tab.getIsRTL());
         }
     }
 }