Bug 1524476 - Don't set the screen origin from synthesized MotionEvents. r=geckoview-reviewers,esawin
authorEitan Isaacson <eitan@monotonous.org>
Fri, 22 Feb 2019 14:11:32 +0000
changeset 519055 eb2c42e0c6cb93319a2740d74674acc1a08d436e
parent 519054 c1cccb860b73aac5d92543d4582205d3f276b2f8
child 519056 c486f9e5266535d2b36e6dde47a7b7174161a5f4
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, esawin
bugs1524476
milestone67.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 1524476 - Don't set the screen origin from synthesized MotionEvents. r=geckoview-reviewers,esawin Differential Revision: https://phabricator.services.mozilla.com/D20702
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/PanZoomController.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/PanZoomController.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/PanZoomController.java
@@ -50,16 +50,18 @@ public class PanZoomController extends J
      * Specifies auto scrolling which jumps content to the desired scroll position.
      */
     public static final int SCROLL_BEHAVIOR_AUTO = 1;
 
     private SynthesizedEventState mPointerState;
 
     private ArrayList<Pair<Integer, MotionEvent>> mQueuedEvents;
 
+    private boolean mSynthesizedEvent = false;
+
     @WrapForJNI(calledFrom = "ui")
     private native boolean handleMotionEvent(
             int action, int actionIndex, long time, int metaState,  float screenX, float screenY,
             int pointerId[], float x[], float y[], float orientation[], float pressure[],
             float toolMajor[], float toolMinor[]);
 
     @WrapForJNI(calledFrom = "ui")
     private native boolean handleScrollEvent(
@@ -112,17 +114,20 @@ public class PanZoomController extends J
             toolMinor[i] = coords.toolMinor;
         }
 
         final float screenX = event.getRawX() - event.getX();
         final float screenY = event.getRawY() - event.getY();
 
         // Take this opportunity to update screen origin of session. This gets
         // dispatched to the gecko thread, so we also pass the new screen x/y directly to apz.
-        mSession.onScreenOriginChanged((int)screenX, (int)screenY);
+        // If this is a synthesized touch, the screen offset is bogus so ignore it.
+        if (!mSynthesizedEvent) {
+            mSession.onScreenOriginChanged((int)screenX, (int)screenY);
+        }
 
         return handleMotionEvent(action, event.getActionIndex(), event.getEventTime(),
                 event.getMetaState(), screenX, screenY, pointerId, x, y, orientation, pressure,
                 toolMajor, toolMinor);
     }
 
     private boolean handleScrollEvent(MotionEvent event) {
         if (!mAttached) {
@@ -515,17 +520,20 @@ public class PanZoomController extends J
             /*metaState*/ 0,
             /*buttonState*/ (isButtonDown ? MotionEvent.BUTTON_PRIMARY : 0),
             /*xPrecision*/ 0,
             /*yPrecision*/ 0,
             /*deviceId*/ 0,
             /*edgeFlags*/ 0,
             /*source*/ source,
             /*flags*/ 0);
+
+        mSynthesizedEvent = true;
         onTouchEvent(event);
+        mSynthesizedEvent = false;
 
         // Forget about removed pointers
         if (eventType == MotionEvent.ACTION_POINTER_UP ||
             eventType == MotionEvent.ACTION_UP ||
             eventType == MotionEvent.ACTION_CANCEL ||
             eventType == MotionEvent.ACTION_HOVER_MOVE)
         {
             mPointerState.pointers.remove(pointerIndex);