Bug 746358 - Implement new role for definition lists. r=tbsaunde
authorHub Figuière <hfiguiere@mozilla.com>
Tue, 24 Apr 2012 11:35:23 -0700
changeset 92231 efa9d8546cc9b7959bf26a6b57b99a45fea6b473
parent 92230 5ed25c2f2aed9727200f1224f9beef267fbe8ca3
child 92232 1142c95513335a123b9ac439159d639b672aa5ea
push id8611
push userhfiguiere@mozilla.com
push dateTue, 24 Apr 2012 18:35:34 +0000
treeherdermozilla-inbound@efa9d8546cc9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs746358
milestone14.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 746358 - Implement new role for definition lists. r=tbsaunde
accessible/public/nsIAccessibleRole.idl
accessible/src/atk/nsRoleMap.h
accessible/src/base/Role.h
accessible/src/base/nsAccessibilityService.h
accessible/src/html/nsHTMLTextAccessible.cpp
accessible/src/html/nsHyperTextAccessible.cpp
accessible/src/mac/mozAccessible.mm
accessible/src/mac/nsRoleMap.h
accessible/src/msaa/nsRoleMap.h
accessible/tests/mochitest/role.js
accessible/tests/mochitest/role/test_general.html
accessible/tests/mochitest/tree/test_list.html
dom/locales/en-US/chrome/accessibility/AccessFu.properties
--- a/accessible/public/nsIAccessibleRole.idl
+++ b/accessible/public/nsIAccessibleRole.idl
@@ -793,14 +793,29 @@ interface nsIAccessibleRole : nsISupport
   const unsigned long ROLE_FIGURE = 124;
 
   /**
    * Represents a rich item with a check box.
    */
   const unsigned long ROLE_CHECK_RICH_OPTION = 125;
 
   /**
+   * An HTML definition list <dl>
+   */
+  const unsigned long ROLE_DEFINITION_LIST = 126;
+
+  /**
+   * An HTML definition term <dt>
+   */
+  const unsigned long ROLE_TERM = 127;
+
+  /**
+   * An HTML definition <dd>
+   */
+  const unsigned long ROLE_DEFINITION = 128;
+
+  /**
    * It's not role actually. This constant is important to help ensure
    * nsRoleMap's are synchronized.
    */
-  const unsigned long ROLE_LAST_ENTRY = 126;
+  const unsigned long ROLE_LAST_ENTRY = 129;
 };
 
--- a/accessible/src/atk/nsRoleMap.h
+++ b/accessible/src/atk/nsRoleMap.h
@@ -166,11 +166,14 @@ static const PRUint32 atkRoleMap[] = {
     ATK_ROLE_LIST_ITEM,           // roles::RICH_OPTION          118
     ATK_ROLE_LIST,                // roles::LISTBOX              119
     ATK_ROLE_UNKNOWN,             // roles::FLAT_EQUATION        120
     ATK_ROLE_TABLE_CELL,          // roles::GRID_CELL            121
     ATK_ROLE_PANEL,               // roles::EMBEDDED_OBJECT      122
     ATK_ROLE_SECTION,             // roles::NOTE                 123
     ATK_ROLE_PANEL,               // roles::FIGURE               124
     ATK_ROLE_CHECK_BOX,           // roles::CHECK_RICH_OPTION    125
+    ATK_ROLE_LIST,                // roles::DEFINITION_LIST      126
+    ATK_ROLE_LIST_ITEM,           // roles::TERM                 127
+    ATK_ROLE_PARAGRAPH,           // roles::DEFINITION           128
     kROLE_ATK_LAST_ENTRY          // roles::LAST_ENTRY
 };
 
--- a/accessible/src/base/Role.h
+++ b/accessible/src/base/Role.h
@@ -794,19 +794,34 @@ namespace roles {
   FIGURE = 124,
 
   /**
    * Represents a rich item with a check box.
    */
   CHECK_RICH_OPTION = 125,
 
   /**
+   * Represent a definition list (dl in HTML).
+   */
+  DEFINITION_LIST = 126,
+
+  /**
+   * Represent a term in a definition list (dt in HTML).
+   */
+  TERM = 127,
+
+  /**
+   * Represent a definition in a definition list (dd in HTML)
+   */
+  DEFINITION = 128,
+
+  /**
    * It's not role actually. This constant is important to help ensure
    * nsRoleMap's are synchronized.
    */
-  LAST_ENTRY = 126
+  LAST_ENTRY = 129
   };
 } // namespace role
 typedef enum mozilla::a11y::roles::Role role;
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/src/base/nsAccessibilityService.h
+++ b/accessible/src/base/nsAccessibilityService.h
@@ -418,17 +418,20 @@ static const char kRoleNames[][20] = {
   "listbox option",      //ROLE_OPTION
   "listbox rich option", //ROLE_RICH_OPTION
   "listbox",             //ROLE_LISTBOX
   "flat equation",       //ROLE_FLAT_EQUATION
   "gridcell",            //ROLE_GRID_CELL
   "embedded object",     //ROLE_EMBEDDED_OBJECT
   "note",                //ROLE_NOTE
   "figure",              //ROLE_FIGURE
-  "check rich option"    //ROLE_CHECK_RICH_OPTION
+  "check rich option",   //ROLE_CHECK_RICH_OPTION
+  "definitionlist",      //ROLE_DEFINITION_LIST
+  "term",                //ROLE_TERM
+  "definition"           //ROLE_DEFINITION
 };
 
 /**
  * Map nsIAccessibleEvents constants to strings. Used by
  * nsIAccessibleRetrieval::getStringEventType() method.
  */
 static const char kEventTypeNames[][40] = {
   "unknown",                                 //
--- a/accessible/src/html/nsHTMLTextAccessible.cpp
+++ b/accessible/src/html/nsHTMLTextAccessible.cpp
@@ -254,16 +254,19 @@ nsHTMLLIAccessible::Shutdown()
   mBullet = nsnull;
 
   nsHyperTextAccessibleWrap::Shutdown();
 }
 
 role
 nsHTMLLIAccessible::NativeRole()
 {
+  if (mContent->Tag() == nsGkAtoms::dt)
+    return roles::TERM;
+
   return roles::LISTITEM;
 }
 
 PRUint64
 nsHTMLLIAccessible::NativeState()
 {
   return nsHyperTextAccessibleWrap::NativeState() | states::READONLY;
 }
@@ -405,16 +408,19 @@ nsHTMLListAccessible::
 {
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLListAccessible, nsHyperTextAccessible)
 
 role
 nsHTMLListAccessible::NativeRole()
 {
+  if (mContent->Tag() == nsGkAtoms::dl)
+    return roles::DEFINITION_LIST;
+
   return roles::LIST;
 }
 
 PRUint64
 nsHTMLListAccessible::NativeState()
 {
   return nsHyperTextAccessibleWrap::NativeState() | states::READONLY;
 }
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -118,16 +118,19 @@ nsresult nsHyperTextAccessible::QueryInt
   return nsAccessible::QueryInterface(aIID, aInstancePtr);
 }
 
 role
 nsHyperTextAccessible::NativeRole()
 {
   nsIAtom *tag = mContent->Tag();
 
+  if (tag == nsGkAtoms::dd)
+    return roles::DEFINITION;
+
   if (tag == nsGkAtoms::form)
     return roles::FORM;
 
   if (tag == nsGkAtoms::blockquote || tag == nsGkAtoms::div ||
       tag == nsGkAtoms::section || tag == nsGkAtoms::nav)
     return roles::SECTION;
 
   if (tag == nsGkAtoms::h1 || tag == nsGkAtoms::h2 ||
--- a/accessible/src/mac/mozAccessible.mm
+++ b/accessible/src/mac/mozAccessible.mm
@@ -462,46 +462,28 @@ GetNativeFromGeckoAccessible(nsIAccessib
   NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(mGeckoAccessible),
                "Does not support nsIAccessibleText when it should");
 #endif
   return (NSString*) AXRoles[mRole];
 }
 
 - (NSString*)subrole
 {
-  if (!mGeckoAccessible)
-    return nil;
-
-  nsIContent* content = mGeckoAccessible->GetContent();
-  if (!content || !content->IsHTML())
-    return nil;
-
-  nsIAtom* tag = content->Tag();
-
   switch (mRole) {
     case roles::LIST:
-      if ((tag == nsGkAtoms::ul) || (tag == nsGkAtoms::ol))
-        return NSAccessibilityContentListSubrole;
+      return NSAccessibilityContentListSubrole;
 
-      if (tag == nsGkAtoms::dl)
-        return NSAccessibilityDefinitionListSubrole;
-
-      break;
+    case roles::DEFINITION_LIST:
+      return NSAccessibilityDefinitionListSubrole;
 
-    case roles::LISTITEM:
-      if (tag == nsGkAtoms::dt)
-        return @"AXTerm";
-
-      break;
+    case roles::TERM:
+      return @"AXTerm";
 
-    case roles::PARAGRAPH:
-      if (tag == nsGkAtoms::dd)
-        return @"AXDefinition";
-
-      break;
+    case roles::DEFINITION:
+      return @"AXDefinition";
 
     default:
       break;
   }
 
   return nil;
 }
 
--- a/accessible/src/mac/nsRoleMap.h
+++ b/accessible/src/mac/nsRoleMap.h
@@ -163,10 +163,13 @@ static const NSString* AXRoles [] = {
   NSAccessibilityRowRole,                       // roles::RICH_OPTION          118
   NSAccessibilityListRole,                      // roles::LISTBOX              119
   NSAccessibilityUnknownRole,                   // roles::FLAT_EQUATION        120
   NSAccessibilityGroupRole,                     // roles::GRID_CELL            121
   NSAccessibilityGroupRole,                     // roles::EMBEDDED_OBJECT      122
   NSAccessibilityGroupRole,                     // roles::NOTE                 123
   NSAccessibilityGroupRole,                     // roles::FIGURE               124
   NSAccessibilityCheckBoxRole,                  // roles::CHECK_RICH_OPTION    125
+  NSAccessibilityListRole,                      // roles::DEFINITION_LIST      126
+  NSAccessibilityGroupRole,                     // roles::TERM                 127
+  NSAccessibilityGroupRole,                     // roles::DEFINITION           128
   @"ROLE_LAST_ENTRY"                            // roles::LAST_ENTRY                  Bogus role that will never be shown (just marks the end of this array)!
 };
--- a/accessible/src/msaa/nsRoleMap.h
+++ b/accessible/src/msaa/nsRoleMap.h
@@ -447,12 +447,21 @@ static const WindowsRoleMapItem gWindows
   { USE_ROLE_STRING, IA2_ROLE_NOTE },
 
   // roles::FIGURE
   { ROLE_SYSTEM_GROUPING, ROLE_SYSTEM_GROUPING },
 
   // roles::CHECK_RICH_OPTION
   { ROLE_SYSTEM_CHECKBUTTON, ROLE_SYSTEM_CHECKBUTTON },
 
+  // roles::DEFINITION_LIST
+  { ROLE_SYSTEM_LIST, ROLE_SYSTEM_LIST },
+
+  // roles::TERM
+  { ROLE_SYSTEM_LISTITEM, ROLE_SYSTEM_LISTITEM },
+
+  // roles::DEFINITION
+  { USE_ROLE_STRING, IA2_ROLE_PARAGRAPH },
+
   // roles::LAST_ENTRY
   { ROLE_WINDOWS_LAST_ENTRY, ROLE_WINDOWS_LAST_ENTRY }
 };
 
--- a/accessible/tests/mochitest/role.js
+++ b/accessible/tests/mochitest/role.js
@@ -11,16 +11,18 @@ const ROLE_CANVAS = nsIAccessibleRole.RO
 const ROLE_CAPTION = nsIAccessibleRole.ROLE_CAPTION;
 const ROLE_CELL = nsIAccessibleRole.ROLE_CELL;
 const ROLE_CHECKBUTTON = nsIAccessibleRole.ROLE_CHECKBUTTON;
 const ROLE_CHROME_WINDOW = nsIAccessibleRole.ROLE_CHROME_WINDOW;
 const ROLE_COMBOBOX = nsIAccessibleRole.ROLE_COMBOBOX;
 const ROLE_COMBOBOX_LIST = nsIAccessibleRole.ROLE_COMBOBOX_LIST;
 const ROLE_COMBOBOX_OPTION = nsIAccessibleRole.ROLE_COMBOBOX_OPTION;
 const ROLE_COLUMNHEADER = nsIAccessibleRole.ROLE_COLUMNHEADER;
+const ROLE_DEFINITION = nsIAccessibleRole.ROLE_DEFINITION;
+const ROLE_DEFINITION_LIST = nsIAccessibleRole.ROLE_DEFINITION_LIST;
 const ROLE_DIALOG = nsIAccessibleRole.ROLE_DIALOG;
 const ROLE_DOCUMENT = nsIAccessibleRole.ROLE_DOCUMENT;
 const ROLE_EMBEDDED_OBJECT = nsIAccessibleRole.ROLE_EMBEDDED_OBJECT;
 const ROLE_ENTRY = nsIAccessibleRole.ROLE_ENTRY;
 const ROLE_FIGURE = nsIAccessibleRole.ROLE_FIGURE;
 const ROLE_FOOTER = nsIAccessibleRole.ROLE_FOOTER;
 const ROLE_FLAT_EQUATION = nsIAccessibleRole.ROLE_FLAT_EQUATION;
 const ROLE_FORM = nsIAccessibleRole.ROLE_FORM;
@@ -57,16 +59,17 @@ const ROLE_RICH_OPTION = nsIAccessibleRo
 const ROLE_ROW = nsIAccessibleRole.ROLE_ROW;
 const ROLE_ROWHEADER = nsIAccessibleRole.ROLE_ROWHEADER;
 const ROLE_SCROLLBAR = nsIAccessibleRole.ROLE_SCROLLBAR;
 const ROLE_SECTION = nsIAccessibleRole.ROLE_SECTION;
 const ROLE_SEPARATOR = nsIAccessibleRole.ROLE_SEPARATOR;
 const ROLE_SLIDER = nsIAccessibleRole.ROLE_SLIDER;
 const ROLE_STATICTEXT = nsIAccessibleRole.ROLE_STATICTEXT;
 const ROLE_TABLE = nsIAccessibleRole.ROLE_TABLE;
+const ROLE_TERM = nsIAccessibleRole.ROLE_TERM;
 const ROLE_TEXT_CONTAINER = nsIAccessibleRole.ROLE_TEXT_CONTAINER;
 const ROLE_TEXT_LEAF = nsIAccessibleRole.ROLE_TEXT_LEAF;
 const ROLE_TOGGLE_BUTTON = nsIAccessibleRole.ROLE_TOGGLE_BUTTON;
 const ROLE_TOOLBAR = nsIAccessibleRole.ROLE_TOOLBAR;
 const ROLE_TOOLTIP = nsIAccessibleRole.ROLE_TOOLTIP;
 const ROLE_TREE_TABLE = nsIAccessibleRole.ROLE_TREE_TABLE;
 const ROLE_WHITESPACE = nsIAccessibleRole.ROLE_WHITESPACE;
 
--- a/accessible/tests/mochitest/role/test_general.html
+++ b/accessible/tests/mochitest/role/test_general.html
@@ -48,19 +48,19 @@
       // breaking JAWS compatibility.
       testRole("data", ROLE_TEXT_CONTAINER);
 
       // Test regular paragraph by comparison to make sure exposure does not
       // get broken.
       testRole("p", ROLE_PARAGRAPH);
 
       // Test dl, dt, dd
-      testRole("definitionlist", ROLE_LIST);
-      testRole("definitionterm", ROLE_LISTITEM);
-      testRole("definitiondescription", ROLE_PARAGRAPH);
+      testRole("definitionlist", ROLE_DEFINITION_LIST);
+      testRole("definitionterm", ROLE_TERM);
+      testRole("definitiondescription", ROLE_DEFINITION);
 
       // Has click, mousedown or mouseup listeners.
       testRole("span1", ROLE_TEXT_CONTAINER);
       testRole("span2", ROLE_TEXT_CONTAINER);
       testRole("span3", ROLE_TEXT_CONTAINER);
 
       SimpleTest.finish();
     }
--- a/accessible/tests/mochitest/tree/test_list.html
+++ b/accessible/tests/mochitest/tree/test_list.html
@@ -83,43 +83,43 @@
           new listItemTree("3. ", "Bananas", circleAccTree)
         ]
       };
 
       testAccessibleTree("list4", nestedAccTree);
 
       // dl list
       var tree =
-        { LIST: [ // dl
-          { LISTITEM: [ // dt
+        { DEFINITION_LIST: [ // dl
+          { TERM: [ // dt
             { TEXT_LEAF: [] },
           ] },
-          { PARAGRAPH: [ // dd
+          { DEFINITION: [ // dd
             { TEXT_LEAF: [] }
           ] },
-          { LISTITEM: [ // dt
+          { TERM: [ // dt
             { TEXT_LEAF: [] }
           ] },
-          { PARAGRAPH: [ // dd
+          { DEFINITION: [ // dd
             { TEXT_LEAF: [] }
           ] }
         ] };
 
       testAccessibleTree("list5", tree);
 
       // dl list inside ordered list
       tree =
         { LIST: [ // ol
           { LISTITEM: [ // li
             { STATICTEXT: [ ] },
-            { LIST: [ // dl
-              { LISTITEM: [ // dt
+            { DEFINITION_LIST: [ // dl
+              { TERM: [ // dt
                 { TEXT_LEAF: [] }
               ] },
-              { PARAGRAPH: [ // dd
+              { DEFINITION: [ // dd
                 { TEXT_LEAF: [] }
               ] }
             ] }
           ] }
         ] };
 
       testAccessibleTree("list6", tree);
 
--- a/dom/locales/en-US/chrome/accessibility/AccessFu.properties
+++ b/dom/locales/en-US/chrome/accessibility/AccessFu.properties
@@ -60,16 +60,19 @@ comboboxlist   =       combo box list
 comboboxoption =       combo box option
 imagemap       =       image map
 listboxoption  =       list box option
 listbox        =       list box
 flatequation   =       flat equation
 gridcell       =       gridcell
 note           =       note
 figure         =       figure
+definitionlist =       definition list
+term           =       term
+definition     =       definition
 
 # More sophisiticated object descriptions
 headingLevel   =       heading level %S
 # LOCALIZATION NOTE: %1$S is the item's role name (e.g. "List item" or "Page tab"), %2$S is the position of the item n the set. %3$S is the total number of such items in the set. An expanded example would read "List item 2 of 5".
 objItemOf      =       %1$S %2$S of %3$S
 objChecked     =       checked %S
 objNotChecked  =       not checked %S
 objExpanded    =       expanded %S