Bug 1071858 - aria-hidden elements will not be part of childCount when traversing. r=eeejay
authorYura Zenevich <yzenevich@mozilla.com>
Thu, 25 Sep 2014 09:57:22 -0400
changeset 230485 caf6c61b1ea0fee6277eea212ce0dc2a70036197
parent 230484 9a5ca02006f77040974436d872cc396499f7c482
child 230486 30bb63e163b7ec874d2a8a4f34db1c441b0c404c
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseeejay
bugs1071858
milestone35.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 1071858 - aria-hidden elements will not be part of childCount when traversing. r=eeejay --- accessible/jsat/TraversalRules.jsm | 4 ++-- accessible/jsat/Utils.jsm | 10 +++++++++ accessible/tests/mochitest/jsat/doc_traversal.html | 24 ++++++++++++++++++++++ .../tests/mochitest/jsat/test_traversal.html | 18 ++++++++-------- 4 files changed, 46 insertions(+), 10 deletions(-)
accessible/jsat/TraversalRules.jsm
accessible/jsat/Utils.jsm
accessible/tests/mochitest/jsat/doc_traversal.html
accessible/tests/mochitest/jsat/test_traversal.html
--- a/accessible/jsat/TraversalRules.jsm
+++ b/accessible/jsat/TraversalRules.jsm
@@ -99,31 +99,31 @@ var gSimpleTraversalRoles =
    // Used for traversing in to child OOP frames.
    Roles.INTERNAL_FRAME];
 
 var gSimpleMatchFunc = function gSimpleMatchFunc(aAccessible) {
   // An object is simple, if it either has a single child lineage,
   // or has a flat subtree.
   function isSingleLineage(acc) {
     for (let child = acc; child; child = child.firstChild) {
-      if (child.childCount > 1) {
+      if (Utils.visibleChildCount(child) > 1) {
         return false;
       }
     }
     return true;
   }
 
   function isFlatSubtree(acc) {
     for (let child = acc.firstChild; child; child = child.nextSibling) {
       // text leafs inherit the actionCount of any ancestor that has a click
       // listener.
       if ([Roles.TEXT_LEAF, Roles.STATICTEXT].indexOf(child.role) >= 0) {
         continue;
       }
-      if (child.childCount > 0 || child.actionCount > 0) {
+      if (Utils.visibleChildCount(child) > 0 || child.actionCount > 0) {
         return false;
       }
     }
     return true;
   }
 
   switch (aAccessible.role) {
   case Roles.COMBOBOX:
--- a/accessible/jsat/Utils.jsm
+++ b/accessible/jsat/Utils.jsm
@@ -355,16 +355,26 @@ this.Utils = { // jshint ignore:line
 
   isHidden: function isHidden(aAccessible) {
     // Need to account for aria-hidden, so can't just check for INVISIBLE
     // state.
     let hidden = Utils.getAttributes(aAccessible).hidden;
     return hidden && hidden === 'true';
   },
 
+  visibleChildCount: function visibleChildCount(aAccessible) {
+    let count = 0;
+    for (let child = aAccessible.firstChild; child; child = child.nextSibling) {
+      if (!this.isHidden(child)) {
+        ++count;
+      }
+    }
+    return count;
+  },
+
   inHiddenSubtree: function inHiddenSubtree(aAccessible) {
     for (let acc=aAccessible; acc; acc=acc.parent) {
       if (this.isHidden(acc)) {
         return true;
       }
     }
     return false;
   },
--- a/accessible/tests/mochitest/jsat/doc_traversal.html
+++ b/accessible/tests/mochitest/jsat/doc_traversal.html
@@ -1,13 +1,18 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Traversal Rule test document</title>
   <meta charset="utf-8" />
+  <style>
+    .content:before {
+      content: "Content";
+    }
+  </style>
 </head>
 <body>
   <h3 id="heading-1">A small first heading</h3>
   <form>
     <label for="input-1-1">Name:</label>
     <input id="input-1-1">
     <label id="label-1-2">Favourite Ice Cream Flavour:<input id="input-1-2"></label>
     <button id="button-1-1">Magic Button</button>
@@ -91,16 +96,35 @@
     <td>3</td>
     <td>1</td>
   </tr>
   <tr>
     <td>4</td>
     <td>1</td>
   </tr>
   </table>
+  <section id="grid" role="grid">
+    <ol role="row">
+      <li role="presentation"></li>
+      <li role="columnheader" aria-label="Sunday">S</li>
+      <li role="columnheader">M</li>
+    </ol>
+    <ol role="row">
+      <li role="rowheader" aria-label="Week 1">1</li>
+      <li role="gridcell"><span>3</span><div></div></li>
+      <li role="gridcell"><span>4</span><div>7</div></li>
+    </ol>
+    <ol role="row">
+      <li role="rowheader">2</li>
+      <li role="gridcell"><span>5</span><div role="presentation">8</div></li>
+      <li id="gridcell4" role="gridcell">
+        <span>6</span><div aria-hidden="true"><div class="content"></div></div>
+      </li>
+    </ol>
+  </section>
   <div id="separator-2" role="separator">Just an innocuous separator</div>
   <table id="table-2">
     <thead>
       <tr>
         <th>Dirty Words</th>
         <th>Meaning</th>
       </tr>
     </thead>
--- a/accessible/tests/mochitest/jsat/test_traversal.html
+++ b/accessible/tests/mochitest/jsat/test_traversal.html
@@ -89,17 +89,17 @@
 
       queueTraversalSequence(gQueue, docAcc, TraversalRules.Anchor, null,
                              ['anchor-1', 'anchor-2']);
 
       queueTraversalSequence(gQueue, docAcc, TraversalRules.Separator, null,
                              ['separator-1', 'separator-2']);
 
       queueTraversalSequence(gQueue, docAcc, TraversalRules.Table, null,
-                             ['table-1', 'table-2']);
+                             ['table-1', 'grid', 'table-2']);
 
       queueTraversalSequence(gQueue, docAcc, TraversalRules.Simple, null,
                              ['heading-1', 'Name:', 'input-1-1', 'label-1-2',
                               'button-1-1', 'Radios are old: ', 'radio-1-1',
                               'Radios are new: ', 'radio-1-2', 'Password:',
                               'input-1-3', 'Unlucky number:', 'input-1-4',
                               'button-1-2', 'Check me: ', 'checkbox-1-1',
                               'select-1-1', 'Value 1', 'Value 2', 'Value 3',
@@ -109,23 +109,25 @@
                               'button-1-3', 'heading-2', 'heading-3',
                               'button-2-1', 'button-2-2', 'button-2-3',
                               'button-2-4', 'Programming Language',
                               'A esoteric weapon wielded by only the most ' +
                               'formidable warriors, for its unrelenting strict' +
                               ' power is unfathomable.',
                               '• Lists of Programming Languages', 'Lisp ',
                               '1. Scheme', '2. Racket', '3. Clojure',
-                              '4. Standard Lisp', 'link-0', ' Lisp', 'checkbox-1-5',
-                              ' LeLisp', '• JavaScript', 'heading-5',
-                              'image-2', 'image-3', 'Not actually an image',
-                              'link-1', 'anchor-1', 'link-2', 'anchor-2', 'link-3',
-                              '3', '1', '4', '1', 'Just an innocuous separator',
-                              'Dirty Words', 'Meaning', 'Mud', 'Wet Dirt',
-                              'Dirt', 'Messy Stuff']);
+                              '4. Standard Lisp', 'link-0', ' Lisp',
+                              'checkbox-1-5', ' LeLisp', '• JavaScript',
+                              'heading-5', 'image-2', 'image-3',
+                              'Not actually an image', 'link-1', 'anchor-1',
+                              'link-2', 'anchor-2', 'link-3', '3', '1', '4',
+                              '1', 'S', 'M', '1', '3', '4', '7', '2', '5', '8',
+                              '6', 'Just an innocuous separator', 'Dirty Words',
+                              'Meaning', 'Mud', 'Wet Dirt', 'Dirt',
+                              'Messy Stuff']);
 
       gQueue.invoke();
     }
 
     SimpleTest.waitForExplicitFinish();
     addLoadEvent(function () {
       /* We open a new browser because we need to test with a top-level content
          document. */