mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 718625 - Implement TextLeaf accessibles for Mac. Fix Heading title. r=tbsaunde
--HG-- extra : rebase_source : c5f3044614af18ace16f7a91d3b51effa48c9ff8
This commit is contained in:
parent
c545610049
commit
60d57606bf
@ -89,10 +89,12 @@ AccessibleWrap::GetNativeType ()
|
|||||||
case roles::STATICTEXT:
|
case roles::STATICTEXT:
|
||||||
case roles::CAPTION:
|
case roles::CAPTION:
|
||||||
case roles::ACCEL_LABEL:
|
case roles::ACCEL_LABEL:
|
||||||
case roles::TEXT_LEAF:
|
|
||||||
case roles::PASSWORD_TEXT:
|
case roles::PASSWORD_TEXT:
|
||||||
// normal textfield (static or editable)
|
// normal textfield (static or editable)
|
||||||
return [mozTextAccessible class];
|
return [mozTextAccessible class];
|
||||||
|
|
||||||
|
case roles::TEXT_LEAF:
|
||||||
|
return [mozTextLeafAccessible class];
|
||||||
|
|
||||||
case roles::LINK:
|
case roles::LINK:
|
||||||
return [mozLinkAccessible class];
|
return [mozLinkAccessible class];
|
||||||
|
@ -472,7 +472,7 @@ GetClosestInterestingAccessible(id anObject)
|
|||||||
|
|
||||||
nsAutoString title;
|
nsAutoString title;
|
||||||
mGeckoAccessible->Name(title);
|
mGeckoAccessible->Name(title);
|
||||||
return title.IsEmpty() ? nil : [NSString stringWithCharacters:title.BeginReading() length:title.Length()];
|
return nsCocoaUtils::ToNSString(title);
|
||||||
|
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
||||||
}
|
}
|
||||||
@ -515,7 +515,8 @@ GetClosestInterestingAccessible(id anObject)
|
|||||||
|
|
||||||
nsAutoString desc;
|
nsAutoString desc;
|
||||||
mGeckoAccessible->Description(desc);
|
mGeckoAccessible->Description(desc);
|
||||||
return desc.IsEmpty() ? nil : [NSString stringWithCharacters:desc.BeginReading() length:desc.Length()];
|
|
||||||
|
return nsCocoaUtils::ToNSString(desc);
|
||||||
|
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,17 @@
|
|||||||
|
|
||||||
@implementation mozHeadingAccessible
|
@implementation mozHeadingAccessible
|
||||||
|
|
||||||
|
- (NSString*)title
|
||||||
|
{
|
||||||
|
nsAutoString title;
|
||||||
|
// XXX use the flattening API when there are available
|
||||||
|
// see bug 768298
|
||||||
|
nsresult rv = mGeckoAccessible->GetContent()->GetTextContent(title);
|
||||||
|
NS_ENSURE_SUCCESS(rv, nil);
|
||||||
|
|
||||||
|
return nsCocoaUtils::ToNSString(title);
|
||||||
|
}
|
||||||
|
|
||||||
- (id)value
|
- (id)value
|
||||||
{
|
{
|
||||||
if (!mGeckoAccessible || !mGeckoAccessible->IsHyperText())
|
if (!mGeckoAccessible || !mGeckoAccessible->IsHyperText())
|
||||||
|
@ -14,3 +14,8 @@
|
|||||||
nsIAccessibleEditableText *mGeckoEditableTextAccessible; // strong
|
nsIAccessibleEditableText *mGeckoEditableTextAccessible; // strong
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface mozTextLeafAccessible : mozAccessible
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "AccessibleWrap.h"
|
#include "AccessibleWrap.h"
|
||||||
|
#include "TextLeafAccessible.h"
|
||||||
|
|
||||||
#include "nsCocoaUtils.h"
|
#include "nsCocoaUtils.h"
|
||||||
#include "nsObjCExceptions.h"
|
#include "nsObjCExceptions.h"
|
||||||
@ -110,13 +111,18 @@ ToNSString(id aValue)
|
|||||||
if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute])
|
if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute])
|
||||||
return [self selectedText];
|
return [self selectedText];
|
||||||
|
|
||||||
|
if ([attribute isEqualToString:NSAccessibilityTitleAttribute])
|
||||||
|
return @"";
|
||||||
|
|
||||||
if ([attribute isEqualToString:NSAccessibilityValueAttribute]) {
|
if ([attribute isEqualToString:NSAccessibilityValueAttribute]) {
|
||||||
// Apple's SpeechSynthesisServer expects AXValue to return an AXStaticText
|
// Apple's SpeechSynthesisServer expects AXValue to return an AXStaticText
|
||||||
// object's AXSelectedText attribute. See bug 674612 for details.
|
// object's AXSelectedText attribute. See bug 674612 for details.
|
||||||
// Also if there is no selected text, we return the full text.
|
// Also if there is no selected text, we return the full text.
|
||||||
// See bug 369710 for details.
|
// See bug 369710 for details.
|
||||||
if ([[self role] isEqualToString:NSAccessibilityStaticTextRole])
|
if ([[self role] isEqualToString:NSAccessibilityStaticTextRole]) {
|
||||||
return [self selectedText] ? : [self text];
|
NSString* selectedText = [self selectedText];
|
||||||
|
return (selectedText && [selectedText length]) ? selectedText : [self text];
|
||||||
|
}
|
||||||
|
|
||||||
return [self text];
|
return [self text];
|
||||||
}
|
}
|
||||||
@ -226,7 +232,7 @@ ToNSString(id aValue)
|
|||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||||
|
|
||||||
if ([attribute isEqualToString:NSAccessibilityValueAttribute])
|
if ([attribute isEqualToString:NSAccessibilityValueAttribute])
|
||||||
return [self isReadOnly];
|
return ![self isReadOnly];
|
||||||
|
|
||||||
if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute] ||
|
if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute] ||
|
||||||
[attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute] ||
|
[attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute] ||
|
||||||
@ -359,7 +365,7 @@ ToNSString(id aValue)
|
|||||||
|
|
||||||
- (NSString*)text
|
- (NSString*)text
|
||||||
{
|
{
|
||||||
if (!mGeckoTextAccessible)
|
if (!mGeckoAccessible || !mGeckoTextAccessible)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
// A password text field returns an empty value
|
// A password text field returns an empty value
|
||||||
@ -378,6 +384,9 @@ ToNSString(id aValue)
|
|||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||||
|
|
||||||
|
if (!mGeckoAccessible || !mGeckoTextAccessible)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return mGeckoTextAccessible ? mGeckoTextAccessible->CharacterCount() : 0;
|
return mGeckoTextAccessible ? mGeckoTextAccessible->CharacterCount() : 0;
|
||||||
|
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0);
|
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0);
|
||||||
@ -484,3 +493,45 @@ ToNSString(id aValue)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@implementation mozTextLeafAccessible
|
||||||
|
|
||||||
|
- (NSArray*)accessibilityAttributeNames
|
||||||
|
{
|
||||||
|
static NSMutableArray* supportedAttributes = nil;
|
||||||
|
if (!supportedAttributes) {
|
||||||
|
supportedAttributes = [[super accessibilityAttributeNames] mutableCopy];
|
||||||
|
[supportedAttributes removeObject:NSAccessibilityChildrenAttribute];
|
||||||
|
}
|
||||||
|
|
||||||
|
return supportedAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)accessibilityAttributeValue:(NSString*)attribute
|
||||||
|
{
|
||||||
|
if ([attribute isEqualToString:NSAccessibilityTitleAttribute])
|
||||||
|
return @"";
|
||||||
|
|
||||||
|
if ([attribute isEqualToString:NSAccessibilityValueAttribute])
|
||||||
|
return [self text];
|
||||||
|
|
||||||
|
return [super accessibilityAttributeValue:attribute];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*)text
|
||||||
|
{
|
||||||
|
if (!mGeckoAccessible)
|
||||||
|
return nil;
|
||||||
|
|
||||||
|
return nsCocoaUtils::ToNSString(mGeckoAccessible->AsTextLeaf()->Text());
|
||||||
|
}
|
||||||
|
|
||||||
|
- (long)textLength
|
||||||
|
{
|
||||||
|
if (!mGeckoAccessible)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return mGeckoAccessible->AsTextLeaf()->Text().Length();
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user