Bug 756690 - Add option to not land on images with no alt text. r=eeejay
authorMax Li <maxli@maxli.ca>
Mon, 17 Jun 2013 16:25:24 -0400
changeset 146898 a0f434c4d17c2f91f9cbd029e1b09cb3145fd81f
parent 146897 1bd6b04a535f8257fae6e0380532db895ff9021c
child 146899 d009ce8e199efa47cc420caa1afbf6ec31540a70
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseeejay
bugs756690
milestone24.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 756690 - Add option to not land on images with no alt text. r=eeejay
accessible/src/jsat/TraversalRules.jsm
b2g/app/b2g.js
mobile/android/app/mobile.js
--- a/accessible/src/jsat/TraversalRules.jsm
+++ b/accessible/src/jsat/TraversalRules.jsm
@@ -9,16 +9,18 @@ const Ci = Components.interfaces;
 const Cu = Components.utils;
 const Cr = Components.results;
 
 this.EXPORTED_SYMBOLS = ['TraversalRules'];
 
 Cu.import('resource://gre/modules/accessibility/Utils.jsm');
 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
 
+let gSkipEmptyImages = new PrefCache('accessibility.accessfu.skip_empty_images');
+
 function BaseTraversalRule(aRoles, aMatchFunc) {
   this._matchRoles = aRoles;
   this._matchFunc = aMatchFunc;
 }
 
 BaseTraversalRule.prototype = {
     getMatchRoles: function BaseTraversalRule_getmatchRoles(aRules) {
       aRules.value = this._matchRoles;
@@ -98,16 +100,18 @@ this.TraversalRules = {
           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 == Ci.nsIAccessibleRole.ROLE_LISTITEM)
             return Ci.nsIAccessibleTraversalRule.FILTER_IGNORE;
 
           return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
         }
+      case Ci.nsIAccessibleRole.ROLE_GRAPHIC:
+        return TraversalRules._shouldSkipImage(aAccessible);
       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 Ci.nsIAccessibleTraversalRule.FILTER_MATCH |
           Ci.nsIAccessibleTraversalRule.FILTER_IGNORE_SUBTREE;
       }
     }
   ),
@@ -163,17 +167,20 @@ this.TraversalRules = {
      Ci.nsIAccessibleRole.ROLE_PAGETAB,
      Ci.nsIAccessibleRole.ROLE_RADIOBUTTON,
      Ci.nsIAccessibleRole.ROLE_RADIO_MENU_ITEM,
      Ci.nsIAccessibleRole.ROLE_SLIDER,
      Ci.nsIAccessibleRole.ROLE_CHECKBUTTON,
      Ci.nsIAccessibleRole.ROLE_CHECK_MENU_ITEM]),
 
   Graphic: new BaseTraversalRule(
-    [Ci.nsIAccessibleRole.ROLE_GRAPHIC]),
+    [Ci.nsIAccessibleRole.ROLE_GRAPHIC],
+    function Graphic_match(aAccessible) {
+      return TraversalRules._shouldSkipImage(aAccessible);
+    }),
 
   Heading: new BaseTraversalRule(
     [Ci.nsIAccessibleRole.ROLE_HEADING]),
 
   ListItem: new BaseTraversalRule(
     [Ci.nsIAccessibleRole.ROLE_LISTITEM,
      Ci.nsIAccessibleRole.ROLE_TERM]),
 
@@ -206,10 +213,17 @@ this.TraversalRules = {
   Separator: new BaseTraversalRule(
     [Ci.nsIAccessibleRole.ROLE_SEPARATOR]),
 
   Table: new BaseTraversalRule(
     [Ci.nsIAccessibleRole.ROLE_TABLE]),
 
   Checkbox: new BaseTraversalRule(
     [Ci.nsIAccessibleRole.ROLE_CHECKBUTTON,
-     Ci.nsIAccessibleRole.ROLE_CHECK_MENU_ITEM])
+     Ci.nsIAccessibleRole.ROLE_CHECK_MENU_ITEM]),
+
+  _shouldSkipImage: function _shouldSkipImage(aAccessible) {
+    if (gSkipEmptyImages.value && aAccessible.name === '') {
+      return Ci.nsIAccessibleTraversalRule.FILTER_IGNORE;
+    }
+    return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
+  }
 };
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -636,16 +636,18 @@ pref("dom.ipc.processPrelaunch.delayMs",
 // whichever comes first.
 pref("dom.ipc.systemMessageCPULockTimeoutSec", 30);
 
 // Ignore the "dialog=1" feature in window.open.
 pref("dom.disable_window_open_dialog_feature", true);
 
 // Screen reader support
 pref("accessibility.accessfu.activate", 2);
+// Whether to skip images with empty alt text
+pref("accessibility.accessfu.skip_empty_images", true);
 
 // Enable hit-target fluffing
 pref("ui.touch.radius.enabled", false);
 pref("ui.touch.radius.leftmm", 3);
 pref("ui.touch.radius.topmm", 5);
 pref("ui.touch.radius.rightmm", 3);
 pref("ui.touch.radius.bottommm", 2);
 
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -644,16 +644,18 @@ pref("ui.scrolling.min_scrollable_distan
 pref("ui.scrolling.axis_lock_mode", "standard");
 
 
 // Enable accessibility mode if platform accessibility is enabled.
 pref("accessibility.accessfu.activate", 2);
 pref("accessibility.accessfu.quicknav_modes", "Link,Heading,FormElement,ListItem");
 // Setting for an utterance order (0 - description first, 1 - description last).
 pref("accessibility.accessfu.utterance", 0);
+// Whether to skip images with empty alt text
+pref("accessibility.accessfu.skip_empty_images", true);
 
 // Mobile manages state by autodetection
 pref("network.manage-offline-status", true);
 
 // increase the timeout clamp for background tabs to 15 minutes
 pref("dom.min_background_timeout_value", 900000);
 
 // The default state of reader mode works on loaded a page.