Bug 1332731 - Follow-up to fix accessibility breakage; r=sebastian
authorJim Chen <nchen@mozilla.com>
Wed, 08 Feb 2017 19:50:32 -0500
changeset 388225 ffddbc50a846ea06c3287b8b5ea4835ddb2cc846
parent 388224 039a0ba190d4db05911b60198503a79bdc8465ef
child 388226 bc5378b6f9aa3c6315fac6366302d34d11659d49
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1332731
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
accessible/jsat/AccessFu.jsm
accessible/jsat/Presentation.jsm
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java
--- a/accessible/jsat/AccessFu.jsm
+++ b/accessible/jsat/AccessFu.jsm
@@ -564,35 +564,22 @@ var Output = {
         if (highlightBox) {
           highlightBox.classList.remove('show');
         }
         break;
       }
     }
   },
 
-  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);
       }
 
       switch(androidEvent.eventType) {
         case ANDROID_VIEW_TEXT_CHANGED:
           androidEvent.brailleOutput = this.brailleState.adjustText(
@@ -602,19 +589,18 @@ var Output = {
           androidEvent.brailleOutput = this.brailleState.adjustSelection(
             androidEvent.brailleOutput);
           break;
         default:
           androidEvent.brailleOutput = this.brailleState.init(
             androidEvent.brailleOutput);
           break;
       }
-      let win = Utils.win;
-      let view = win && win.QueryInterface(Ci.nsIAndroidView);
-      view.dispatch('Accessibility:Event', androidEvent);
+
+      Utils.win.WindowEventDispatcher.sendRequest(androidEvent);
     }
   },
 
   Braille: function Braille(aDetails) {
     Logger.debug('Braille output: ' + aDetails.output);
   }
 };
 
@@ -800,19 +786,17 @@ var Input = {
             return;
           } else {
             target.blur();
           }
         }
 
         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:
         if (this.editState.editing) {
           return;
         }
         this.activateCurrent();
         break;
--- a/accessible/jsat/Presentation.jsm
+++ b/accessible/jsat/Presentation.jsm
@@ -310,17 +310,17 @@ AndroidPresenter.prototype.pivotChanged 
   };
 
 AndroidPresenter.prototype.actionInvoked =
   function AndroidPresenter_actionInvoked(aObject, aActionName) {
     let state = Utils.getState(aObject);
 
     // 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));
     }
 
     return {
       type: this.type,
       details: [{
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java
@@ -75,29 +75,29 @@ public class GeckoAccessibility {
                 }
             }.execute();
     }
 
     private static void populateEventFromJSON (AccessibilityEvent event, GeckoBundle message) {
         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"));
         event.setAddedCount(message.getInt("addedCount", -1));
         event.setRemovedCount(message.getInt("removedCount", -1));
         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));
         event.setScrollY(message.getInt("scrollY", -1));
         event.setMaxScrollX(message.getInt("maxScrollX", -1));
         event.setMaxScrollY(message.getInt("maxScrollY", -1));
     }
 
@@ -132,17 +132,17 @@ public class GeckoAccessibility {
 
         sendAccessibilityEvent(message, eventType);
     }
 
     public static void sendAccessibilityEvent(final GeckoBundle message, final int eventType) {
         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")) {
             sCurrentNode = VIRTUAL_ENTRY_POINT_BEFORE;
         } else {
             sCurrentNode = VIRTUAL_CURSOR_POSITION;
         }
 
@@ -169,39 +169,39 @@ public class GeckoAccessibility {
             sVirtualCursorNode.setClickable(message.getBoolean("clickable"));
             sVirtualCursorNode.setCheckable(message.getBoolean("checkable"));
             sVirtualCursorNode.setChecked(message.getBoolean("checked"));
             sVirtualCursorNode.setPassword(message.getBoolean("password"));
 
             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) {
                 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);
                 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"),
+                sendBrailleText(view, braille.getString("text", ""),
                                 braille.getInt("selectionStart"), braille.getInt("selectionEnd"));
             }
 
             if (eventType == AccessibilityEvent.TYPE_VIEW_HOVER_ENTER) {
                 sHoverEnter = message;
             }
 
             ThreadUtils.postToUiThread(new Runnable() {