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
--- 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", ""),