Bug 703004 - Fix NPE on touch during startup [r=pcwalton]
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 16 Nov 2011 13:42:45 -0500
changeset 83504 d651122879aca3df1c187f36b8c906b1fca4e8f6
parent 83503 245b412faf415626348c277128920012af7799f2
child 83505 add4665a783d3380e863d9a1a9a2a815bef318cb
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspcwalton
bugs703004
milestone11.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 703004 - Fix NPE on touch during startup [r=pcwalton] Fix a couple of places that transform a point but don't properly deal with the possible null return value.
embedding/android/GeckoAppShell.java
embedding/android/ui/PanZoomController.java
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -456,16 +456,19 @@ public class GeckoAppShell
 
         layerController.setOnTouchListener(new View.OnTouchListener() {
             public boolean onTouch(View view, MotionEvent event) {
                 float origX = event.getX();
                 float origY = event.getY();
                 /* Transform the point to the layer offset. */
                 PointF eventPoint = new PointF(origX, origY);
                 PointF geckoPoint = layerController.convertViewPointToLayerPoint(eventPoint);
+                if (geckoPoint == null) {
+                    return false;
+                }
                 event.setLocation((int)Math.round(geckoPoint.x), (int)Math.round(geckoPoint.y));
 
                 GeckoAppShell.sendEventToGecko(new GeckoEvent(event));
 
                 /* Restore the view coordinates in case the caller further processes this event */
                 event.setLocation(origX, origY);
                 return true;
             }
--- a/embedding/android/ui/PanZoomController.java
+++ b/embedding/android/ui/PanZoomController.java
@@ -589,16 +589,19 @@ public class PanZoomController
     }
 
     @Override
     public void onLongPress(MotionEvent motionEvent) {
         JSONObject ret = new JSONObject();
         try {
             PointF point = new PointF(motionEvent.getX(), motionEvent.getY());
             point = mController.convertViewPointToLayerPoint(point);
+            if (point == null) {
+                return;
+            }
             ret.put("x", (int)Math.round(point.x));
             ret.put("y", (int)Math.round(point.y));
         } catch(Exception ex) {
             Log.w(LOG_NAME, "Error building return: " + ex);
         }
 
         GeckoEvent e = new GeckoEvent("Gesture:LongPress", ret.toString());
         GeckoAppShell.sendEventToGecko(e);