Bug 714976 - The role description should be HTML Content. r=tbsaunde
authorHub Figuière <hfiguiere@mozilla.com>
Fri, 06 Jan 2012 15:21:17 -0800
changeset 85499 8f723d91fb82313b0b4226f1168a73dd063d9d67
parent 85494 40c9f9ff9fd578cd56da91d129374ed361142149
child 85500 0ef29ddd07e54d636e64586bc09130e1f315a3e9
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs714976
milestone12.0a1
Bug 714976 - The role description should be HTML Content. r=tbsaunde
accessible/src/base/nsAccessNode.h
accessible/src/mac/mozAccessible.mm
dom/locales/en-US/chrome/accessibility/mac/accessible.properties
--- a/accessible/src/base/nsAccessNode.h
+++ b/accessible/src/base/nsAccessNode.h
@@ -190,16 +190,22 @@ public:
    * Return true if the accessible is primary accessible for the given DOM node.
    *
    * Accessible hierarchy may be complex for single DOM node, in this case
    * these accessibles share the same DOM node. The primary accessible "owns"
    * that DOM node in terms it gets stored in the accessible to node map.
    */
   virtual bool IsPrimaryForNode() const;
 
+  /**
+   * Return the string bundle
+   */
+  static nsIStringBundle* GetStringBundle()
+    { return gStringBundle; }
+
 protected:
     nsPresContext* GetPresContext();
 
     void LastRelease();
 
   nsCOMPtr<nsIContent> mContent;
   nsCOMPtr<nsIWeakReference> mWeakShell;
 
--- a/accessible/src/mac/mozAccessible.mm
+++ b/accessible/src/mac/mozAccessible.mm
@@ -38,27 +38,32 @@
  
 #import "mozAccessible.h"
 
 // to get the mozView formal protocol, that all gecko's ChildViews implement.
 #import "mozView.h"
 #import "nsRoleMap.h"
 
 #include "nsRect.h"
+#include "nsCocoaUtils.h"
 #include "nsCoord.h"
 #include "nsObjCExceptions.h"
 
 #include "nsIAccessible.h"
 #include "nsIAccessibleRelation.h"
 #include "nsIAccessibleText.h"
 #include "nsIAccessibleEditableText.h"
 #include "Relation.h"
 
+#include "nsAccessNode.h"
 #include "nsRootAccessible.h"
 
+#include "mozilla/Services.h"
+
+using namespace mozilla;
 using namespace mozilla::a11y;
 
 // converts a screen-global point in the cocoa coordinate system (with origo in the bottom-left corner
 // of the screen), into a top-left screen point, that gecko can use.
 static inline void
 ConvertCocoaToGeckoPoint(NSPoint &aInPoint, nsPoint &aOutPoint)
 {
   float mainScreenHeight = [(NSView*)[[NSScreen screens] objectAtIndex:0] frame].size.height;
@@ -116,18 +121,36 @@ GetNativeFromGeckoAccessible(nsIAccessib
 
   mozAccessible *native = nil;
   anAccessible->GetNativeInterface ((void**)&native);
   return native;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSNULL;
 }
 
+/**
+ * Get a localized string from the string bundle.
+ * Return nil is not found.
+ */
+static NSString* 
+GetLocalizedString(const nsString& aString)
+{
+  if (!nsAccessNode::GetStringBundle())
+    return nil;
+
+  nsXPIDLString text;
+  nsresult rv = nsAccessNode::GetStringBundle()->GetStringFromName(aString.get(),
+                                 getter_Copies(text));
+  NS_ENSURE_SUCCESS(rv, nil);
+
+  return !text.IsEmpty() ? nsCocoaUtils::ToNSString(text) : nil;
+}
+
 #pragma mark -
- 
+
 @implementation mozAccessible
  
 - (id)initWithAccessible:(nsAccessibleWrap*)geckoAccessible
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if ((self = [super init])) {
     mGeckoAccessible = geckoAccessible;
@@ -224,18 +247,24 @@ 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 ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) {
+    if ((mRole == nsIAccessibleRole::ROLE_INTERNAL_FRAME) 
+        || (mRole == nsIAccessibleRole::ROLE_DOCUMENT_FRAME))
+      return GetLocalizedString(NS_LITERAL_STRING("htmlContent")) ? : @"HTML Content";
+
     return NSAccessibilityRoleDescription([self role], nil);
+  }
+  
   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];
--- a/dom/locales/en-US/chrome/accessibility/mac/accessible.properties
+++ b/dom/locales/en-US/chrome/accessibility/mac/accessible.properties
@@ -6,8 +6,13 @@ select  =       Select
 open    =       Open
 close   =       Close
 switch  =       Switch
 click   =       Click
 collapse=       Collapse
 expand  =       Expand
 activate=       Activate
 cycle   =       Cycle
+
+# Universal Access API support
+# (Mac Only)
+# The Role Description for AXWebArea (the web widget). Like in Safari.
+htmlContent = HTML Content