diff --git a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java index 44ce03190eb6..62dc7a8c0909 100644 --- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java +++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java @@ -673,7 +673,7 @@ public abstract class GeckoApp extends GeckoActivity GeckoAccessibility.updateAccessibilitySettings(this); } else if ("Accessibility:Event".equals(event)) { - GeckoAccessibility.sendAccessibilityEvent(message); + GeckoAccessibility.sendAccessibilityEvent(mLayerView, message); } else if ("Bookmark:Insert".equals(event)) { final BrowserDB db = BrowserDB.from(getProfile()); diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java index 9a6875ac588a..b23fa5d47439 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java @@ -7,8 +7,6 @@ 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; @@ -110,7 +108,8 @@ public class GeckoAccessibility { return sEnabled; } - public static void sendAccessibilityEvent(final GeckoBundle message) { + public static void sendAccessibilityEvent(final GeckoView view, + final GeckoBundle message) { if (!sEnabled) return; @@ -120,10 +119,11 @@ public class GeckoAccessibility { return; } - sendAccessibilityEvent(message, eventType); + sendAccessibilityEvent(view, message, eventType); } - public static void sendAccessibilityEvent(final GeckoBundle message, final int eventType) { + public static void sendAccessibilityEvent(final GeckoView view, final GeckoBundle message, + final int eventType) { if (!sEnabled) return; @@ -148,10 +148,6 @@ public class GeckoAccessibility { } else { // In Jelly Bean we populate an AccessibilityNodeInfo with the minimal amount of data to have // it work with TalkBack. - final LayerView view = GeckoAppShell.getLayerView(); - if (view == null) - return; - if (sVirtualCursorNode == null) { sVirtualCursorNode = AccessibilityNodeInfo.obtain(view, VIRTUAL_CURSOR_POSITION); } @@ -266,7 +262,12 @@ public class GeckoAccessibility { AccessibilityNodeProvider mAccessibilityNodeProvider; @Override - public AccessibilityNodeProvider getAccessibilityNodeProvider(final View host) { + public AccessibilityNodeProvider getAccessibilityNodeProvider(final View hostView) { + if (!(hostView instanceof GeckoView)) { + return super.getAccessibilityNodeProvider(hostView); + } + final GeckoView host = (GeckoView) hostView; + if (mAccessibilityNodeProvider == null) // The accessibility node structure for web content consists of 3 LayerView child nodes: // 1. VIRTUAL_ENTRY_POINT_BEFORE: Represents the entry point before the LayerView. @@ -319,7 +320,7 @@ public class GeckoAccessibility { // The accessibility focus is permanently on the middle node, VIRTUAL_CURSOR_POSITION. // When we enter the view forward or backward we just ask Gecko to get focus, keeping the current position. if (virtualViewId == VIRTUAL_CURSOR_POSITION && sHoverEnter != null) { - GeckoAccessibility.sendAccessibilityEvent(sHoverEnter, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); + GeckoAccessibility.sendAccessibilityEvent(host, sHoverEnter, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { final GeckoBundle data = new GeckoBundle(1); data.putBoolean("gainFocus", true);