<rdar://problem/6230234> AXTable should probably not be exposed in there's only one cell



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@36773 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 8a7fd9f..50ec4a6 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -2,6 +2,15 @@
 
         Reviewed by Darin Adler.
 
+        Tests for <rdar://problem/6230234> AXTable should probably not be exposed in there's only one cell
+
+        * accessibility/table-one-cell-expected.txt: Added.
+        * accessibility/table-one-cell.html: Added.
+
+2008-09-22  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Darin Adler.
+
         Tests for setting/getting selected text ranges through AX
 
         * accessibility/textarea-selected-text-range-expected.txt: Added.
diff --git a/LayoutTests/accessibility/table-one-cell-expected.txt b/LayoutTests/accessibility/table-one-cell-expected.txt
new file mode 100644
index 0000000..e771ff3
--- /dev/null
+++ b/LayoutTests/accessibility/table-one-cell-expected.txt
@@ -0,0 +1,25 @@
+Pick Your Location!
+Get specific content for your area. 
+http://web.apple.com
+AXRole: AXGroup
+AXSubrole: (null)
+AXRoleDescription: group
+AXChildren: <array of size 3>
+AXHelp: 
+AXParent: <AXGroup>
+AXSize: NSSize: {132, 90}
+AXTitle: 
+AXDescription: 
+AXValue: 
+AXFocused: 0
+AXEnabled: 1
+AXWindow: <AXGroup>
+AXSelectedTextMarkerRange: (null)
+AXStartTextMarker: <AXGroup>
+AXEndTextMarker: <AXGroup>
+AXVisited: 0
+AXLinkedUIElements: (null)
+AXSelected: 0
+AXBlockQuoteLevel: 0
+AXTopLevelUIElement: <AXGroup>
+
diff --git a/LayoutTests/accessibility/table-one-cell.html b/LayoutTests/accessibility/table-one-cell.html
new file mode 100644
index 0000000..03dc47b
--- /dev/null
+++ b/LayoutTests/accessibility/table-one-cell.html
@@ -0,0 +1,33 @@
+<html>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+<body id="body">
+    
+    <!-- this table should not appear as an AXTable because it only has one cell -->
+
+    <table width="90" border="0" bgcolor="a1a5a9">
+    <tr>
+    <td>
+    <P><strong>Pick Your Location!</strong><br>Get specific content for your area. <br><a href="http://web.apple.com">http://web.apple.com</a><br>
+    </font>
+    </td>
+    </tr>
+    </table>
+    
+    <div id="result"></div>
+    
+    <script>
+        if (window.accessibilityController) {
+            var result = document.getElementById("result");
+
+            var body = document.getElementById("body");
+            body.focus();
+            var table = accessibilityController.focusedElement.childAtIndex(0);
+
+            result.innerText += table.allAttributes();
+        }
+    </script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 512c81a..0776635 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,17 @@
 
         Reviewed by Darin Adler.
 
+        <rdar://problem/6230234> AXTable should probably not be exposed in there's only one cell
+
+        Test: accessibility/table-one-cell.html
+
+        * page/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::isTableExposableThroughAccessibility):
+
+2008-09-22  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Darin Adler.
+
         <rdar://problem/6167779> Setting AXSelectedTextRange for TextAreas in a WebView behaves incorrectly
 
         Test: accessibility/textarea-selected-text-range.html
diff --git a/WebCore/page/AccessibilityTable.cpp b/WebCore/page/AccessibilityTable.cpp
index 22c7246..78c881c 100644
--- a/WebCore/page/AccessibilityTable.cpp
+++ b/WebCore/page/AccessibilityTable.cpp
@@ -113,6 +113,10 @@
     int numCols = firstBody->numColumns();
     int numRows = firstBody->numRows();
     
+    // if there's only one cell, it's not a good AXTable candidate
+    if (numRows == 1 && numCols == 1)
+        return false;
+    
     // store the background color of the table to check against cell's background colors
     RenderStyle* tableStyle = table->style();
     if (!tableStyle)