Bug 1332731 - Follow-up to fix accessibility breakage; r=sebastian

Follow-up to fix breakage in accessibility caused by the bundle
conversion. In particular, optString(foo) should have been converted to
getString(foo, "") because optString returns "" by default.

Also fix a small bug in Presentation.jsm where an array or null should
be used instead of a string.
This commit is contained in:
Jim Chen 2017-02-08 19:50:32 -05:00
Родитель 65ff086671
Коммит 42a4c3f718
3 изменённых файлов: 13 добавлений и 29 удалений

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

@ -569,25 +569,12 @@ var Output = {
}
},
get androidBridge() {
delete this.androidBridge;
if (Utils.MozBuildApp === 'mobile/android') {
this.androidBridge = Services.androidBridge;
} else {
this.androidBridge = null;
}
return this.androidBridge;
},
Android: function Android(aDetails, aBrowser) {
const ANDROID_VIEW_TEXT_CHANGED = 0x10;
const ANDROID_VIEW_TEXT_SELECTION_CHANGED = 0x2000;
if (!this.androidBridge) {
return;
}
for (let androidEvent of aDetails) {
androidEvent.type = 'Accessibility:Event';
if (androidEvent.bounds) {
androidEvent.bounds = AccessFu.adjustContentBounds(
androidEvent.bounds, aBrowser);
@ -607,9 +594,8 @@ var Output = {
androidEvent.brailleOutput);
break;
}
let win = Utils.win;
let view = win && win.QueryInterface(Ci.nsIAndroidView);
view.dispatch('Accessibility:Event', androidEvent);
Utils.win.WindowEventDispatcher.sendRequest(androidEvent);
}
},
@ -805,9 +791,7 @@ var Input = {
if (Utils.MozBuildApp == 'mobile/android') {
// Return focus to native Android browser chrome.
let win = Utils.win;
let view = win && win.QueryInterface(Ci.nsIAndroidView);
view.dispatch('ToggleChrome:Focus');
Utils.win.WindowEventDispatcher.dispatch('ToggleChrome:Focus');
}
break;
case aEvent.DOM_VK_RETURN:

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

@ -315,7 +315,7 @@ AndroidPresenter.prototype.actionInvoked =
// Checkable objects use TalkBack's text derived from the event state,
// so we don't populate the text here.
let text = '';
let text = null;
if (!state.contains(States.CHECKABLE)) {
text = Utils.localize(UtteranceGenerator.genForAction(aObject,
aActionName));

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

@ -80,10 +80,10 @@ public class GeckoAccessibility {
final String[] textArray = message.getStringArray("text");
if (textArray != null) {
for (int i = 0; i < textArray.length; i++)
event.getText().add(textArray[i]);
event.getText().add(textArray[i] != null ? textArray[i] : "");
}
event.setContentDescription(message.getString("description"));
event.setContentDescription(message.getString("description", ""));
event.setEnabled(message.getBoolean("enabled", true));
event.setChecked(message.getBoolean("checked"));
event.setPassword(message.getBoolean("password"));
@ -92,7 +92,7 @@ public class GeckoAccessibility {
event.setFromIndex(message.getInt("fromIndex", -1));
event.setItemCount(message.getInt("itemCount", -1));
event.setCurrentItemIndex(message.getInt("currentItemIndex", -1));
event.setBeforeText(message.getString("beforeText"));
event.setBeforeText(message.getString("beforeText", ""));
event.setToIndex(message.getInt("toIndex", -1));
event.setScrollable(message.getBoolean("scrollable"));
event.setScrollX(message.getInt("scrollX", -1));
@ -137,7 +137,7 @@ public class GeckoAccessibility {
if (!sEnabled)
return;
final String exitView = message.getString("exitView");
final String exitView = message.getString("exitView", "");
if (exitView.equals("moveNext")) {
sCurrentNode = VIRTUAL_ENTRY_POINT_AFTER;
} else if (exitView.equals("movePrevious")) {
@ -174,13 +174,13 @@ public class GeckoAccessibility {
final String[] textArray = message.getStringArray("text");
StringBuilder sb = new StringBuilder();
if (textArray != null && textArray.length > 0) {
sb.append(textArray[0]);
sb.append(textArray[0] != null ? textArray[0] : "");
for (int i = 1; i < textArray.length; i++) {
sb.append(" ").append(textArray[i]);
sb.append(' ').append(textArray[i] != null ? textArray[i] : "");
}
sVirtualCursorNode.setText(sb.toString());
}
sVirtualCursorNode.setContentDescription(message.getString("description"));
sVirtualCursorNode.setContentDescription(message.getString("description", ""));
final GeckoBundle bounds = message.getBundle("bounds");
if (bounds != null) {
@ -196,7 +196,7 @@ public class GeckoAccessibility {
final GeckoBundle braille = message.getBundle("brailleOutput");
if (braille != null) {
sendBrailleText(view, braille.getString("text"),
sendBrailleText(view, braille.getString("text", ""),
braille.getInt("selectionStart"), braille.getInt("selectionEnd"));
}