Backed out changeset 8d3a31f6fcd6 (bug 1643765) by morgan's request CLOSED TREE

This commit is contained in:
Bogdan Tara 2020-07-08 19:57:22 +03:00
parent 7d938e109a
commit 92d6c2f06f
13 changed files with 73 additions and 117 deletions

View File

@ -98,18 +98,6 @@ 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;

View File

@ -313,17 +313,7 @@ using namespace mozilla::a11y;
}
- (BOOL)isAccessibilityElement {
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);
return YES;
}
- (BOOL)accessibilityNotifiesWhenDestroyed {
@ -366,50 +356,6 @@ 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 {

View File

@ -34,32 +34,15 @@
// 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)moxUnignoredChildren;
- (NSArray* _Nullable)moxChildren;
// AXParent
- (id _Nullable)moxUnignoredParent;
- (id _Nullable)moxParent;
// AXRole
- (NSString* _Nullable)moxRole;

View File

@ -89,6 +89,17 @@ 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
@ -184,12 +195,6 @@ 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
@ -201,6 +206,10 @@ inline mozAccessible* GetNativeFromGeckoAccessible(mozilla::a11y::AccessibleOrPr
// ---- NSAccessibility methods ---- //
// whether to include this element in the platform's tree
// override
- (BOOL)isAccessibilityElement;
// override
- (NSString*)description;

View File

@ -77,7 +77,26 @@ using namespace mozilla::a11y;
#pragma mark -
- (BOOL)moxIgnoreWithParent:(mozAccessible*)parent {
- (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 {
if (Accessible* acc = mGeckoAccessible.AsAccessible()) {
if (acc->IsContent() && acc->GetContent()->IsXULElement()) {
if (acc->VisibilityState() & states::INVISIBLE) {
@ -86,10 +105,10 @@ using namespace mozilla::a11y;
}
}
return [parent moxIgnoreChild:self];
return [parent ignoreChild:self];
}
- (BOOL)moxIgnoreChild:(mozAccessible*)child {
- (BOOL)ignoreChild:(mozAccessible*)child {
return NO;
}
@ -247,7 +266,7 @@ static const uint64_t kCacheInitialized = ((uint64_t)0x1) << 63;
if (!child.IsNull()) {
mozAccessible* nativeChild = GetNativeFromGeckoAccessible(child);
return [nativeChild isAccessibilityElement] ? nativeChild : [nativeChild moxUnignoredParent];
return [nativeChild isAccessibilityElement] ? nativeChild : [nativeChild moxParent];
}
// if we didn't find anything, return ourself or child view.
@ -273,12 +292,16 @@ 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 all our native children lazily, including those that are ignored.
// gets our native children lazily.
- (NSArray*)moxChildren {
MOZ_ASSERT(!mGeckoAccessible.IsNull());
@ -292,7 +315,14 @@ static const uint64_t kCacheInitialized = ((uint64_t)0x1) << 63;
continue;
}
[children addObject:nativeChild];
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];
}
}
return children;
@ -624,7 +654,7 @@ struct RoleDescrComparator {
}
if (![self isRoot]) {
mozAccessible* parent = (mozAccessible*)[self moxUnignoredParent];
mozAccessible* parent = (mozAccessible*)[self moxParent];
if (![parent isRoot]) {
return @(![parent disableChild:self]);
}

View File

@ -33,7 +33,7 @@
- (void)stateChanged:(uint64_t)state isEnabled:(BOOL)enabled;
// override
- (BOOL)moxIgnoreWithParent:(mozAccessible*)parent;
- (BOOL)ignoreWithParent:(mozAccessible*)parent;
@end

View File

@ -75,7 +75,7 @@ enum CheckboxValue {
}
}
- (BOOL)moxIgnoreWithParent:(mozAccessible*)parent {
- (BOOL)ignoreWithParent:(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 moxIgnoreWithParent:parent];
return [super ignoreWithParent:parent];
}
@end

View File

@ -40,7 +40,7 @@
- (NSNumber*)moxMinimized;
// override
- (id)moxUnignoredParent;
- (id)moxParent;
#pragma mark - mozAccessible/widget

View File

@ -46,7 +46,7 @@ static id<mozAccessible, mozView> getNativeViewFromRootAccessible(Accessible* aA
}
// return the AXParent that our parallell NSView tells us about.
- (id)moxUnignoredParent {
- (id)moxParent {
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 moxUnignoredParent];
return [super moxParent];
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}

View File

@ -54,7 +54,7 @@
@interface mozListboxAccessible : mozSelectableAccessible
// override
- (BOOL)moxIgnoreChild:(mozAccessible*)child;
- (BOOL)ignoreChild:(mozAccessible*)child;
// override
- (BOOL)disableChild:(mozAccessible*)child;

View File

@ -13,7 +13,7 @@
* Return the mozAccessibles that are selectable.
*/
- (NSArray*)selectableChildren {
return [[self moxUnignoredChildren]
return [[self moxChildren]
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 moxUnignoredChildren]
return [[self moxChildren]
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(mozAccessible* child,
NSDictionary* bindings) {
// Return mozSelectableChildAccessibles that have are selected (truthy value).
@ -77,7 +77,7 @@
}
- (NSArray*)moxContents {
return [self moxUnignoredChildren];
return [self moxChildren];
}
- (id)moxValue {
@ -103,12 +103,12 @@
@implementation mozListboxAccessible
- (BOOL)moxIgnoreChild:(mozAccessible*)child {
- (BOOL)ignoreChild:(mozAccessible*)child {
if (!child || child->mRole == roles::GROUPING) {
return YES;
}
return [super moxIgnoreChild:child];
return [super ignoreChild: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 moxUnignoredParent];
mozAccessible* parent = (mozAccessible*)[self moxParent];
[parent moxPostNotification:NSAccessibilitySelectedChildrenChangedNotification];
break;
}

View File

@ -26,7 +26,7 @@
- (mozAccessible*)moxParent;
// override
- (NSArray*)moxUnignoredChildren;
- (NSArray*)moxChildren;
// override
- (void)dealloc;
@ -78,7 +78,7 @@
- (NSArray*)moxColumns;
// override
- (NSArray*)moxUnignoredChildren;
- (NSArray*)moxChildren;
@end

View File

@ -31,7 +31,7 @@
return mParent;
}
- (NSArray*)moxUnignoredChildren {
- (NSArray*)moxChildren {
if (mChildren) return mChildren;
mChildren = [[NSMutableArray alloc] init];
@ -206,8 +206,8 @@
return mColContainers;
}
- (NSArray*)moxUnignoredChildren {
return [[super moxUnignoredChildren] arrayByAddingObjectsFromArray:[self moxColumns]];
- (NSArray*)moxChildren {
return [[super moxChildren] arrayByAddingObjectsFromArray:[self moxColumns]];
}
- (void)invalidateColumns {