Bug 1053765 - Putting role=log on a table tag breaks row and cell accessibles, r=tbsaunde
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 15 Aug 2014 16:49:02 -0400
changeset 199918 7769257793f632c2f62d5e4c29d08f3a87f8b842
parent 199917 f16ba9b456d15306024595c881b2971a6615eea3
child 199919 84845cf0f3987ff9ec57496b3c1b251a53869bcf
push id9784
push userryanvm@gmail.com
push dateSat, 16 Aug 2014 21:45:40 +0000
treeherderb2g-inbound@94ba78a42305 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1053765
milestone34.0a1
Bug 1053765 - Putting role=log on a table tag breaks row and cell accessibles, r=tbsaunde
accessible/base/nsAccessibilityService.cpp
accessible/generic/Accessible-inl.h
accessible/generic/Accessible.h
accessible/tests/mochitest/tree/test_table.html
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -967,32 +967,32 @@ nsAccessibilityService::GetOrCreateAcces
       newAcc = CreateHTMLAccessibleByMarkup(frame, content, aContext);
 
       // Try using frame to do it.
       if (!newAcc)
         newAcc = CreateAccessibleByFrameType(frame, content, aContext);
 
       // If table has strong ARIA role then all table descendants shouldn't
       // expose their native roles.
-      if (!roleMapEntry && newAcc) {
+      if (!roleMapEntry && newAcc && aContext->HasStrongARIARole()) {
         if (frame->AccessibleType() == eHTMLTableRowType) {
           nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
-          if (contextRoleMap && !(contextRoleMap->IsOfType(eTable)))
+          if (!contextRoleMap->IsOfType(eTable))
             roleMapEntry = &aria::gEmptyRoleMap;
 
         } else if (frame->AccessibleType() == eHTMLTableCellType &&
                    aContext->ARIARoleMap() == &aria::gEmptyRoleMap) {
           roleMapEntry = &aria::gEmptyRoleMap;
 
         } else if (content->Tag() == nsGkAtoms::dt ||
                    content->Tag() == nsGkAtoms::li ||
                    content->Tag() == nsGkAtoms::dd ||
                    frame->AccessibleType() == eHTMLLiType) {
           nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
-          if (contextRoleMap && !(contextRoleMap->IsOfType(eList)))
+          if (!contextRoleMap->IsOfType(eList))
             roleMapEntry = &aria::gEmptyRoleMap;
         }
       }
     }
   }
 
   // Accessible XBL types and deck stuff are used in XUL only currently.
   if (!newAcc && content->IsXUL()) {
--- a/accessible/generic/Accessible-inl.h
+++ b/accessible/generic/Accessible-inl.h
@@ -23,16 +23,22 @@ Accessible::Role()
 }
 
 inline bool
 Accessible::IsARIARole(nsIAtom* aARIARole) const
 {
   return mRoleMapEntry && mRoleMapEntry->Is(aARIARole);
 }
 
+inline bool
+Accessible::HasStrongARIARole() const
+{
+  return mRoleMapEntry && mRoleMapEntry->roleRule == kUseMapRole;
+}
+
 inline mozilla::a11y::role
 Accessible::ARIARole()
 {
   if (!mRoleMapEntry || mRoleMapEntry->roleRule != kUseMapRole)
     return mozilla::a11y::roles::NOTHING;
 
   return ARIATransformRole(mRoleMapEntry->role);
 }
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -214,16 +214,17 @@ public:
    */
   mozilla::a11y::role Role();
 
   /**
    * Return true if ARIA role is specified on the element.
    */
   bool HasARIARole() const { return mRoleMapEntry; }
   bool IsARIARole(nsIAtom* aARIARole) const;
+  bool HasStrongARIARole() const;
 
   /**
    * Retrun ARIA role map if any.
    */
   nsRoleMapEntry* ARIARoleMap() const { return mRoleMapEntry; }
 
   /**
    * Return accessible role specified by ARIA (see constants in
--- a/accessible/tests/mochitest/tree/test_table.html
+++ b/accessible/tests/mochitest/tree/test_table.html
@@ -157,16 +157,28 @@
               { CELL: [
                 { TEXT_LEAF: [ ] }
               ] }
             ] }
           ] } ]
         };
       testAccessibleTree("table5", accTree);
 
+      /////////////////////////////////////////////////////////////////////////
+      // log table
+      accTree =
+        { TABLE: [
+          { ROW: [
+            { CELL: [
+              { TEXT_LEAF: [ ] }
+            ] }
+          ] }
+        ] };
+      testAccessibleTree("logtable", accTree);
+
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 <body>
@@ -259,10 +271,12 @@
 
   <table id="table5">
     <tbody style="display:block;overflow:auto;">
       <tr>
         <td>bla</td>
       </tr>
     </tbody>
   </table>
+
+  <table id="logtable" role="log"><tr><td>blah</td></tr></table>
 </body>
 </html>