mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1643765: Add moxUnignoredChildren getter to MOXAccessibleBase r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D80983
This commit is contained in:
parent
8b5037b2d1
commit
22c2b06956
@ -98,6 +98,18 @@ inline id<mozAccessible> GetObjectOrRepresentedView(id<mozAccessible> aObject) {
|
||||
// override
|
||||
- (id<MOXTextMarkerSupport>)moxTextMarkerDelegate;
|
||||
|
||||
// override
|
||||
- (NSArray*)moxUnignoredChildren;
|
||||
|
||||
// override
|
||||
- (NSArray*)moxChildren;
|
||||
|
||||
// override
|
||||
- (id<mozAccessible>)moxUnignoredParent;
|
||||
|
||||
// override
|
||||
- (id<mozAccessible>)moxParent;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (BOOL)isExpired;
|
||||
|
@ -313,7 +313,17 @@ using namespace mozilla::a11y;
|
||||
}
|
||||
|
||||
- (BOOL)isAccessibilityElement {
|
||||
return YES;
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||
|
||||
if ([self isExpired]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
id parent = [self moxParent];
|
||||
|
||||
return ![self moxIgnoreWithParent:parent];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityNotifiesWhenDestroyed {
|
||||
@ -356,6 +366,50 @@ using namespace mozilla::a11y;
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray*)moxChildren {
|
||||
return @[];
|
||||
}
|
||||
|
||||
- (NSArray*)moxUnignoredChildren {
|
||||
NSMutableArray* unignoredChildren = [[NSMutableArray alloc] init];
|
||||
NSArray* allChildren = [self moxChildren];
|
||||
|
||||
for (MOXAccessibleBase* nativeChild in allChildren) {
|
||||
if ([nativeChild moxIgnoreWithParent:self]) {
|
||||
// If this child should be ignored get its unignored children.
|
||||
// This will in turn recurse to any unignored descendants if the
|
||||
// child is ignored.
|
||||
[unignoredChildren addObjectsFromArray:[nativeChild moxUnignoredChildren]];
|
||||
} else {
|
||||
[unignoredChildren addObject:nativeChild];
|
||||
}
|
||||
}
|
||||
|
||||
return unignoredChildren;
|
||||
}
|
||||
|
||||
- (id<mozAccessible>)moxParent {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id<mozAccessible>)moxUnignoredParent {
|
||||
id nativeParent = [self moxParent];
|
||||
|
||||
if (![nativeParent isAccessibilityElement]) {
|
||||
return [nativeParent moxUnignoredParent];
|
||||
}
|
||||
|
||||
return GetObjectOrRepresentedView(nativeParent);
|
||||
}
|
||||
|
||||
- (BOOL)moxIgnoreWithParent:(MOXAccessibleBase*)parent {
|
||||
return [parent moxIgnoreChild:self];
|
||||
}
|
||||
|
||||
- (BOOL)moxIgnoreChild:(MOXAccessibleBase*)child {
|
||||
return NO;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (BOOL)isExpired {
|
||||
|
@ -34,15 +34,32 @@
|
||||
// Return text delegate if it exists.
|
||||
- (id<MOXTextMarkerSupport> _Nullable)moxTextMarkerDelegate;
|
||||
|
||||
// Returns a list of all children, doesn't do ignore filtering.
|
||||
- (NSArray* _Nullable)moxChildren;
|
||||
|
||||
// Returns our parent, doesn't do ignore filtering.
|
||||
- (id<mozAccessible> _Nullable)moxParent;
|
||||
|
||||
// This is called by isAccessibilityElement. If a subclass wants
|
||||
// to alter the isAccessibilityElement return value, it must
|
||||
// override this and not isAccessibilityElement directly.
|
||||
- (BOOL)moxIgnoreWithParent:(id<MOXAccessible> _Nullable)parent;
|
||||
|
||||
// Should the child be ignored. This allows subclasses to determine
|
||||
// what kinds of accessibles are valid children. This causes the child
|
||||
// to be skipped, but the unignored descendants will be added to the
|
||||
// container in the default children getter.
|
||||
- (BOOL)moxIgnoreChild:(id<MOXAccessible> _Nullable)child;
|
||||
|
||||
@optional
|
||||
|
||||
#pragma mark - AttributeGetters
|
||||
|
||||
// AXChildren
|
||||
- (NSArray* _Nullable)moxChildren;
|
||||
- (NSArray* _Nullable)moxUnignoredChildren;
|
||||
|
||||
// AXParent
|
||||
- (id _Nullable)moxParent;
|
||||
- (id _Nullable)moxUnignoredParent;
|
||||
|
||||
// AXRole
|
||||
- (NSString* _Nullable)moxRole;
|
||||
|
@ -89,17 +89,6 @@ inline mozAccessible* GetNativeFromGeckoAccessible(mozilla::a11y::AccessibleOrPr
|
||||
// Invalidate cached state.
|
||||
- (void)invalidateState;
|
||||
|
||||
// This is called by isAccessibilityElement. If a subclass wants
|
||||
// to alter the isAccessibilityElement return value, it should
|
||||
// override this and not isAccessibilityElement directly.
|
||||
- (BOOL)ignoreWithParent:(mozAccessible*)parent;
|
||||
|
||||
// Should the child be ignored. This allows subclasses to determine
|
||||
// what kinds of accessibles are valid children. This causes the child
|
||||
// to be skipped, but the unignored descendants will be added to the
|
||||
// container in the default children getter.
|
||||
- (BOOL)ignoreChild:(mozAccessible*)child;
|
||||
|
||||
#pragma mark - mozAccessible protocol / widget
|
||||
|
||||
// override
|
||||
@ -195,6 +184,12 @@ inline mozAccessible* GetNativeFromGeckoAccessible(mozilla::a11y::AccessibleOrPr
|
||||
// override
|
||||
- (void)moxPerformPress;
|
||||
|
||||
// override
|
||||
- (BOOL)moxIgnoreWithParent:(mozAccessible*)parent;
|
||||
|
||||
// override
|
||||
- (BOOL)moxIgnoreChild:(mozAccessible*)child;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// makes ourselves "expired". after this point, we might be around if someone
|
||||
@ -206,10 +201,6 @@ inline mozAccessible* GetNativeFromGeckoAccessible(mozilla::a11y::AccessibleOrPr
|
||||
|
||||
// ---- NSAccessibility methods ---- //
|
||||
|
||||
// whether to include this element in the platform's tree
|
||||
// override
|
||||
- (BOOL)isAccessibilityElement;
|
||||
|
||||
// override
|
||||
- (NSString*)description;
|
||||
|
||||
|
@ -77,26 +77,7 @@ using namespace mozilla::a11y;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (BOOL)isAccessibilityElement {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||
|
||||
if ([self isExpired]) {
|
||||
return ![self ignoreWithParent:nil];
|
||||
}
|
||||
|
||||
mozAccessible* parent = nil;
|
||||
AccessibleOrProxy p = mGeckoAccessible.Parent();
|
||||
|
||||
if (!p.IsNull()) {
|
||||
parent = GetNativeFromGeckoAccessible(p);
|
||||
}
|
||||
|
||||
return ![self ignoreWithParent:parent];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
|
||||
}
|
||||
|
||||
- (BOOL)ignoreWithParent:(mozAccessible*)parent {
|
||||
- (BOOL)moxIgnoreWithParent:(mozAccessible*)parent {
|
||||
if (Accessible* acc = mGeckoAccessible.AsAccessible()) {
|
||||
if (acc->IsContent() && acc->GetContent()->IsXULElement()) {
|
||||
if (acc->VisibilityState() & states::INVISIBLE) {
|
||||
@ -105,10 +86,10 @@ using namespace mozilla::a11y;
|
||||
}
|
||||
}
|
||||
|
||||
return [parent ignoreChild:self];
|
||||
return [parent moxIgnoreChild:self];
|
||||
}
|
||||
|
||||
- (BOOL)ignoreChild:(mozAccessible*)child {
|
||||
- (BOOL)moxIgnoreChild:(mozAccessible*)child {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@ -266,7 +247,7 @@ static const uint64_t kCacheInitialized = ((uint64_t)0x1) << 63;
|
||||
|
||||
if (!child.IsNull()) {
|
||||
mozAccessible* nativeChild = GetNativeFromGeckoAccessible(child);
|
||||
return [nativeChild isAccessibilityElement] ? nativeChild : [nativeChild moxParent];
|
||||
return [nativeChild isAccessibilityElement] ? nativeChild : [nativeChild moxUnignoredParent];
|
||||
}
|
||||
|
||||
// if we didn't find anything, return ourself or child view.
|
||||
@ -292,16 +273,12 @@ static const uint64_t kCacheInitialized = ((uint64_t)0x1) << 63;
|
||||
nativeParent = GetNativeFromGeckoAccessible(mGeckoAccessible.AsAccessible()->RootAccessible());
|
||||
}
|
||||
|
||||
if (![nativeParent isAccessibilityElement]) {
|
||||
nativeParent = [nativeParent moxParent];
|
||||
}
|
||||
|
||||
return GetObjectOrRepresentedView(nativeParent);
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
||||
}
|
||||
|
||||
// gets our native children lazily.
|
||||
// gets all our native children lazily, including those that are ignored.
|
||||
- (NSArray*)moxChildren {
|
||||
MOZ_ASSERT(!mGeckoAccessible.IsNull());
|
||||
|
||||
@ -315,14 +292,7 @@ static const uint64_t kCacheInitialized = ((uint64_t)0x1) << 63;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([nativeChild ignoreWithParent:self]) {
|
||||
// If this child should be ignored get its unignored children.
|
||||
// This will in turn recurse to any unignored descendants if the
|
||||
// child is ignored.
|
||||
[children addObjectsFromArray:[nativeChild moxChildren]];
|
||||
} else {
|
||||
[children addObject:nativeChild];
|
||||
}
|
||||
[children addObject:nativeChild];
|
||||
}
|
||||
|
||||
return children;
|
||||
@ -654,7 +624,7 @@ struct RoleDescrComparator {
|
||||
}
|
||||
|
||||
if (![self isRoot]) {
|
||||
mozAccessible* parent = (mozAccessible*)[self moxParent];
|
||||
mozAccessible* parent = (mozAccessible*)[self moxUnignoredParent];
|
||||
if (![parent isRoot]) {
|
||||
return @(![parent disableChild:self]);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
- (void)stateChanged:(uint64_t)state isEnabled:(BOOL)enabled;
|
||||
|
||||
// override
|
||||
- (BOOL)ignoreWithParent:(mozAccessible*)parent;
|
||||
- (BOOL)moxIgnoreWithParent:(mozAccessible*)parent;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -75,7 +75,7 @@ enum CheckboxValue {
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)ignoreWithParent:(mozAccessible*)parent {
|
||||
- (BOOL)moxIgnoreWithParent:(mozAccessible*)parent {
|
||||
if (Accessible* acc = mGeckoAccessible.AsAccessible()) {
|
||||
if (acc->IsContent() && acc->GetContent()->IsXULElement(nsGkAtoms::menulist)) {
|
||||
// The way select elements work is that content has a COMBOBOX accessible, when it is clicked
|
||||
@ -87,7 +87,7 @@ enum CheckboxValue {
|
||||
}
|
||||
}
|
||||
|
||||
return [super ignoreWithParent:parent];
|
||||
return [super moxIgnoreWithParent:parent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -40,7 +40,7 @@
|
||||
- (NSNumber*)moxMinimized;
|
||||
|
||||
// override
|
||||
- (id)moxParent;
|
||||
- (id)moxUnignoredParent;
|
||||
|
||||
#pragma mark - mozAccessible/widget
|
||||
|
||||
|
@ -46,7 +46,7 @@ static id<mozAccessible, mozView> getNativeViewFromRootAccessible(Accessible* aA
|
||||
}
|
||||
|
||||
// return the AXParent that our parallell NSView tells us about.
|
||||
- (id)moxParent {
|
||||
- (id)moxUnignoredParent {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
|
||||
if (!mParallelView) mParallelView = (id<mozView, mozAccessible>)[self representedView];
|
||||
@ -55,7 +55,7 @@ static id<mozAccessible, mozView> getNativeViewFromRootAccessible(Accessible* aA
|
||||
return [mParallelView accessibilityAttributeValue:NSAccessibilityParentAttribute];
|
||||
|
||||
MOZ_ASSERT(mParallelView, "we're a root accessible w/o native view?");
|
||||
return [super moxParent];
|
||||
return [super moxUnignoredParent];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@
|
||||
@interface mozListboxAccessible : mozSelectableAccessible
|
||||
|
||||
// override
|
||||
- (BOOL)ignoreChild:(mozAccessible*)child;
|
||||
- (BOOL)moxIgnoreChild:(mozAccessible*)child;
|
||||
|
||||
// override
|
||||
- (BOOL)disableChild:(mozAccessible*)child;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* Return the mozAccessibles that are selectable.
|
||||
*/
|
||||
- (NSArray*)selectableChildren {
|
||||
return [[self moxChildren]
|
||||
return [[self moxUnignoredChildren]
|
||||
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(mozAccessible* child,
|
||||
NSDictionary* bindings) {
|
||||
return [child isKindOfClass:[mozSelectableChildAccessible class]];
|
||||
@ -31,7 +31,7 @@
|
||||
* Return the mozAccessibles that are actually selected.
|
||||
*/
|
||||
- (NSArray*)moxSelectedChildren {
|
||||
return [[self moxChildren]
|
||||
return [[self moxUnignoredChildren]
|
||||
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(mozAccessible* child,
|
||||
NSDictionary* bindings) {
|
||||
// Return mozSelectableChildAccessibles that have are selected (truthy value).
|
||||
@ -77,7 +77,7 @@
|
||||
}
|
||||
|
||||
- (NSArray*)moxContents {
|
||||
return [self moxChildren];
|
||||
return [self moxUnignoredChildren];
|
||||
}
|
||||
|
||||
- (id)moxValue {
|
||||
@ -103,12 +103,12 @@
|
||||
|
||||
@implementation mozListboxAccessible
|
||||
|
||||
- (BOOL)ignoreChild:(mozAccessible*)child {
|
||||
- (BOOL)moxIgnoreChild:(mozAccessible*)child {
|
||||
if (!child || child->mRole == roles::GROUPING) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return [super ignoreChild:child];
|
||||
return [super moxIgnoreChild:child];
|
||||
}
|
||||
|
||||
- (BOOL)disableChild:(mozAccessible*)child {
|
||||
@ -201,7 +201,7 @@
|
||||
switch (eventType) {
|
||||
case nsIAccessibleEvent::EVENT_FOCUS:
|
||||
// Our focused state is equivelent to native selected states for menus.
|
||||
mozAccessible* parent = (mozAccessible*)[self moxParent];
|
||||
mozAccessible* parent = (mozAccessible*)[self moxUnignoredParent];
|
||||
[parent moxPostNotification:NSAccessibilitySelectedChildrenChangedNotification];
|
||||
break;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
- (mozAccessible*)moxParent;
|
||||
|
||||
// override
|
||||
- (NSArray*)moxChildren;
|
||||
- (NSArray*)moxUnignoredChildren;
|
||||
|
||||
// override
|
||||
- (void)dealloc;
|
||||
@ -78,7 +78,7 @@
|
||||
- (NSArray*)moxColumns;
|
||||
|
||||
// override
|
||||
- (NSArray*)moxChildren;
|
||||
- (NSArray*)moxUnignoredChildren;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
return mParent;
|
||||
}
|
||||
|
||||
- (NSArray*)moxChildren {
|
||||
- (NSArray*)moxUnignoredChildren {
|
||||
if (mChildren) return mChildren;
|
||||
|
||||
mChildren = [[NSMutableArray alloc] init];
|
||||
@ -206,8 +206,8 @@
|
||||
return mColContainers;
|
||||
}
|
||||
|
||||
- (NSArray*)moxChildren {
|
||||
return [[super moxChildren] arrayByAddingObjectsFromArray:[self moxColumns]];
|
||||
- (NSArray*)moxUnignoredChildren {
|
||||
return [[super moxUnignoredChildren] arrayByAddingObjectsFromArray:[self moxColumns]];
|
||||
}
|
||||
|
||||
- (void)invalidateColumns {
|
||||
|
Loading…
Reference in New Issue
Block a user