Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8264299: Create implementation of native accessibility peer for ScrollPane and ScrollBar Java Accessibility roles #3794

Closed
wants to merge 8 commits into from
@@ -112,19 +112,6 @@ - (void)getActionsWithEnv:(JNIEnv *)env;
- (id)accessibilityValueAttribute;
@end


@interface ScrollAreaAccessibility_Old : JavaComponentAccessibility {

}
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env;
- (NSArray *)accessibilityContentsAttribute;
- (BOOL)accessibilityIsContentsAttributeSettable;
- (id)accessibilityVerticalScrollBarAttribute;
- (BOOL)accessibilityIsVerticalScrollBarAttributeSettable;
- (id)accessibilityHorizontalScrollBarAttribute;
- (BOOL)accessibilityIsHorizontalScrollBarAttributeSettable;
@end

@interface TableAccessibility : JavaComponentAccessibility {

}
@@ -381,8 +368,6 @@ + (JavaComponentAccessibility *) createWithParent:(JavaComponentAccessibility *)
newChild = [TabGroupAccessibility alloc];
} else if ([javaRole isEqualToString:@"table"]) {
newChild = [TableAccessibility alloc];
} else if ([javaRole isEqualToString:@"scrollpane"]) {
newChild = [ScrollAreaAccessibility_Old alloc];
} else {
NSString *nsRole = [sRoles objectForKey:javaRole];
if ([nsRole isEqualToString:NSAccessibilityStaticTextRole] ||
@@ -1876,105 +1861,6 @@ - (jobject)tabGroup
@end


@implementation ScrollAreaAccessibility_Old

- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env
{
NSMutableArray *names = (NSMutableArray *)[super initializeAttributeNamesWithEnv:env];

[names addObject:NSAccessibilityHorizontalScrollBarAttribute];
[names addObject:NSAccessibilityVerticalScrollBarAttribute];
[names addObject:NSAccessibilityContentsAttribute];

return names;
}

- (id)accessibilityHorizontalScrollBarAttribute
{
JNIEnv *env = [ThreadUtilities getJNIEnv];

NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
if ([children count] <= 0) return nil;

// The scroll bars are in the children.
JavaComponentAccessibility *aElement;
NSEnumerator *enumerator = [children objectEnumerator];
while ((aElement = (JavaComponentAccessibility *)[enumerator nextObject])) {
if ([[aElement accessibilityRoleAttribute] isEqualToString:NSAccessibilityScrollBarRole]) {
jobject elementAxContext = [aElement axContextWithEnv:env];
if (isHorizontal(env, elementAxContext, fComponent)) {
(*env)->DeleteLocalRef(env, elementAxContext);
return aElement;
}
(*env)->DeleteLocalRef(env, elementAxContext);
}
}

return nil;
}

- (BOOL)accessibilityIsHorizontalScrollBarAttributeSettable
{
return NO;
}

- (id)accessibilityVerticalScrollBarAttribute
{
JNIEnv *env = [ThreadUtilities getJNIEnv];

NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
if ([children count] <= 0) return nil;

// The scroll bars are in the children.
NSEnumerator *enumerator = [children objectEnumerator];
JavaComponentAccessibility *aElement;
while ((aElement = (JavaComponentAccessibility *)[enumerator nextObject])) {
if ([[aElement accessibilityRoleAttribute] isEqualToString:NSAccessibilityScrollBarRole]) {
jobject elementAxContext = [aElement axContextWithEnv:env];
if (isVertical(env, elementAxContext, fComponent)) {
(*env)->DeleteLocalRef(env, elementAxContext);
return aElement;
}
(*env)->DeleteLocalRef(env, elementAxContext);
}
}

return nil;
}

- (BOOL)accessibilityIsVerticalScrollBarAttributeSettable
{
return NO;
}

- (NSArray *)accessibilityContentsAttribute
{
JNIEnv *env = [ThreadUtilities getJNIEnv];
NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];

if ([children count] <= 0) return nil;
NSArray *contents = [NSMutableArray arrayWithCapacity:[children count]];

// The scroll bars are in the children. children less the scroll bars is the contents
NSEnumerator *enumerator = [children objectEnumerator];
JavaComponentAccessibility *aElement;
while ((aElement = (JavaComponentAccessibility *)[enumerator nextObject])) {
if (![[aElement accessibilityRoleAttribute] isEqualToString:NSAccessibilityScrollBarRole]) {
// no scroll bars in contents
[(NSMutableArray *)contents addObject:aElement];
}
}

return contents;
}

- (BOOL)accessibilityIsContentsAttributeSettable
{
return NO;
}

@end

// these constants are duplicated in CAccessibility.java
#define JAVA_AX_ROWS (1)
#define JAVA_AX_COLS (2)