Bug 696975 - extend the list of legitimate data table structures for layout-guess object attribute, r=surkov, hub
authorMark Capella <markcapella@twcny.rr.com>
Mon, 12 Mar 2012 13:54:21 -0400
changeset 88839 b3b14faed003
parent 88838 c9dc897118f2
child 88840 442550ccaf18
push id22230
push usermak77@bonardo.net
push date2012-03-13 10:17 +0000
treeherdermozilla-central@a0fa0eb17298 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov, hub
bugs696975
milestone13.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 696975 - extend the list of legitimate data table structures for layout-guess object attribute, r=surkov, hub
accessible/src/html/nsHTMLTableAccessible.cpp
accessible/tests/mochitest/table/test_layoutguess.html
--- a/accessible/src/html/nsHTMLTableAccessible.cpp
+++ b/accessible/src/html/nsHTMLTableAccessible.cpp
@@ -1436,19 +1436,36 @@ nsHTMLTableAccessible::IsProbablyForLayo
     }
 
     if (childElm->Tag() == nsGkAtoms::tbody) {
       for (nsIContent* rowElm = childElm->GetFirstChild(); rowElm;
            rowElm = rowElm->GetNextSibling()) {
         if (rowElm->IsHTML() && rowElm->Tag() == nsGkAtoms::tr) {
           for (nsIContent* cellElm = rowElm->GetFirstChild(); cellElm;
                cellElm = cellElm->GetNextSibling()) {
-            if (cellElm->IsHTML() && cellElm->Tag() == nsGkAtoms::th) {
-              RETURN_LAYOUT_ANSWER(false,
-                                   "Has th -- legitimate table structures");
+            if (cellElm->IsHTML()) {
+              
+              if (cellElm->NodeInfo()->Equals(nsGkAtoms::th)) {
+                RETURN_LAYOUT_ANSWER(false,
+                                     "Has th -- legitimate table structures");
+              }
+
+              if (cellElm->HasAttr(kNameSpaceID_None, nsGkAtoms::headers) ||
+                  cellElm->HasAttr(kNameSpaceID_None, nsGkAtoms::scope) ||
+                  cellElm->HasAttr(kNameSpaceID_None, nsGkAtoms::abbr)) {
+                RETURN_LAYOUT_ANSWER(false,
+                                     "Has headers, scope, or abbr attribute -- legitimate table structures");
+              }
+
+              nsAccessible* cell = mDoc->GetAccessible(cellElm);
+              if (cell && cell->GetChildCount() == 1 &&
+                  cell->FirstChild()->IsAbbreviation()) {
+                RETURN_LAYOUT_ANSWER(false,
+                                     "has abbr -- legitimate table structures");
+              }
             }
           }
         }
       }
     }
   }
 
   if (HasDescendant(NS_LITERAL_STRING("table"))) {
--- a/accessible/tests/mochitest/table/test_layoutguess.html
+++ b/accessible/tests/mochitest/table/test_layoutguess.html
@@ -30,31 +30,49 @@
       testAbsentAttrs("table2", attr);
 
       // table with summary
       testAbsentAttrs("table3", attr);
 
       // table with caption
       testAbsentAttrs("table4", attr);
 
-      // table with empty caption
+      // layout table with empty caption
       testAttrs("table4.2", attr, true);
 
-      // table with th element
-      testAbsentAttrs("table5", attr);
-
       // table with thead element
-      testAbsentAttrs("table6", attr);
+      testAbsentAttrs("table5", attr);
 
       // table with tfoot element
-      testAbsentAttrs("table7", attr);
+      testAbsentAttrs("table5.1", attr);
 
       // table with colgroup or col elements
-      testAbsentAttrs("table8", attr);
-      testAbsentAttrs("table8.2", attr);
+      testAbsentAttrs("table5.2", attr);
+      testAbsentAttrs("table5.3", attr);
+
+      // table with th element
+      testAbsentAttrs("table6", attr);
+
+      // table with headers attribute
+      testAbsentAttrs("table6.2", attr);
+
+      // table with scope attribute
+      testAbsentAttrs("table6.2.2", attr);
+
+      // table with abbr attribute
+      testAbsentAttrs("table6.2.3", attr);
+
+      // table with abbr element
+      testAbsentAttrs("table6.3", attr);
+
+      // table with abbr element having empty text node
+      testAbsentAttrs("table6.4", attr);
+
+      // table with abbr element and non-empty text node 
+      testAttrs("table6.5", attr, true);
 
       // layout table with nested table
       testAttrs("table9", attr, true);
 
       // layout table with 1 column
       testAttrs("table10", attr, true);
 
       // layout table with 1 row
@@ -120,16 +138,21 @@
      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">
   </pre>
 
   <!-- Table with role of grid -->
   <table id="table1" role="grid">
@@ -195,63 +218,110 @@
   <!-- table with caption -->
   <table id="table4">
     <caption>This is a table</caption>
     <tr>
       <td>Cell1</td><td>cell2</td>
     </tr>
   </table>
 
-  <!-- table with empty caption -->
+  <!-- layout table with empty caption -->
   <table id="table4.2">
     <caption> </caption>
     <tr>
       <td>Cell1</td><td>cell2</td>
     </tr>
   </table>
 
-  <!-- table with th element -->
+  <!-- table with thead element -->
   <table id="table5">
-    <tr>
-      <th>Cell1</th><th>cell2</th>
-    </tr>
-  </table>
-
-  <!-- table with thead element -->
-  <table id="table6">
     <thead>
       <tr>
         <td>Cell1</td><td>cell2</td>
       </tr>
     </thead>
   </table>
 
   <!-- table with tfoot element -->
-  <table id="table7">
+  <table id="table5.1">
     <tfoot>
       <tr>
         <td>Cell1</td><td>cell2</td>
       </tr>
     </tfoot>
   </table>
 
   <!-- table with colgroup and col elements -->
-  <table id="table8">
+  <table id="table5.2">
     <colgroup width="20"></colgroup>
     <tr>
       <td>Cell1</td><td>cell2</td>
     </tr>
   </table>
-  <table id="table8.2">
+  <table id="table5.3">
     <col width="20">
     <tr>
       <td>Cell1</td><td>cell2</td>
     </tr>
   </table>
 
+  <!-- table with th element -->
+  <table id="table6">
+    <tr>
+      <th>Cell1</th><th>cell2</th>
+    </tr>
+  </table>
+
+  <!-- table with headers attribute -->
+  <table id="table6.2">
+    <tr>
+      <td headers="a">table6.2 cell</td>
+    </tr>
+  </table>
+
+  <!-- table with scope attribute -->
+  <table id="table6.2.2">
+    <tr>
+      <td scope="a">table6.2.2 cell</td>
+    </tr>
+  </table>
+
+  <!-- table with abbr attribute -->
+  <table id="table6.2.3">
+    <tr>
+      <td abbr="table6.2.3">table6.2.3 cell1</td>
+    </tr>
+  </table>
+
+  <!-- table with abbr element -->
+  <table id="table6.3">
+    <tr>
+      <td>table6.3 cell1</td>
+      <td><abbr>table6.3 cell2</abbr></td>
+    </tr>
+  </table>
+
+  <!-- table with abbr element having empty text node -->
+  <table id="table6.4">
+    <tr>
+      <td>
+        <abbr>abbr</abbr>
+      </td>
+    </tr>
+  </table>
+
+  <!-- table with abbr element and non-empty text node -->
+  <table id="table6.5">
+    <tr>
+      <td>
+        This is a really long text (<abbr>tiarlt</abbr>) inside layout table 
+      </td>
+    </tr>
+  </table>
+
   <!-- layout table with nested table -->
   <table id="table9">
     <tr>
       <td><table><tr><td>Cell</td></tr></table></td>
     </tr>
   </table>
 
   <!-- layout table with 1 column -->