Bug 936008 - Avoid NPE when getting a zoom constraints update before the LayerView is fully initialized. r=wesj
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 16 Jan 2014 16:14:08 -0500
changeset 163881 5327f5b72d9800f6d72da085c616e834cd3b9b8a
parent 163880 52058b81ff1fc95c4ab97e325c0b1de0805486fc
child 163882 3fe78618846b02f641a4aa035d858e7cc6085444
child 163912 50a2220b70bf0d9eb6a57cd86daae7f6af8ef834
push idunknown
push userunknown
push dateunknown
reviewerswesj
bugs936008
milestone29.0a1
Bug 936008 - Avoid NPE when getting a zoom constraints update before the LayerView is fully initialized. r=wesj
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());
         }
     }
 }