Bug 1020510 - let tbody/etc accessible in table hierarchy, r=tbsaunde
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 06 Jun 2014 13:22:46 -0400
changeset 206459 d4fc8141e2db56af7651e959c06dfe730058bc85
parent 206458 3697556d43f79c2eb9dfdfe283e96c4ca065608f
child 206460 684d2cee3f2d3357102ec36e284fa72da7369d4d
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1020510
milestone32.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 1020510 - let tbody/etc accessible in table hierarchy, r=tbsaunde
accessible/src/base/nsAccessibilityService.cpp
accessible/tests/mochitest/table/test_indexes_table.html
accessible/tests/mochitest/tree/test_table.html
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -421,17 +421,17 @@ nsAccessibilityService::TreeViewChanged(
                                         nsIContent* aContent,
                                         nsITreeView* aView)
 {
   DocAccessible* document = GetDocAccessible(aPresShell);
   if (document) {
     Accessible* accessible = document->GetAccessible(aContent);
     if (accessible) {
       XULTreeAccessible* treeAcc = accessible->AsXULTree();
-      if (treeAcc) 
+      if (treeAcc)
         treeAcc->TreeViewChanged(aView);
     }
   }
 }
 
 void
 nsAccessibilityService::RangeValueChanged(nsIPresShell* aPresShell,
                                           nsIContent* aContent)
@@ -1170,17 +1170,17 @@ nsAccessibilityService::CreateAccessible
 
   if (role.IsEmpty() || role.EqualsLiteral("none"))
     return nullptr;
 
   if (role.EqualsLiteral("outerdoc")) {
     nsRefPtr<Accessible> accessible = new OuterDocAccessible(aContent, aDoc);
     return accessible.forget();
   }
- 
+
   nsRefPtr<Accessible> accessible;
 #ifdef MOZ_XUL
   // XUL controls
   if (role.EqualsLiteral("xul:alert")) {
     accessible = new XULAlertAccessible(aContent, aDoc);
 
   } else if (role.EqualsLiteral("xul:button")) {
     accessible = new XULButtonAccessible(aContent, aDoc);
@@ -1553,28 +1553,32 @@ nsAccessibilityService::CreateAccessible
       // when reading by AT.
       if (aContext->IsHTMLTableRow() || aContext->IsHTMLTable())
         newAcc = new HTMLTableCellAccessibleWrap(aContent, document);
       else
         newAcc = new HyperTextAccessibleWrap(aContent, document);
       break;
 
     case eHTMLTableRowType: {
-      // Accessible HTML table row must be a child of tbody/tfoot/thead of
-      // accessible HTML table or must be a child of accessible of HTML table.
-      if (aContext->IsTable()) {
+      // Accessible HTML table row may be a child of tbody/tfoot/thead of
+      // accessible HTML table or a direct child of accessible of HTML table.
+      Accessible* table = aContext->IsTable() ?
+        aContext :
+        (aContext->Parent()->IsTable() ? aContext->Parent() : nullptr);
+
+      if (table) {
         nsIContent* parentContent = aContent->GetParent();
         nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
-        if (parentFrame->GetType() == nsGkAtoms::tableRowGroupFrame) {
+        if (parentFrame->GetType() != nsGkAtoms::tableOuterFrame) {
           parentContent = parentContent->GetParent();
           parentFrame = parentContent->GetPrimaryFrame();
         }
 
         if (parentFrame->GetType() == nsGkAtoms::tableOuterFrame &&
-            aContext->GetContent() == parentContent) {
+            table->GetContent() == parentContent) {
           newAcc = new HTMLTableRowAccessible(aContent, document);
         }
       }
       break;
     }
     case eHTMLTextFieldType:
       newAcc = new HTMLTextFieldAccessible(aContent, document);
       break;
@@ -1644,17 +1648,17 @@ nsAccessibilityService::RemoveNativeRoot
 /**
  * Return accessibility service; creating one if necessary.
  */
 nsresult
 NS_GetAccessibilityService(nsIAccessibilityService** aResult)
 {
   NS_ENSURE_TRUE(aResult, NS_ERROR_NULL_POINTER);
   *aResult = nullptr;
- 
+
   if (nsAccessibilityService::gAccessibilityService) {
     NS_ADDREF(*aResult = nsAccessibilityService::gAccessibilityService);
     return NS_OK;
   }
 
   nsRefPtr<nsAccessibilityService> service = new nsAccessibilityService();
   NS_ENSURE_TRUE(service, NS_ERROR_OUT_OF_MEMORY);
 
--- a/accessible/tests/mochitest/table/test_indexes_table.html
+++ b/accessible/tests/mochitest/table/test_indexes_table.html
@@ -340,17 +340,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       <tr>
          <td colspan="2">4</td>
         <td rowspan="2">5</td>
         </tr>
       <tr>
         <td>6</td>
       </tr>
       <tr>
-        <td colspan="3">7</td>       
+        <td colspan="3">7</td>
       </tr>
 
     </tbody>
   </table>
 
   <table border="1" id="tableinsane5">
     <caption>just a crazy table</caption>
     <thead>
--- a/accessible/tests/mochitest/tree/test_table.html
+++ b/accessible/tests/mochitest/tree/test_table.html
@@ -133,26 +133,40 @@
           }
         ]
       };
 
       testAccessibleTree("table3", accTree);
 
       /////////////////////////////////////////////////////////////////////////
       // table4 (display: table-row)
-      accTree = 
+      accTree =
         { TABLE: [
           { ROW: [
             { CELL: [
               { TEXT_LEAF: [ ] }
             ] }
           ] } ]
         };
       testAccessibleTree("table4", accTree);
 
+      /////////////////////////////////////////////////////////////////////////
+      // table5 (intermediate accessible for tbody)
+      accTree =
+        { TABLE: [
+          { TEXT_CONTAINER: [
+            { ROW: [
+              { CELL: [
+                { TEXT_LEAF: [ ] }
+              ] }
+            ] }
+          ] } ]
+        };
+      testAccessibleTree("table5", accTree);
+
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 <body>
@@ -237,10 +251,18 @@
     </tr>
   </table>
 
   <table id="table4">
     <div style="display: table-row">
       <td>cell1</td>
     </div>
   </table>
+
+  <table id="table5">
+    <tbody style="display:block;overflow:auto;">
+      <tr>
+        <td>bla</td>
+      </tr>
+    </tbody>
+  </table>
 </body>
 </html>