Bug 834120 - Table cell accessibles not exposed for CSS table without table-row. r=tbsaunde, a=lsblakk
authorAlexander Surkov <surkov.alexander@gmail.com>
Sat, 16 Feb 2013 14:42:00 +0900
changeset 127543 1a977d7f1004cd7c1006c22a9bf0ecc6c8a4ca22
parent 127542 84f1c02d8bf690f1b9681886983cbd0e080921cd
child 127544 c830a508404d7eea6044e8537cd4ce1c1f687009
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde, lsblakk
bugs834120
milestone20.0a2
Bug 834120 - Table cell accessibles not exposed for CSS table without table-row. r=tbsaunde, a=lsblakk
accessible/src/base/nsAccessibilityService.cpp
accessible/src/generic/Accessible.h
accessible/src/html/HTMLTableAccessible.cpp
accessible/src/html/HTMLTableAccessible.h
accessible/tests/mochitest/table/test_indexes_table.html
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -1417,18 +1417,20 @@ nsAccessibilityService::CreateAccessible
       break;
     case eHTMLRadioButtonType:
       newAcc = new HTMLRadioButtonAccessible(aContent, document);
       break;
     case eHTMLTableType:
       newAcc = new HTMLTableAccessibleWrap(aContent, document);
       break;
     case eHTMLTableCellType:
-      // Accessible HTML table cell must be a child of accessible HTML table row.
-      if (aContext->IsHTMLTableRow())
+      // Accessible HTML table cell should be a child of accessible HTML table
+      // or its row (CSS HTML tables are polite to the used markup at
+      // certain degree).
+      if (aContext->IsHTMLTableRow() || aContext->IsHTMLTable())
         newAcc = new HTMLTableCellAccessibleWrap(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()) {
         nsIContent* parentContent = aContent->GetParent();
--- a/accessible/src/generic/Accessible.h
+++ b/accessible/src/generic/Accessible.h
@@ -482,16 +482,17 @@ public:
   bool IsHyperText() const { return HasGenericType(eHyperText); }
   HyperTextAccessible* AsHyperText();
 
   bool IsHTMLFileInput() const { return mType == eHTMLFileInputType; }
 
   bool IsHTMLListItem() const { return mType == eHTMLLiType; }
   HTMLLIAccessible* AsHTMLListItem();
 
+  bool IsHTMLTable() const { return mType == eHTMLTableType; }
   bool IsHTMLTableRow() const { return mType == eHTMLTableRowType; }
 
   bool IsImage() const { return mType == eImageType; }
   ImageAccessible* AsImage();
 
   bool IsImageMap() const { return mType == eImageMapType; }
   HTMLImageMapAccessible* AsImageMap();
 
--- a/accessible/src/html/HTMLTableAccessible.cpp
+++ b/accessible/src/html/HTMLTableAccessible.cpp
@@ -338,26 +338,16 @@ HTMLTableRowAccessible::NativeRole()
 {
   return roles::ROW;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLTableAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
-HTMLTableAccessible::
-  HTMLTableAccessible(nsIContent* aContent, DocAccessible* aDoc) :
-  AccessibleWrap(aContent, aDoc), xpcAccessibleTable(this)
-{
-  mGenericTypes |= eTable;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// HTMLTableAccessible: nsISupports implementation
-
 NS_IMPL_ISUPPORTS_INHERITED1(HTMLTableAccessible, Accessible,
                              nsIAccessibleTable)
 
 ////////////////////////////////////////////////////////////////////////////////
 //nsAccessNode
 
 void
 HTMLTableAccessible::Shutdown()
--- a/accessible/src/html/HTMLTableAccessible.h
+++ b/accessible/src/html/HTMLTableAccessible.h
@@ -116,17 +116,22 @@ public:
 // #define SHOW_LAYOUT_HEURISTIC
 
 class HTMLTableAccessible : public AccessibleWrap,
                             public xpcAccessibleTable,
                             public nsIAccessibleTable,
                             public TableAccessible
 {
 public:
-  HTMLTableAccessible(nsIContent* aContent, DocAccessible* aDoc);
+  HTMLTableAccessible(nsIContent* aContent, DocAccessible* aDoc) :
+    AccessibleWrap(aContent, aDoc), xpcAccessibleTable(this)
+  {
+    mType = eHTMLTableType;
+    mGenericTypes |= eTable;
+  }
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIAccessible Table
   NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::)
 
   // TableAccessible
   virtual Accessible* Caption();
--- a/accessible/tests/mochitest/table/test_indexes_table.html
+++ b/accessible/tests/mochitest/table/test_indexes_table.html
@@ -123,26 +123,43 @@ https://bugzilla.mozilla.org/show_bug.cg
         [-1, -1, -1, -1, -1],
         [ 3,  4,  5, -1, -1],
         [ 6,  6,  7, -1, -1],
         [ 8,  9,  7, -1, -1],
         [ 10, 9,  7, 11, 12]
       ];
       testTableIndexes("tableinsane6", idxes);
 
+      //////////////////////////////////////////////////////////////////////////
+      // csstablecrazy1 (no rows)
+      idxes = [
+        [0,  1]
+      ];
+
+      testTableIndexes("csstablecrazy1", idxes);
+
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 <body>
 
-  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=410052">Mozilla Bug 410052</a>
+  <a target="_blank"
+     title="GetIndexAt and GetRowAtIndex and GetColumnAtIndex on HTML tables are inconsistent"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=410052">
+   Bug 410052
+  </a>
+  <a target="_blank"
+     title="Table cell accessibles not exposed for CSS table without table-row "
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=834120">
+   Bug 834120
+  </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <!--
     If you change the structure of the table please make sure to change
     the indexes count in 'for' statement in the script above.
@@ -397,10 +414,16 @@ https://bugzilla.mozilla.org/show_bug.cg
       <tr>
         <td colspan="3">10</td>
         <td>11</td>
         <td>12</td>
       </tr>
     </tbody>
   </table>
 
+  <div id="csstablecrazy1"
+       style="width: 100%; border: 1px solid red; display:table;">
+    <div style="display:table-cell;">cell1</div>
+    <div style="display:table-cell;">cell2</div>
+  </div>
+
 </body>
 </html>