Bug 727722 - Create an accessible for HTML table row by frame, r=tbsaunde, roc, surkov
authorMichał Frontczak <michaljev@o2.pl>
Wed, 25 Apr 2012 12:06:21 +0900
changeset 96445 9751f50e98d40092c13d6987b3cf2abd3ae637df
parent 96444 b032eb5936c1774d31016397d2b71ebea71e1f2f
child 96446 e7e12d907ddbd7449ac4409051304240a14aad8e
push idunknown
push userunknown
push dateunknown
reviewerstbsaunde, roc, surkov
bugs727722
milestone15.0a1
Bug 727722 - Create an accessible for HTML table row by frame, r=tbsaunde, roc, surkov
accessible/src/base/nsAccessibilityService.cpp
accessible/src/base/nsAccessibilityService.h
accessible/tests/mochitest/tree/test_table.html
layout/tables/nsTableRowFrame.cpp
layout/tables/nsTableRowFrame.h
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -422,16 +422,26 @@ nsAccessibilityService::CreateHTMLTableC
 {
   nsAccessible* accessible = 
     new nsHTMLTableCellAccessibleWrap(aContent, GetDocAccessible(aPresShell));
   NS_ADDREF(accessible);
   return accessible;
 }
 
 already_AddRefed<nsAccessible>
+nsAccessibilityService::CreateHTMLTableRowAccessible(nsIContent* aContent,
+                                                     nsIPresShell* aPresShell)
+{
+  nsAccessible* accessible =
+    new nsEnumRoleAccessible(aContent, GetDocAccessible(aPresShell), roles::ROW);
+  NS_ADDREF(accessible);
+  return accessible;
+}
+
+already_AddRefed<nsAccessible>
 nsAccessibilityService::CreateHTMLTextAccessible(nsIContent* aContent,
                                                  nsIPresShell* aPresShell)
 {
   nsAccessible* accessible = 
     new nsHTMLTextAccessible(aContent, GetDocAccessible(aPresShell));
   NS_ADDREF(accessible);
   return accessible;
 }
@@ -1679,23 +1689,16 @@ nsAccessibilityService::CreateHTMLAccess
       tag == nsGkAtoms::h5 ||
       tag == nsGkAtoms::h6 ||
       tag == nsGkAtoms::q) {
     nsAccessible* accessible = new nsHyperTextAccessibleWrap(aContent, aDoc);
     NS_IF_ADDREF(accessible);
     return accessible;
   }
 
-  if (tag == nsGkAtoms::tr) {
-    nsAccessible* accessible = new nsEnumRoleAccessible(aContent, aDoc,
-                                                        roles::ROW);
-    NS_IF_ADDREF(accessible);
-    return accessible;
-  }
-
   if (nsCoreUtils::IsHTMLTableHeader(aContent)) {
     nsAccessible* accessible = new nsHTMLTableHeaderCellAccessibleWrap(aContent,
                                                                        aDoc);
     NS_IF_ADDREF(accessible);
     return accessible;
   }
 
   if (tag == nsGkAtoms::output) {
--- a/accessible/src/base/nsAccessibilityService.h
+++ b/accessible/src/base/nsAccessibilityService.h
@@ -127,16 +127,18 @@ public:
                                     nsIPresShell* aPresShell);
   already_AddRefed<nsAccessible>
     CreateHTMLRadioButtonAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
   already_AddRefed<nsAccessible>
     CreateHTMLTableAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
   already_AddRefed<nsAccessible>
     CreateHTMLTableCellAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
   already_AddRefed<nsAccessible>
+    CreateHTMLTableRowAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
+  already_AddRefed<nsAccessible>
     CreateHTMLTextAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
   already_AddRefed<nsAccessible>
     CreateHTMLTextFieldAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
   already_AddRefed<nsAccessible>
     CreateHyperTextAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
   already_AddRefed<nsAccessible>
     CreateOuterDocAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
 
--- a/accessible/tests/mochitest/tree/test_table.html
+++ b/accessible/tests/mochitest/tree/test_table.html
@@ -123,30 +123,46 @@
               }
             ]
           }
         ]
       };
 
       testAccessibleTree("table3", accTree);
 
+      /////////////////////////////////////////////////////////////////////////
+      // table4 (display: table-row)
+      accTree = 
+        { TABLE: [
+          { ROW: [
+            { CELL: [
+              { TEXT_LEAF: [ ] }
+            ] }
+          ] } ]
+        };
+      testAccessibleTree("table4", accTree);
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 <body>
 
   <a target="_blank"
      title="When a table has only one column per row and that column happens to be a column header its role is exposed wrong"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=529621">
     Mozilla Bug 529621
   </a>
+  <a target="_blank"
+     title="when div has display style table-row"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=727722">
+    Mozilla Bug 727722
+  </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <table id="table">
     <thead>
       <tr>
@@ -184,10 +200,16 @@
   </table>
 
   <table id="table3">
     <tr>
       <th>rowheader</th>
       <td>cell</td>
     </tr>
   </table>
+
+  <table id="table4">
+    <div style="display: table-row">
+      <td>cell1</td>
+    </div>
+  </table>
 </body>
 </html>
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -45,16 +45,19 @@
 #include "nsTableFrame.h"
 #include "nsTableCellFrame.h"
 #include "nsCSSRendering.h"
 #include "nsHTMLParts.h"
 #include "nsTableColGroupFrame.h"
 #include "nsTableColFrame.h"
 #include "nsCOMPtr.h"
 #include "nsDisplayList.h"
+#ifdef ACCESSIBILITY
+#include "nsAccessibilityService.h"
+#endif
 
 using namespace mozilla;
 
 struct nsTableCellReflowState : public nsHTMLReflowState
 {
   nsTableCellReflowState(nsPresContext*           aPresContext,
                          const nsHTMLReflowState& aParentReflowState,
                          nsIFrame*                aFrame,
@@ -1341,17 +1344,29 @@ void nsTableRowFrame::SetContinuousBCBor
       return;
     case NS_SIDE_LEFT:
       mLeftContBorderWidth = aPixelValue;
       return;
     default:
       NS_ERROR("invalid NS_SIDE arg");
   }
 }
+#ifdef ACCESSIBILITY
+already_AddRefed<nsAccessible>
+nsTableRowFrame::CreateAccessible()
+{
+  nsAccessibilityService* accService = nsIPresShell::AccService();
+  if (accService) {
+    return accService->CreateHTMLTableRowAccessible(mContent,
+                                                    PresContext()->PresShell());
+  }
 
+  return nsnull;
+}
+#endif
 /**
  * Sets the NS_ROW_HAS_CELL_WITH_STYLE_HEIGHT bit to indicate whether
  * this row has any cells that have non-auto-height.  (Row-spanning
  * cells are ignored.)
  */
 void nsTableRowFrame::InitHasCellWithStyleHeight(nsTableFrame* aTableFrame)
 {
   nsTableIterator iter(*this);
--- a/layout/tables/nsTableRowFrame.h
+++ b/layout/tables/nsTableRowFrame.h
@@ -250,16 +250,20 @@ public:
   nscoord GetOuterTopContBCBorderWidth();
   /**
    * Sets full border widths before collapsing with cell borders
    * @param aForSide - side to set; only accepts right, left, and top
    */
   void SetContinuousBCBorderWidth(PRUint8     aForSide,
                                   BCPixelSize aPixelValue);
 
+#ifdef ACCESSIBILITY
+  virtual already_AddRefed<nsAccessible> CreateAccessible();
+#endif
+
 protected:
 
   /** protected constructor.
     * @see NewFrame
     */
   nsTableRowFrame(nsStyleContext *aContext);
 
   void InitChildReflowState(nsPresContext&         aPresContext,