Bug 1007975 - div with display:table exposes table semantics r=surkov
authorTakeshi Kurosawa <taken.spc@gmail.com>
Mon, 19 Oct 2015 21:46:54 +0900
changeset 268746 2e52638cab7c5162aea16066d0942776c0b4d7d5
parent 268745 b0359c684793d8361829a92d81b65fffed4f2934
child 268747 12a6564962d71fd3544c768e5fcb7439ad53d284
push id29562
push userkwierso@gmail.com
push dateWed, 21 Oct 2015 23:29:46 +0000
treeherdermozilla-central@4879f22ef96a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1007975
milestone44.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 1007975 - div with display:table exposes table semantics r=surkov - Construct a table accessible object if a content in question is HTML <table> - Drop checking whether a table accessible object is built by CSS display:table from HTMLTableAccessbile::IsProbablyLayoutTable
accessible/base/nsAccessibilityService.cpp
accessible/html/HTMLTableAccessible.cpp
accessible/tests/mochitest/table/a11y.ini
accessible/tests/mochitest/table/test_css_tables.html
accessible/tests/mochitest/table/test_indexes_table.html
accessible/tests/mochitest/table/test_layoutguess.html
accessible/tests/mochitest/table/test_table_2.html
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -1657,17 +1657,20 @@ nsAccessibilityService::CreateAccessible
       break;
     case eHTMLRangeType:
       newAcc = new HTMLRangeAccessible(aContent, document);
       break;
     case eHTMLSpinnerType:
       newAcc = new HTMLSpinnerAccessible(aContent, document);
       break;
     case eHTMLTableType:
-      newAcc = new HTMLTableAccessibleWrap(aContent, document);
+      if (aContent->IsHTMLElement(nsGkAtoms::table))
+        newAcc = new HTMLTableAccessibleWrap(aContent, document);
+      else
+        newAcc = new HyperTextAccessibleWrap(aContent, document);
       break;
     case eHTMLTableCellType:
       // 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).
       // Otherwise create a generic text accessible to avoid text jamming
       // when reading by AT.
       if (aContext->IsHTMLTableRow() || aContext->IsHTMLTable())
--- a/accessible/html/HTMLTableAccessible.cpp
+++ b/accessible/html/HTMLTableAccessible.cpp
@@ -964,18 +964,18 @@ HTMLTableAccessible::IsProbablyLayoutTab
 
   if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::role)) {
     // Role attribute is present, but overridden roles have already been dealt with.
     // Only landmarks and other roles that don't override the role from native
     // markup are left to deal with here.
     RETURN_LAYOUT_ANSWER(false, "Has role attribute, weak role, and role is table");
   }
 
-  if (!mContent->IsHTMLElement(nsGkAtoms::table))
-    RETURN_LAYOUT_ANSWER(true, "table built by CSS display:table style");
+  NS_ASSERTION(mContent->IsHTMLElement(nsGkAtoms::table),
+    "table should not be built by CSS display:table style");
 
   // Check if datatable attribute has "0" value.
   if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::datatable,
                             NS_LITERAL_STRING("0"), eCaseMatters)) {
     RETURN_LAYOUT_ANSWER(true, "Has datatable = 0 attribute, it's for layout");
   }
 
   // Check for legitimate data table attributes.
--- a/accessible/tests/mochitest/table/a11y.ini
+++ b/accessible/tests/mochitest/table/a11y.ini
@@ -1,10 +1,11 @@
 [DEFAULT]
 
+[test_css_tables.html]
 [test_headers_ariagrid.html]
 [test_headers_ariatable.html]
 [test_headers_listbox.xul]
 [test_headers_table.html]
 [test_headers_tree.xul]
 [test_indexes_ariagrid.html]
 [test_indexes_listbox.xul]
 [test_indexes_table.html]
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/table/test_css_tables.html
@@ -0,0 +1,116 @@
+<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+  <title>CSS display:table is not a table</title>
+  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+  <link rel="stylesheet" type="text/css"
+        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+  <script type="application/javascript"
+          src="../common.js"></script>
+  <script type="application/javascript"
+          src="../role.js"></script>
+
+  <script type="application/javascript">
+
+    function doTest()
+    {
+      //////////////////////////////////////////////////////////////////////////
+      // elements with display:table
+
+      // only display:table
+      var accTree =
+        { SECTION: [
+          { TEXT_LEAF: [ ] }
+        ] };
+      testAccessibleTree("table1", accTree);
+
+      // only display:table and display:table-cell
+      accTree =
+        { SECTION: [
+          { SECTION: [
+            { TEXT_LEAF: [ ] }
+	        ] }
+      ] };
+      testAccessibleTree("table2", accTree);
+
+      // display:table, display:table-row, and display:table-cell
+      accTree =
+        { SECTION: [
+          { SECTION: [
+            { TEXT_LEAF: [ ] }
+          ] }
+      ] };
+      testAccessibleTree("table3", accTree);
+
+      // display:table, display:table-row-group, display:table-row, and display:table-cell
+      accTree =
+        { SECTION: [
+          { SECTION: [
+            { TEXT_LEAF: [ ] }
+          ] }
+        ] };
+      testAccessibleTree("table4", accTree);
+
+      // display:inline-table
+      accTree =
+        { TEXT_CONTAINER: [
+          { TEXT_CONTAINER: [
+            { TEXT_LEAF: [ ] }
+          ] }
+        ] };
+      testAccessibleTree("table5", accTree);
+
+      SimpleTest.finish();
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    addA11yLoadEvent(doTest);
+  </script>
+</head>
+
+<body>
+  <a target="_blank"
+     title=" div with display:table exposes table semantics"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=1007975">Mozilla Bug 1007975</a>
+
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+  <pre id="test">
+  </pre>
+
+  <div id="table1" style="display:table">
+    table1
+  </div>
+
+  <div id="table2" style="display:table">
+    <div style="display:table-cell">table2</div>
+  </div>
+
+  <div id="table3" style="display:table">
+    <div style="display:table-row">
+      <div style="display:table-cell">table3</div>
+    </div>
+  </div>
+
+  <div id="table4" style="display:table">
+    <div style="display:table-row-group">
+      <div style="display:table-row">
+        <div style="display:table-cell">table4</div>
+      </div>
+    </div>
+  </div>
+
+  <div>
+    <span id="table5" style="display:inline-table">
+      <span style="display:table-row">
+        <span style="display:table-cell">table5</div>
+      </span>
+    </span>
+  </div>
+      
+</body>
+</html>
--- a/accessible/tests/mochitest/table/test_indexes_table.html
+++ b/accessible/tests/mochitest/table/test_indexes_table.html
@@ -123,43 +123,30 @@ 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"
      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.
@@ -414,16 +401,10 @@ 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>
--- a/accessible/tests/mochitest/table/test_layoutguess.html
+++ b/accessible/tests/mochitest/table/test_layoutguess.html
@@ -111,19 +111,16 @@
       testAttrs("table21.3", attr, true);
       testAttrs("table21.4", attr, true);
       testAttrs("table21.5", attr, true);
       testAttrs("table21.6", attr, true);
 
       // layout table having datatable="0" attribute and containing data table structure (tfoot element)
       testAttrs("table22", attr, true);
 
-      // css table with non-table tag
-      testAttrs("table23", attr, true);
-
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 <body>
@@ -134,21 +131,16 @@
     Mozilla Bug 495388
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=690222"
      title="Data table elements used to determine layout-guess attribute shouldn't be picked from nested tables">
     Mozilla Bug 690222
   </a>
   <a target="_blank"
-     href="https://bugzilla.mozilla.org/show_bug.cgi?id=693948"
-     title="Expose layout-guess: true object attribute on CSS table accessible">
-    Mozilla Bug 693948
-  </a>
-  <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=696975"
      title="Extend the list of legitimate data table structures">
     Mozilla Bug 696975
   </a>
 
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
@@ -339,38 +331,38 @@
   <table id="table12">
     <tr><td>Col1</td><td>Col2</td><td>Col3</td><td>Col4</td><td>Col5</td></tr>
     <tr><td>Col1</td><td>Col2</td><td>Col3</td><td>Col4</td><td>Col5</td></tr>
   </table>
 
   <!-- table with a bordered cell -->
   <table id="table13" border="1" width="100%" bordercolor="#0000FF">
     <tr>
-      <td bordercolor="#000000"></td>
-      <td bordercolor="#000000"></td>
-      <td bordercolor="#000000"></td>
+      <td bordercolor="#000000"> </td>
+      <td bordercolor="#000000"> </td>
+      <td bordercolor="#000000"> </td>
     </tr>
     <tr>
-      <td bordercolor="#000000"></td>
-      <td bordercolor="#000000"></td>
-      <td bordercolor="#000000"></td>
+      <td bordercolor="#000000"> </td>
+      <td bordercolor="#000000"> </td>
+      <td bordercolor="#000000"> </td>
     </tr>
   </table> 
 
   <!-- table with alternating row background colors -->
   <table id="table14" width="100%">
     <tr style="background-color: #0000FF;">
-      <td></td>
-      <td></td>
-      <td></td>
+      <td> </td>
+      <td> </td>
+      <td> </td>
     </tr>
     <tr style="background-color: #00FF00;">
-      <td></td>
-      <td></td>
-      <td></td>
+      <td> </td>
+      <td> </td>
+      <td> </td>
     </tr>
   </table> 
 
   <!-- table with 3 columns and 21 rows -->
   <table id="table15" border="0">
     <tr><td>Col1</td><td>Col2</td><td>Col3</td></tr>
     <tr><td>Col1</td><td>Col2</td><td>Col3</td></tr>
     <tr><td>Col1</td><td>Col2</td><td>Col3</td></tr>
@@ -505,18 +497,10 @@
   <table id="table22" datatable="0">
     <tfoot>
       <tr>
         <td>Cell1</td><td>cell2</td>
       </tr>
     </tfoot>
   </table>
 
-  <!-- css table with noon-table tag -->
-  <div id="table23" style="display:table;">
-    <div style="display:table-row;">
-      <div style="display:table-cell;">Row 1, column 1</div>
-      <div style="display:table-cell;">Row 1, column 2</div>
-      <div style="display:table-cell;">Row 1, column 3</div>
-    </div>
-  </div>
 </body>
 </html>
--- a/accessible/tests/mochitest/table/test_table_2.html
+++ b/accessible/tests/mochitest/table/test_table_2.html
@@ -44,21 +44,16 @@ function doTest()
     testRole(accTable4, ROLE_TABLE);
 
     is(accTable4.getCellAt(0,0).firstChild.name, "cell0", "wrong cell");
     is(accTable4.getCellAt(0,1).firstChild.name, "cell1", "wrong cell");
     is(accTable4.getCellAt(1,0).firstChild.name, "cell2", "wrong cell");
     is(accTable4.getCellAt(1,1).firstChild.name, "cell3", "wrong cell");
   }
 
-  // test crazy table
-  var table6 = getAccessible("table6", [nsIAccessibleTable]);
-  ok(!table6.getCellAt(0, 0),
-     "We don't expect cell accessible for crazy table 6!");
-
   SimpleTest.finish();
 }
 SimpleTest.waitForExplicitFinish();
 addA11yLoadEvent(doTest);
   </script>
  </head>
 
  <body >
@@ -84,16 +79,11 @@ addA11yLoadEvent(doTest);
      <td>cell1</td>
     </tr>
     <tr>
      <td>cell2</td>
      <td>cell3</td>
     </tr>
    </table>
 
-  <div style="display:table;" id="table6">
-    <input type="checkbox">
-    <a href="bar">Bad checkbox</a>
-  </div>
-
   </center>
  </body>
 </html>