Bug 1396233 - Add toolbar offset to screen location of a11y event so Android can draw the target box in the correct location r=esawin draft
authorRandall Barker <rbarker@mozilla.com>
Thu, 07 Sep 2017 14:03:46 -0700
changeset 660987 803a15d2198c0e2db78688d75e2aee6e817a412b
parent 660986 78ab7b444a9c125ead34fae6777021d8103571d7
child 730443 5ca6881d00ecb24c197c63aa6963ba2e29127f57
push id78622
push userbmo:rbarker@mozilla.com
push dateThu, 07 Sep 2017 21:49:07 +0000
reviewersesawin
bugs1396233
milestone57.0a1
Bug 1396233 - Add toolbar offset to screen location of a11y event so Android can draw the target box in the correct location r=esawin MozReview-Commit-ID: 9MN0G7VHGOQ
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.mozilla.gecko.EventDispatcher;
+import org.mozilla.gecko.gfx.LayerView;
 import org.mozilla.gecko.util.GeckoBundle;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.content.Context;
 import android.graphics.Rect;
 import android.os.Build;
 import android.os.Bundle;
 import android.util.Log;
@@ -142,17 +143,17 @@ public class GeckoAccessibility {
                     @Override
                     public void run() {
                         sendDirectAccessibilityEvent(eventType, message);
                 }
             });
         } else {
             // In Jelly Bean we populate an AccessibilityNodeInfo with the minimal amount of data to have
             // it work with TalkBack.
-            final View view = GeckoAppShell.getLayerView();
+            final LayerView view = GeckoAppShell.getLayerView();
             if (view == null)
                 return;
 
             if (sVirtualCursorNode == null) {
                 sVirtualCursorNode = AccessibilityNodeInfo.obtain(view, VIRTUAL_CURSOR_POSITION);
             }
             sVirtualCursorNode.setEnabled(message.getBoolean("enabled", true));
             sVirtualCursorNode.setClickable(message.getBoolean("clickable"));
@@ -173,16 +174,17 @@ public class GeckoAccessibility {
 
             final GeckoBundle bounds = message.getBundle("bounds");
             if (bounds != null) {
                 Rect relativeBounds = new Rect(bounds.getInt("left"), bounds.getInt("top"),
                                                bounds.getInt("right"), bounds.getInt("bottom"));
                 sVirtualCursorNode.setBoundsInParent(relativeBounds);
                 int[] locationOnScreen = new int[2];
                 view.getLocationOnScreen(locationOnScreen);
+                locationOnScreen[1] += view.getCurrentToolbarHeight();
                 Rect screenBounds = new Rect(relativeBounds);
                 screenBounds.offset(locationOnScreen[0], locationOnScreen[1]);
                 sVirtualCursorNode.setBoundsInScreen(screenBounds);
             }
 
             final GeckoBundle braille = message.getBundle("brailleOutput");
             if (braille != null) {
                 sendBrailleText(view, braille.getString("text", ""),