зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
a6188cfc76
Коммит
4402031ae6
|
@ -673,7 +673,7 @@ public abstract class GeckoApp extends GeckoActivity
|
||||||
GeckoAccessibility.updateAccessibilitySettings(this);
|
GeckoAccessibility.updateAccessibilitySettings(this);
|
||||||
|
|
||||||
} else if ("Accessibility:Event".equals(event)) {
|
} else if ("Accessibility:Event".equals(event)) {
|
||||||
GeckoAccessibility.sendAccessibilityEvent(message);
|
GeckoAccessibility.sendAccessibilityEvent(mLayerView, message);
|
||||||
|
|
||||||
} else if ("Bookmark:Insert".equals(event)) {
|
} else if ("Bookmark:Insert".equals(event)) {
|
||||||
final BrowserDB db = BrowserDB.from(getProfile());
|
final BrowserDB db = BrowserDB.from(getProfile());
|
||||||
|
|
|
@ -7,8 +7,6 @@ package org.mozilla.gecko;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
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.GeckoBundle;
|
||||||
import org.mozilla.gecko.util.ThreadUtils;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
|
@ -110,7 +108,8 @@ public class GeckoAccessibility {
|
||||||
return sEnabled;
|
return sEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendAccessibilityEvent(final GeckoBundle message) {
|
public static void sendAccessibilityEvent(final GeckoView view,
|
||||||
|
final GeckoBundle message) {
|
||||||
if (!sEnabled)
|
if (!sEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -120,10 +119,11 @@ public class GeckoAccessibility {
|
||||||
return;
|
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)
|
if (!sEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -148,10 +148,6 @@ public class GeckoAccessibility {
|
||||||
} else {
|
} else {
|
||||||
// In Jelly Bean we populate an AccessibilityNodeInfo with the minimal amount of data to have
|
// In Jelly Bean we populate an AccessibilityNodeInfo with the minimal amount of data to have
|
||||||
// it work with TalkBack.
|
// it work with TalkBack.
|
||||||
final LayerView view = GeckoAppShell.getLayerView();
|
|
||||||
if (view == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (sVirtualCursorNode == null) {
|
if (sVirtualCursorNode == null) {
|
||||||
sVirtualCursorNode = AccessibilityNodeInfo.obtain(view, VIRTUAL_CURSOR_POSITION);
|
sVirtualCursorNode = AccessibilityNodeInfo.obtain(view, VIRTUAL_CURSOR_POSITION);
|
||||||
}
|
}
|
||||||
|
@ -266,7 +262,12 @@ public class GeckoAccessibility {
|
||||||
AccessibilityNodeProvider mAccessibilityNodeProvider;
|
AccessibilityNodeProvider mAccessibilityNodeProvider;
|
||||||
|
|
||||||
@Override
|
@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)
|
if (mAccessibilityNodeProvider == null)
|
||||||
// The accessibility node structure for web content consists of 3 LayerView child nodes:
|
// 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.
|
// 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.
|
// 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.
|
// 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) {
|
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 {
|
} else {
|
||||||
final GeckoBundle data = new GeckoBundle(1);
|
final GeckoBundle data = new GeckoBundle(1);
|
||||||
data.putBoolean("gainFocus", true);
|
data.putBoolean("gainFocus", true);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче