Bug 1137748 - Expose correct roles, subroles, and roledescriptions for various WAI-ARIA roles on OS X, r=surkov
authorMarco Zehe <mzehe@mozilla.com>
Fri, 26 Jun 2015 17:31:44 -0700
changeset 268558 0d4f428037b5c4dbce6cdbbeea9a3afb43a2e882
parent 268557 d4c34d7fb112dbfd548a9c371021980abd14ac96
child 268559 1e7d5ce4c80f109e5e06786f592097f75938cad0
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1137748
milestone41.0a1
Bug 1137748 - Expose correct roles, subroles, and roledescriptions for various WAI-ARIA roles on OS X, r=surkov
accessible/base/RoleMap.h
accessible/mac/mozAccessible.mm
dom/locales/en-US/chrome/accessibility/mac/accessible.properties
--- a/accessible/base/RoleMap.h
+++ b/accessible/base/RoleMap.h
@@ -69,17 +69,17 @@ ROLE(CARET,
      NSAccessibilityUnknownRole,  //Unused on OS X.
      ROLE_SYSTEM_CARET,
      ROLE_SYSTEM_CARET,
      eNoNameRule)
 
 ROLE(ALERT,
      "alert",
      ATK_ROLE_ALERT,
-     NSAccessibilityWindowRole,
+     NSAccessibilityGroupRole,
      ROLE_SYSTEM_ALERT,
      ROLE_SYSTEM_ALERT,
      eNoNameRule)
 
 ROLE(WINDOW,
      "window",
      ATK_ROLE_WINDOW,
      NSAccessibilityWindowRole,  //Irrelevant on OS X; all window a11y is handled by the system.
--- a/accessible/mac/mozAccessible.mm
+++ b/accessible/mac/mozAccessible.mm
@@ -725,16 +725,17 @@ ConvertToNSArray(nsTArray<Accessible*>& 
 }
 
 - (NSString*)subrole
 {
   AccessibleWrap* accWrap = [self getGeckoAccessible];
   if (!accWrap)
     return nil;
 
+  // Deal with landmarks first
   nsIAtom* landmark = accWrap->LandmarkRole();
   if (landmark) {
     if (landmark == nsGkAtoms::application)
       return @"AXLandmarkApplication";
     if (landmark == nsGkAtoms::banner)
       return @"AXLandmarkBanner";
     if (landmark == nsGkAtoms::complementary)
       return @"AXLandmarkComplementary";
@@ -747,16 +748,47 @@ ConvertToNSArray(nsTArray<Accessible*>& 
     if (landmark == nsGkAtoms::navigation)
       return @"AXLandmarkNavigation";
     if (landmark == nsGkAtoms::search)
       return @"AXLandmarkSearch";
     if (landmark == nsGkAtoms::searchbox)
       return @"AXSearchField";
   }
 
+  // Now, deal with widget roles
+  if (accWrap->HasARIARole()) {
+    nsRoleMapEntry* roleMap = accWrap->ARIARoleMap();
+    if (roleMap->Is(nsGkAtoms::alert))
+      return @"AXApplicationAlert";
+    if (roleMap->Is(nsGkAtoms::alertdialog))
+      return @"AXApplicationAlertDialog";
+    if (roleMap->Is(nsGkAtoms::article))
+      return @"AXDocumentArticle";
+    if (roleMap->Is(nsGkAtoms::dialog))
+      return @"AXApplicationDialog";
+    if (roleMap->Is(nsGkAtoms::document))
+      return @"AXDocument";
+    if (roleMap->Is(nsGkAtoms::log_))
+      return @"AXApplicationLog";
+    if (roleMap->Is(nsGkAtoms::marquee))
+      return @"AXApplicationMarquee";
+    if (roleMap->Is(nsGkAtoms::math))
+      return @"AXDocumentMath";
+    if (roleMap->Is(nsGkAtoms::note_))
+      return @"AXDocumentNote";
+    if (roleMap->Is(nsGkAtoms::region))
+      return @"AXDocumentRegion";
+    if (roleMap->Is(nsGkAtoms::status))
+      return @"AXApplicationStatus";
+    if (roleMap->Is(nsGkAtoms::timer))
+      return @"AXApplicationTimer";
+    if (roleMap->Is(nsGkAtoms::tooltip))
+      return @"AXUserInterfaceTooltip";
+  }
+
   switch (mRole) {
     case roles::LIST:
       return @"AXContentList"; // 10.6+ NSAccessibilityContentListSubrole;
 
     case roles::ENTRY:
       if (accWrap->IsSearchbox())
         return @"AXSearchField";
       break;
@@ -845,25 +877,38 @@ ConvertToNSArray(nsTArray<Accessible*>& 
 
 struct RoleDescrMap
 {
   NSString* role;
   const nsString description;
 };
 
 static const RoleDescrMap sRoleDescrMap[] = {
+  { @"AXApplicationAlert", NS_LITERAL_STRING("alert") },
+  { @"AXApplicationAlertDialog", NS_LITERAL_STRING("alertDialog") },
+  { @"AXApplicationLog", NS_LITERAL_STRING("log") },
+  { @"AXApplicationMarquee", NS_LITERAL_STRING("marquee") },
+  { @"AXApplicationStatus", NS_LITERAL_STRING("status") },
+  { @"AXApplicationTimer", NS_LITERAL_STRING("timer") },
   { @"AXDefinition", NS_LITERAL_STRING("definition") },
+  { @"AXDocument", NS_LITERAL_STRING("document") },
+  { @"AXDocumentArticle", NS_LITERAL_STRING("article") },
+  { @"AXDocumentMath", NS_LITERAL_STRING("math") },
+  { @"AXDocumentNote", NS_LITERAL_STRING("note") },
+  { @"AXDocumentRegion", NS_LITERAL_STRING("region") },
+  { @"AXLandmarkApplication", NS_LITERAL_STRING("application") },
   { @"AXLandmarkBanner", NS_LITERAL_STRING("banner") },
   { @"AXLandmarkComplementary", NS_LITERAL_STRING("complementary") },
   { @"AXLandmarkContentInfo", NS_LITERAL_STRING("content") },
   { @"AXLandmarkMain", NS_LITERAL_STRING("main") },
   { @"AXLandmarkNavigation", NS_LITERAL_STRING("navigation") },
   { @"AXLandmarkSearch", NS_LITERAL_STRING("search") },
   { @"AXSearchField", NS_LITERAL_STRING("searchTextField") },
-  { @"AXTerm", NS_LITERAL_STRING("term") }
+  { @"AXTerm", NS_LITERAL_STRING("term") },
+  { @"AXUserInterfaceTooltip", NS_LITERAL_STRING("tooltip") }
 };
 
 struct RoleDescrComparator
 {
   const NSString* mRole;
   explicit RoleDescrComparator(const NSString* aRole) : mRole(aRole) {}
   int operator()(const RoleDescrMap& aEntry) const {
     return [mRole compare:aEntry.role];
--- a/dom/locales/en-US/chrome/accessibility/mac/accessible.properties
+++ b/dom/locales/en-US/chrome/accessibility/mac/accessible.properties
@@ -23,14 +23,28 @@ htmlContent = HTML Content
 # The Role Description for the Tab button.
 tab     =       tab
 # The Role Description for definition list dl, dt and dd
 term    =       term
 definition =    definition
 # The Role Description for an input type="search" text field
 searchTextField = search text field
 # The Role Description for WAI-ARIA Landmarks
+application =   application
 search  =       search
 banner  =       banner
 navigation =    navigation
 complementary = complementary
 content =       content
 main    =       main
+# The (spoken) role description for various WAI-ARIA roles
+alert       =      alert
+alertDialog =      alert dialog
+article     =      article
+document    =      document
+log         =      log
+marquee     =      marquee
+math        =      math
+note        =      note
+region      =      region
+status      =      application status
+timer       =      timer
+tooltip     =      tooltip