Bug 1335895 - part 26: Update NativePanZoomController.java to use LayerView.isGeckoReady and remove setScrollingRootContent r=jchen,kats draft
authorRandall Barker <rbarker@mozilla.com>
Mon, 27 Mar 2017 13:57:23 -0700
changeset 563860 e27a5b32ccaf3edcda41b37a4f91df22d95043b5
parent 563859 c10f7519c4cb48156264b21669d92da7cd2e69c7
child 563861 1243de5eadefee679d9e486013db58d925894e59
push id54439
push userbmo:rbarker@mozilla.com
push dateMon, 17 Apr 2017 22:56:51 +0000
reviewersjchen, kats
bugs1335895
milestone55.0a1
Bug 1335895 - part 26: Update NativePanZoomController.java to use LayerView.isGeckoReady and remove setScrollingRootContent r=jchen,kats MozReview-Commit-ID: DtQlJHS9h8Q
mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/NativePanZoomController.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/NativePanZoomController.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/NativePanZoomController.java
@@ -18,17 +18,16 @@ import org.json.JSONObject;
 import android.graphics.PointF;
 import android.util.TypedValue;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.InputDevice;
 
 class NativePanZoomController extends JNIObject implements PanZoomController {
-    private final PanZoomTarget mTarget;
     private final LayerView mView;
     private boolean mDestroyed;
     private Overscroll mOverscroll;
     boolean mNegateWheelScroll;
     private float mPointerScrollFactor;
     private PrefsHelper.PrefHandler mPrefsObserver;
     private long mLastDownTime;
     private static final float MAX_SCROLL = 0.075f * GeckoAppShell.getDpi();
@@ -106,17 +105,18 @@ class NativePanZoomController extends JN
 
         if (count <= 0) {
             return false;
         }
 
         final MotionEvent.PointerCoords coords = new MotionEvent.PointerCoords();
         event.getPointerCoords(0, coords);
         final float x = coords.x;
-        final float y = coords.y;
+        // Scroll events are not adjusted by the AndroidDyanmicToolbarAnimator so adjust the offset here.
+        final float y = coords.y - mView.getCurrentToolbarHeight();
 
         final float flipFactor = mNegateWheelScroll ? -1.0f : 1.0f;
         final float hScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL) * flipFactor * mPointerScrollFactor;
         final float vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL) * flipFactor * mPointerScrollFactor;
 
         return handleScrollEvent(event.getEventTime(), event.getMetaState(), x, y, hScroll, vScroll);
     }
 
@@ -135,18 +135,17 @@ class NativePanZoomController extends JN
         event.getPointerCoords(0, coords);
         final float x = coords.x;
         final float y = coords.y;
 
         return handleMouseEvent(event.getActionMasked(), event.getEventTime(), event.getMetaState(), x, y, event.getButtonState());
     }
 
 
-    NativePanZoomController(PanZoomTarget target, View view) {
-        mTarget = target;
+    NativePanZoomController(View view) {
         mView = (LayerView) view;
         mDestroyed = true;
 
         String[] prefs = { "ui.scrolling.negate_wheel_scroll" };
         mPrefsObserver = new PrefsHelper.PrefHandlerBase() {
             @Override public void prefValue(String pref, boolean value) {
                 if (pref.equals("ui.scrolling.negate_wheel_scroll")) {
                     mNegateWheelScroll = value;
@@ -203,17 +202,17 @@ class NativePanZoomController extends JN
     }
 
     @Override @WrapForJNI(calledFrom = "ui") // PanZoomController
     public void destroy() {
         if (mPrefsObserver != null) {
             PrefsHelper.removeObserver(mPrefsObserver);
             mPrefsObserver = null;
         }
-        if (mDestroyed || !mTarget.isGeckoReady()) {
+        if (mDestroyed || !mView.isGeckoReady()) {
             return;
         }
         mDestroyed = true;
         disposeNative();
     }
 
     @Override
     public void attach() {
@@ -279,21 +278,16 @@ class NativePanZoomController extends JN
                         mOverscroll.setDistance(x, Overscroll.Axis.X);
                         mOverscroll.setDistance(y, Overscroll.Axis.Y);
                     }
                 });
             }
         }
     }
 
-    @WrapForJNI(calledFrom = "ui")
-    private void setScrollingRootContent(final boolean isRootContent) {
-        mTarget.setScrollingRootContent(isRootContent);
-    }
-
     /**
      * Active SelectionCaretDrag requires DynamicToolbarAnimator to be pinned
      * to avoid unwanted scroll interactions.
      */
     @WrapForJNI(calledFrom = "gecko")
     private void onSelectionDragState(boolean state) {
         mView.getDynamicToolbarAnimator().setPinned(state, PinReason.CARET_DRAG);
     }