Bug 1253703 - Null-check createNativeGestureEvent result; r=kats
authorJim Chen <nchen@mozilla.com>
Fri, 11 Mar 2016 13:47:22 -0500
changeset 288328 5624c53dd9a5b3a38e734c3652dfdeb9e6f877c7
parent 288327 940a177ba6a4875625482f17d52da5608bd1a2dd
child 288329 3b0c3fcc410bef8bdbb04af647ab4528bfeb2e7e
push id30079
push userryanvm@gmail.com
push dateSat, 12 Mar 2016 20:24:19 +0000
treeherdermozilla-central@d1d47ba19ce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1253703
milestone48.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 1253703 - Null-check createNativeGestureEvent result; r=kats createNativeGestureEvent can fail and return null, so we should guard against that.
mobile/android/base/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
@@ -1164,17 +1164,21 @@ class JavaPanZoomController
 
         if (!mTarget.getZoomConstraints().getAllowZoom())
             return false;
 
         setState(PanZoomState.PINCHING);
         mLastZoomFocus = new PointF(detector.getFocusX(), detector.getFocusY());
         cancelTouch();
 
-        GeckoAppShell.sendEventToGecko(GeckoEvent.createNativeGestureEvent(GeckoEvent.ACTION_MAGNIFY_START, mLastZoomFocus, getMetrics().zoomFactor));
+        final GeckoEvent event = GeckoEvent.createNativeGestureEvent(
+                GeckoEvent.ACTION_MAGNIFY_START, mLastZoomFocus, getMetrics().zoomFactor);
+        if (event != null) {
+            GeckoAppShell.sendEventToGecko(event);
+        }
 
         return true;
     }
 
     @Override
     public boolean onScale(SimpleScaleGestureDetector detector) {
         if (mTarget.getFullScreenState() != FullScreenState.NONE)
             return false;
@@ -1197,18 +1201,21 @@ class JavaPanZoomController
 
             // If overscroll is disabled, prevent zooming outside the normal document pans.
             if (mX.getOverScrollMode() == View.OVER_SCROLL_NEVER || mY.getOverScrollMode() == View.OVER_SCROLL_NEVER) {
                 target = getValidViewportMetrics(target);
             }
             mTarget.setViewportMetrics(target);
         }
 
-        GeckoEvent event = GeckoEvent.createNativeGestureEvent(GeckoEvent.ACTION_MAGNIFY, mLastZoomFocus, getMetrics().zoomFactor);
-        GeckoAppShell.sendEventToGecko(event);
+        final GeckoEvent event = GeckoEvent.createNativeGestureEvent(
+                GeckoEvent.ACTION_MAGNIFY, mLastZoomFocus, getMetrics().zoomFactor);
+        if (event != null) {
+            GeckoAppShell.sendEventToGecko(event);
+        }
 
         return true;
     }
 
     private ImmutableViewportMetrics applyZoomDelta(ImmutableViewportMetrics metrics, float zoomDelta) {
         float oldZoom = metrics.zoomFactor;
         float newZoom = oldZoom + zoomDelta;
         float adjustedZoom = getAdjustedZoomFactor(newZoom / oldZoom);