Bug 898545 - Get rid of simple touch rule, and make the simple rule use bigger targets when possible. r=marcoz
authorEitan Isaacson <eitan@monotonous.org>
Fri, 26 Jul 2013 14:09:17 -0700
changeset 140232 443a642f25df08d3f88e96732a3fafbae5f9d6ae
parent 140231 d0a9de9496783591a5dfb0fd49b633068a4d12a8
child 140233 7aa74bef708cb94012fe7b4a39fde64d88eae7b8
push id1951
push userryanvm@gmail.com
push dateSun, 28 Jul 2013 01:55:51 +0000
treeherderfx-team@73b69c146ca6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarcoz
bugs898545
milestone25.0a1
Bug 898545 - Get rid of simple touch rule, and make the simple rule use bigger targets when possible. r=marcoz
accessible/src/jsat/AccessFu.jsm
accessible/src/jsat/TraversalRules.jsm
--- a/accessible/src/jsat/AccessFu.jsm
+++ b/accessible/src/jsat/AccessFu.jsm
@@ -653,17 +653,17 @@ var Input = {
   _handleGesture: function _handleGesture(aGesture) {
     let gestureName = aGesture.type + aGesture.touches.length;
     Logger.info('Gesture', aGesture.type,
                 '(fingers: ' + aGesture.touches.length + ')');
 
     switch (gestureName) {
       case 'dwell1':
       case 'explore1':
-        this.moveToPoint('SimpleTouch', aGesture.x, aGesture.y);
+        this.moveToPoint('Simple', aGesture.x, aGesture.y);
         break;
       case 'doubletap1':
         this.activateCurrent();
         break;
       case 'doubletaphold1':
         this.sendContextMenuMessage();
         break;
       case 'swiperight1':
--- a/accessible/src/jsat/TraversalRules.jsm
+++ b/accessible/src/jsat/TraversalRules.jsm
@@ -34,16 +34,17 @@ const ROLE_TOGGLE_BUTTON = Ci.nsIAccessi
 const ROLE_ENTRY = Ci.nsIAccessibleRole.ROLE_ENTRY;
 const ROLE_LIST = Ci.nsIAccessibleRole.ROLE_LIST;
 const ROLE_DEFINITION_LIST = Ci.nsIAccessibleRole.ROLE_DEFINITION_LIST;
 const ROLE_LISTITEM = Ci.nsIAccessibleRole.ROLE_LISTITEM;
 const ROLE_BUTTONDROPDOWNGRID = Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWNGRID;
 const ROLE_LISTBOX = Ci.nsIAccessibleRole.ROLE_LISTBOX;
 const ROLE_SLIDER = Ci.nsIAccessibleRole.ROLE_SLIDER;
 const ROLE_HEADING = Ci.nsIAccessibleRole.ROLE_HEADING;
+const ROLE_HEADER = Ci.nsIAccessibleRole.ROLE_HEADER;
 const ROLE_TERM = Ci.nsIAccessibleRole.ROLE_TERM;
 const ROLE_SEPARATOR = Ci.nsIAccessibleRole.ROLE_SEPARATOR;
 const ROLE_TABLE = Ci.nsIAccessibleRole.ROLE_TABLE;
 const ROLE_INTERNAL_FRAME = Ci.nsIAccessibleRole.ROLE_INTERNAL_FRAME;
 const ROLE_PARAGRAPH = Ci.nsIAccessibleRole.ROLE_PARAGRAPH;
 const ROLE_SECTION = Ci.nsIAccessibleRole.ROLE_SECTION;
 
 this.EXPORTED_SYMBOLS = ['TraversalRules'];
@@ -98,73 +99,75 @@ var gSimpleTraversalRoles =
    ROLE_PROGRESSBAR,
    ROLE_BUTTONDROPDOWN,
    ROLE_BUTTONMENU,
    ROLE_CHECK_MENU_ITEM,
    ROLE_PASSWORD_TEXT,
    ROLE_RADIO_MENU_ITEM,
    ROLE_TOGGLE_BUTTON,
    ROLE_ENTRY,
+   ROLE_HEADER,
+   ROLE_HEADING,
    // Used for traversing in to child OOP frames.
    ROLE_INTERNAL_FRAME];
 
 this.TraversalRules = {
   Simple: new BaseTraversalRule(
     gSimpleTraversalRoles,
     function Simple_match(aAccessible) {
+      function hasZeroOrSingleChildDescendants () {
+        for (let acc = aAccessible; acc.childCount > 0; acc = acc.firstChild) {
+          if (acc.childCount > 1) {
+            return false;
+          }
+        }
+
+        return true;
+      }
+
       switch (aAccessible.role) {
       case ROLE_COMBOBOX:
         // We don't want to ignore the subtree because this is often
         // where the list box hangs out.
         return FILTER_MATCH;
       case ROLE_TEXT_LEAF:
         {
           // Nameless text leaves are boring, skip them.
           let name = aAccessible.name;
           if (name && name.trim())
             return FILTER_MATCH;
           else
             return FILTER_IGNORE;
         }
-      case ROLE_LINK:
-        // If the link has children we should land on them instead.
-        // Image map links don't have children so we need to match those.
-        if (aAccessible.childCount == 0)
-          return FILTER_MATCH;
-        else
-          return FILTER_IGNORE;
       case ROLE_STATICTEXT:
         {
           let parent = aAccessible.parent;
           // Ignore prefix static text in list items. They are typically bullets or numbers.
           if (parent.childCount > 1 && aAccessible.indexInParent == 0 &&
               parent.role == ROLE_LISTITEM)
             return FILTER_IGNORE;
 
           return FILTER_MATCH;
         }
       case ROLE_GRAPHIC:
         return TraversalRules._shouldSkipImage(aAccessible);
+      case ROLE_LINK:
+      case ROLE_HEADER:
+      case ROLE_HEADING:
+        return hasZeroOrSingleChildDescendants() ?
+          (FILTER_MATCH | FILTER_IGNORE_SUBTREE) : (FILTER_IGNORE);
       default:
         // Ignore the subtree, if there is one. So that we don't land on
         // the same content that was already presented by its parent.
         return FILTER_MATCH |
           FILTER_IGNORE_SUBTREE;
       }
     }
   ),
 
-  SimpleTouch: new BaseTraversalRule(
-    gSimpleTraversalRoles,
-    function Simple_match(aAccessible) {
-      return FILTER_MATCH |
-        FILTER_IGNORE_SUBTREE;
-    }
-  ),
-
   Anchor: new BaseTraversalRule(
     [ROLE_LINK],
     function Anchor_match(aAccessible)
     {
       // We want to ignore links, only focus named anchors.
       let state = {};
       let extraState = {};
       aAccessible.getState(state, extraState);