diff --git a/accessible/src/mac/mozAccessible.mm b/accessible/src/mac/mozAccessible.mm index b70605d92934..5c36da66fe3d 100644 --- a/accessible/src/mac/mozAccessible.mm +++ b/accessible/src/mac/mozAccessible.mm @@ -183,7 +183,7 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible) return nil; if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) - return NSAccessibilityUnignoredChildren ([self children]); + return [self children]; if ([attribute isEqualToString:NSAccessibilityParentAttribute]) return [self parent]; @@ -371,6 +371,15 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible) } } +#ifdef DEBUG_hakan + // make sure we're not returning any ignored accessibles. + NSEnumerator *e = [mChildren objectEnumerator]; + mozAccessible *m = nil; + while ((m = [e nextObject])) { + NSAssert1(![m accessibilityIsIgnored], @"we should never return an ignored accessible! (%@)", m); + } +#endif + return mChildren; } diff --git a/accessible/src/mac/mozActionElements.h b/accessible/src/mac/mozActionElements.h index b26b933c9173..79f904c93778 100644 --- a/accessible/src/mac/mozActionElements.h +++ b/accessible/src/mac/mozActionElements.h @@ -50,5 +50,6 @@ - (int)isChecked; @end +/* Used for buttons that may pop up a menu. */ @interface mozPopupButtonAccessible : mozButtonAccessible @end diff --git a/accessible/src/mac/mozTextAccessible.h b/accessible/src/mac/mozTextAccessible.h index 26c19741c067..7a561b246508 100644 --- a/accessible/src/mac/mozTextAccessible.h +++ b/accessible/src/mac/mozTextAccessible.h @@ -11,3 +11,13 @@ nsIAccessibleEditableText *mGeckoEditableTextAccessible; // strong } @end + +/* A combobox (in the mac world) is a textfield with an associated menu, for example + the location bar. */ +@interface mozComboboxAccessible : mozTextAccessible +// equivalent to pressing return key in this textfield. +- (void)confirm; + +// shows the menu for this combobox. +- (void)showMenu; +@end diff --git a/accessible/src/mac/mozTextAccessible.mm b/accessible/src/mac/mozTextAccessible.mm index e6e6c8fe9c10..362fb4ad49ea 100644 --- a/accessible/src/mac/mozTextAccessible.mm +++ b/accessible/src/mac/mozTextAccessible.mm @@ -181,3 +181,81 @@ extern const NSString *kTopLevelUIElementAttribute; // NSAccessibilityTopLevel } @end + +@implementation mozComboboxAccessible + +- (NSArray*)accessibilityAttributeNames +{ + static NSArray *supportedAttributes = nil; + if (!supportedAttributes) { + // standard attributes that are shared and supported by all generic elements. + supportedAttributes = [[NSArray alloc] initWithObjects:NSAccessibilityParentAttribute, // required + NSAccessibilityRoleAttribute, // required + NSAccessibilityTitleAttribute, + NSAccessibilityValueAttribute, // required + NSAccessibilityHelpAttribute, + NSAccessibilityRoleDescriptionAttribute, + NSAccessibilityPositionAttribute, // required + NSAccessibilitySizeAttribute, // required + NSAccessibilityWindowAttribute, // required + NSAccessibilityFocusedAttribute, // required + NSAccessibilityEnabledAttribute, // required + NSAccessibilityChildrenAttribute, // required + NSAccessibilityHelpAttribute, + // NSAccessibilityExpandedAttribute, // required + kTopLevelUIElementAttribute, // required (on OS X 10.4+) + kInstanceDescriptionAttribute, // required (on OS X 10.4+) + /* text-specific attributes */ + NSAccessibilitySelectedTextAttribute, // required + NSAccessibilitySelectedTextRangeAttribute, // required + NSAccessibilityNumberOfCharactersAttribute, // required + // TODO: NSAccessibilityVisibleCharacterRangeAttribute, // required + // TODO: NSAccessibilityInsertionPointLineNumberAttribute + nil]; + } + return supportedAttributes; +} + +- (NSArray *)accessibilityActionNames +{ + if ([self isEnabled]) { + return [NSArray arrayWithObjects:NSAccessibilityConfirmAction, + NSAccessibilityShowMenuAction, + nil]; + } + return nil; +} + +- (NSString *)accessibilityActionDescription:(NSString *)action +{ + if ([action isEqualToString:NSAccessibilityShowMenuAction]) + return @"show menu"; + if ([action isEqualToString:NSAccessibilityConfirmAction]) + return @"confirm"; + + return [super accessibilityActionDescription:action]; +} + +- (void)accessibilityPerformAction:(NSString *)action +{ + // both the ShowMenu and Click action do the same thing. + if ([self isEnabled]) { + if ([action isEqualToString:NSAccessibilityShowMenuAction]) + [self showMenu]; + if ([action isEqualToString:NSAccessibilityConfirmAction]) + [self confirm]; + } +} + +- (void)showMenu +{ + // currently unimplemented. waiting for support in bug 363697 +} + +- (void)confirm +{ + // should be the same as pressing enter/return in this textfield. + // not yet implemented +} + +@end diff --git a/accessible/src/mac/nsAccessibleWrap.h b/accessible/src/mac/nsAccessibleWrap.h index a4674f01214f..466b3b0cba42 100644 --- a/accessible/src/mac/nsAccessibleWrap.h +++ b/accessible/src/mac/nsAccessibleWrap.h @@ -85,8 +85,7 @@ class nsAccessibleWrap : public nsAccessible role == ROLE_PUSHBUTTON || role == ROLE_TOGGLE_BUTTON || role == ROLE_SPLITBUTTON || - role == ROLE_ENTRY || - role == ROLE_AUTOCOMPLETE); + role == ROLE_ENTRY); } // ignored means that the accessible might still have children, but is not displayed diff --git a/accessible/src/mac/nsAccessibleWrap.mm b/accessible/src/mac/nsAccessibleWrap.mm index 96b5eccef11c..516fe2b0fc06 100644 --- a/accessible/src/mac/nsAccessibleWrap.mm +++ b/accessible/src/mac/nsAccessibleWrap.mm @@ -117,6 +117,9 @@ nsAccessibleWrap::GetNativeType () case ROLE_CHECKBUTTON: return [mozCheckboxAccessible class]; + case ROLE_AUTOCOMPLETE: + return [mozComboboxAccessible class]; + case ROLE_ENTRY: case ROLE_STATICTEXT: case ROLE_HEADING: @@ -124,8 +127,8 @@ nsAccessibleWrap::GetNativeType () case ROLE_CAPTION: case ROLE_ACCEL_LABEL: case ROLE_TEXT_LEAF: - case ROLE_AUTOCOMPLETE: - return [mozTextAccessible class]; + // normal textfield (static or editable) + return [mozTextAccessible class]; case ROLE_COMBOBOX: return [mozPopupButtonAccessible class]; diff --git a/accessible/src/mac/nsRoleMap.h b/accessible/src/mac/nsRoleMap.h index e98a9b5923c7..4b5e67a4ebfe 100644 --- a/accessible/src/mac/nsRoleMap.h +++ b/accessible/src/mac/nsRoleMap.h @@ -142,7 +142,7 @@ static const NSString* AXRoles [] = { NSAccessibilityGroupRole, // ROLE_FOOTER NSAccessibilityGroupRole, // ROLE_PARAGRAPH @"AXRuler", // ROLE_RULER. 10.4+ only, so we re-define the constant. - NSAccessibilityTextFieldRole, // ROLE_AUTOCOMPLETE + NSAccessibilityComboBoxRole, // ROLE_AUTOCOMPLETE NSAccessibilityTextFieldRole, // ROLE_EDITBAR NSAccessibilityTextFieldRole, // ROLE_ENTRY NSAccessibilityStaticTextRole, // ROLE_CAPTION