Bug 712924 - Part 2: Return the proper role description for definition lists, with localization. r=surkov a=NPOTB
authorHub Figuière <hfiguiere@mozilla.com>
Tue, 17 Apr 2012 17:31:03 -0700
changeset 95214 a0258b6aeed48fad8b137b140a9f1c18b90ea509
parent 95213 eee73897136b4fb54a6e1cac13cc9b48e6af6c25
child 95215 a18c49118152295433be812cc29d8b144b35708d
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov, NPOTB
bugs712924
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 712924 - Part 2: Return the proper role description for definition lists, with localization. r=surkov a=NPOTB
accessible/src/mac/mozAccessible.h
accessible/src/mac/mozAccessible.mm
dom/locales/en-US/chrome/accessibility/mac/accessible.properties
--- a/accessible/src/mac/mozAccessible.h
+++ b/accessible/src/mac/mozAccessible.h
@@ -104,16 +104,19 @@ GetObjectOrRepresentedView(id <mozAccess
 
 // can be overridden to report another role name.
 - (NSString*)role;
 
 // a subrole is a more specialized variant of the role. for example,
 // the role might be "textfield", while the subrole is "password textfield".
 - (NSString*)subrole;
 
+// Return the role description, as there are a few exceptions.
+- (NSString*)roleDescription;
+
 // returns the native window we're inside.
 - (NSWindow*)window;
 
 // the accessible description of this particular instance.
 - (NSString*)customDescription;
 
 // the value of this element.
 - (id)value;
--- a/accessible/src/mac/mozAccessible.mm
+++ b/accessible/src/mac/mozAccessible.mm
@@ -220,23 +220,18 @@ GetNativeFromGeckoAccessible(nsIAccessib
   if ([attribute isEqualToString:NSAccessibilityPositionAttribute]) 
     return [self position];
   if ([attribute isEqualToString:NSAccessibilitySubroleAttribute])
     return [self subrole];
   if ([attribute isEqualToString:NSAccessibilityEnabledAttribute])
     return [NSNumber numberWithBool:[self isEnabled]];
   if ([attribute isEqualToString:NSAccessibilityValueAttribute])
     return [self value];
-  if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) {
-    if (mRole == roles::DOCUMENT)
-      return utils::LocalizedString(NS_LITERAL_STRING("htmlContent"));
-
-    return NSAccessibilityRoleDescription([self role], [self subrole]);
-  }
-  
+  if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) 
+    return [self roleDescription];  
   if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute])
     return [self customDescription];
   if ([attribute isEqualToString:NSAccessibilityFocusedAttribute])
     return [NSNumber numberWithBool:[self isFocused]];
   if ([attribute isEqualToString:NSAccessibilitySizeAttribute])
     return [self size];
   if ([attribute isEqualToString:NSAccessibilityWindowAttribute])
     return [self window];
@@ -505,16 +500,31 @@ GetNativeFromGeckoAccessible(nsIAccessib
 
     default:
       break;
   }
 
   return nil;
 }
 
+- (NSString*)roleDescription
+{
+  if (mRole == roles::DOCUMENT)
+    return utils::LocalizedString(NS_LITERAL_STRING("htmlContent"));
+  
+  NSString* subrole = [self subrole];
+  
+  if ((mRole == roles::LISTITEM) && [subrole isEqualToString:@"AXTerm"])
+    return utils::LocalizedString(NS_LITERAL_STRING("term"));
+  if ((mRole == roles::PARAGRAPH) && [subrole isEqualToString:@"AXDefinition"])
+    return utils::LocalizedString(NS_LITERAL_STRING("definition"));
+  
+  return NSAccessibilityRoleDescription([self role], subrole);
+}
+
 - (NSString*)title
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   nsAutoString title;
   mGeckoAccessible->GetName (title);
   return title.IsEmpty() ? nil : [NSString stringWithCharacters:title.BeginReading() length:title.Length()];
 
--- a/dom/locales/en-US/chrome/accessibility/mac/accessible.properties
+++ b/dom/locales/en-US/chrome/accessibility/mac/accessible.properties
@@ -13,8 +13,11 @@ activate=       Activate
 cycle   =       Cycle
 
 # Universal Access API support
 # (Mac Only)
 # The Role Description for AXWebArea (the web widget). Like in Safari.
 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