Bug 1335895 - part 31: Update FloatingToolbarTextSelection, FormAssistPopup, OverscrollEdgeEffect, and GeckoInputConnection to use LayerView.getCurrentToolbarHeight() r=jchen,kats draft
authorRandall Barker <rbarker@mozilla.com>
Mon, 27 Mar 2017 09:59:31 -0700
changeset 563865 bb2c9bb1fa2bedc4a36a99208f17f506163d916c
parent 563864 a6e857db8247b8e5eea4a41dbd85bb54d1eb25af
child 563866 905673c9064b74813d6466cdf835d4058b0950a9
push id54439
push userbmo:rbarker@mozilla.com
push dateMon, 17 Apr 2017 22:56:51 +0000
reviewersjchen, kats
bugs1335895
milestone55.0a1
Bug 1335895 - part 31: Update FloatingToolbarTextSelection, FormAssistPopup, OverscrollEdgeEffect, and GeckoInputConnection to use LayerView.getCurrentToolbarHeight() r=jchen,kats MozReview-Commit-ID: GQueTbHYGJK
mobile/android/base/java/org/mozilla/gecko/FormAssistPopup.java
mobile/android/base/java/org/mozilla/gecko/text/FloatingToolbarTextSelection.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoInputConnection.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/OverscrollEdgeEffect.java
--- a/mobile/android/base/java/org/mozilla/gecko/FormAssistPopup.java
+++ b/mobile/android/base/java/org/mozilla/gecko/FormAssistPopup.java
@@ -272,17 +272,17 @@ public class FormAssistPopup extends Rel
             sValidationMessageHeight = (int) (res.getDimension(R.dimen.validation_message_height));
         }
 
         float zoom = aMetrics.zoomFactor;
 
         // These values correspond to the input box for which we want to
         // display the FormAssistPopup.
         int left = (int) (mX * zoom - aMetrics.viewportRectLeft);
-        int top = (int) (mY * zoom - aMetrics.viewportRectTop + GeckoAppShell.getLayerView().getSurfaceTranslation());
+        int top = (int) (mY * zoom - aMetrics.viewportRectTop + GeckoAppShell.getLayerView().getCurrentToolbarHeight());
         int width = (int) (mW * zoom);
         int height = (int) (mH * zoom);
 
         int popupWidth = LayoutParams.MATCH_PARENT;
         int popupLeft = left < 0 ? 0 : left;
 
         FloatSize viewport = aMetrics.getSize();
 
--- a/mobile/android/base/java/org/mozilla/gecko/text/FloatingToolbarTextSelection.java
+++ b/mobile/android/base/java/org/mozilla/gecko/text/FloatingToolbarTextSelection.java
@@ -166,19 +166,20 @@ public class FloatingToolbarTextSelectio
     }
 
     private void updateRect(final GeckoBundle message) {
         final double x = message.getDouble("x");
         final double y = (int) message.getDouble("y");
         final double width = (int) message.getDouble("width");
         final double height = (int) message.getDouble("height");
 
+        final float toolbarOffset = layerView.getCurrentToolbarHeight();
         final float zoomFactor = layerView.getZoomFactor();
         layerView.getLocationInWindow(locationInWindow);
 
         contentRect = new Rect(
                 (int) (x * zoomFactor + locationInWindow[0]),
-                (int) (y * zoomFactor + locationInWindow[1]),
+                (int) (y * zoomFactor + locationInWindow[1] + toolbarOffset),
                 (int) ((x + width) * zoomFactor + locationInWindow[0]),
                 (int) ((y + height) * zoomFactor + locationInWindow[1] +
                        (height > 0 ? handlesOffset : 0)));
     }
 }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoInputConnection.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoInputConnection.java
@@ -359,17 +359,17 @@ class GeckoInputConnection
         if (v == null) {
             return;
         }
 
         int[] viewCoords = new int[2];
         v.getLocationOnScreen(viewCoords);
 
         DynamicToolbarAnimator animator = GeckoAppShell.getLayerView().getDynamicToolbarAnimator();
-        float toolbarHeight = animator.getMaxTranslation() - animator.getToolbarTranslation();
+        float toolbarHeight = (float)animator.getCurrentToolbarHeight();
 
         Matrix matrix = GeckoAppShell.getLayerView().getMatrixForLayerRectToViewRect();
         if (matrix == null) {
             if (DEBUG) {
                 Log.d(LOGTAG, "Cannot get Matrix to convert from Gecko coords to layer view coords");
             }
             return;
         }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/OverscrollEdgeEffect.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/OverscrollEdgeEffect.java
@@ -119,21 +119,22 @@ public class OverscrollEdgeEffect implem
 
     @Override
     public void draw(final Canvas canvas, final ImmutableViewportMetrics metrics) {
         if (metrics == null) {
             return;
         }
 
         PointF visibleEnd = mView.getDynamicToolbarAnimator().getVisibleEndOfLayerView();
+        float toolbarEnd = (float)mView.getDynamicToolbarAnimator().getCurrentToolbarHeight();
 
         // If we're pulling an edge, or fading it out, draw!
         boolean invalidate = false;
         if (!mEdges[TOP].isFinished()) {
-            invalidate |= draw(mEdges[TOP], canvas, 0, 0, 0);
+            invalidate |= draw(mEdges[TOP], canvas, 0, toolbarEnd, 0);
         }
 
         if (!mEdges[BOTTOM].isFinished()) {
             invalidate |= draw(mEdges[BOTTOM], canvas, visibleEnd.x, visibleEnd.y, 180);
         }
 
         if (!mEdges[LEFT].isFinished()) {
             invalidate |= draw(mEdges[LEFT], canvas, 0, visibleEnd.y, 270);