Bug 1396951 - 4. Pass in GeckoView instance when sending a11y event; r=snorp

Pass in a `GeckoView` instance when sending a11y events so we're not
dependent on `GeckoAppShell.getLayerView()`. However, there's likely
more work to be done to make a11y work for any GeckoView.

MozReview-Commit-ID: DBeDOX5c3qY

--HG--
extra : rebase_source : 49d9a06ec90543c49d03f298a7d78ea54bbe0a58
This commit is contained in:
Jim Chen 2017-09-22 14:35:23 -04:00
Родитель a6188cfc76
Коммит 4402031ae6
2 изменённых файлов: 13 добавлений и 12 удалений

Просмотреть файл

@ -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());

Просмотреть файл

@ -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);