Bug 1253703 - Null-check createNativeGestureEvent result; r=kats a=sylvestre
authorJim Chen <nchen@mozilla.com>
Fri, 11 Mar 2016 13:47:22 -0500
changeset 323570 3099bd33de817e6745c989c3ae0b16c9b2ec0a76
parent 323569 7908ee2063b10177e48f06f790de769f7fb91ea3
child 323571 34df95dbc0d58186c0a631f5f2dd7f633d8f33da
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, sylvestre
bugs1253703
milestone47.0a2
Bug 1253703 - Null-check createNativeGestureEvent result; r=kats a=sylvestre createNativeGestureEvent can fail and return null, so we should guard against that. MozReview-Commit-ID: 8V0zMiOzKnG
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);