Bug 714976 - The role description should be HTML Content. r=tbsaunde

This commit is contained in:
Hub Figuière 2012-01-06 15:21:17 -08:00
parent 13a0a7914c
commit 09abdcf50f
3 changed files with 42 additions and 2 deletions

View File

@ -195,6 +195,12 @@ public:
*/
virtual bool IsPrimaryForNode() const;
/**
* Return the string bundle
*/
static nsIStringBundle* GetStringBundle()
{ return gStringBundle; }
protected:
nsPresContext* GetPresContext();

View File

@ -43,6 +43,7 @@
#import "nsRoleMap.h"
#include "nsRect.h"
#include "nsCocoaUtils.h"
#include "nsCoord.h"
#include "nsObjCExceptions.h"
@ -52,8 +53,12 @@
#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
@ -121,8 +126,26 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible)
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
@ -229,8 +252,14 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible)
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])

View File

@ -11,3 +11,8 @@ 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