Bug 859100 - Fix NullPointerException in BrowserToolbar.canToolbarHide. r=kats
authorChris Lord <chrislord.net@gmail.com>
Thu, 11 Apr 2013 17:33:40 +0100
changeset 128465 03f97f46000da051ebdeb258d758330e77318c62
parent 128464 bdf42baf15d87d4cb0fec9e2756118aa8a88c8c1
child 128466 0a4e209fddeaf3979e5ee7c75c82a3c28ee06837
push id26324
push userchrislord.net@gmail.com
push dateThu, 11 Apr 2013 16:34:14 +0000
treeherdermozilla-inbound@0a4e209fddea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs859100
milestone23.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 859100 - Fix NullPointerException in BrowserToolbar.canToolbarHide. r=kats If this is called before initializeChrome is called, GeckoApp.getLayerView can be null.
mobile/android/base/BrowserToolbar.java
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -1,16 +1,17 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
+import org.mozilla.gecko.gfx.LayerView;
 import org.mozilla.gecko.util.HardwareUtils;
 
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.graphics.Rect;
 import android.graphics.drawable.AnimationDrawable;
 import android.graphics.drawable.ColorDrawable;
@@ -490,19 +491,22 @@ public class BrowserToolbar implements V
                 }
                 break;
         }
     }
 
     private boolean canToolbarHide() {
         // Forbid the toolbar from hiding if hiding the toolbar would cause
         // the page to go into overscroll.
-        ImmutableViewportMetrics metrics = GeckoApp.mAppContext.getLayerView().
-            getLayerClient().getViewportMetrics();
-        return (metrics.getPageHeight() >= metrics.getHeight());
+        LayerView layerView = GeckoApp.mAppContext.getLayerView();
+        if (layerView != null) {
+            ImmutableViewportMetrics metrics = layerView.getViewportMetrics();
+            return (metrics.getPageHeight() >= metrics.getHeight());
+        }
+        return false;
     }
 
     public void animateVisibility(boolean show) {
         // Do nothing if there's a delayed animation pending that does the
         // same thing and this request also has a delay.
         if (mVisibility != ToolbarVisibility.INCONSISTENT &&
             show == isVisible()) {
             return;