Skip to content
Permalink
Browse files
8256108: Create implementation for NSAccessibilityElement protocol peer
Reviewed-by: serb
  • Loading branch information
Alexander Zuev committed Nov 20, 2020
1 parent 6813889 commit 4c095252a540ea799d6014fb42e6ebedb3b24196
Showing with 44 additions and 1 deletion.
  1. +44 −1 src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -127,6 +127,23 @@ - (NSArray *)accessibilityColumnsAttribute;
@end


// In order to use a new NSAccessibility API and since our components
// are represented as a custom UI elements we need to implement a set
// of custom protocols. Definitions of these protocols will start here.

// This is a root interface in the NSAccessibility* protocols hierarchy
// and all the component-specific protocols should be derived from it.
// It is also a place for the functions that might be exposed by all the
// component accessibility peers.
// Please see https://developer.apple.com/documentation/appkit/nsaccessibilityprotocol
// for more details.
@interface CommonComponentAccessibility : JavaComponentAccessibility <NSAccessibilityElement> {

}
- (NSRect)accessibilityFrame;
- (nullable id)accessibilityParent;
@end

@implementation JavaComponentAccessibility

- (NSString *)description
@@ -1917,6 +1934,32 @@ - (id)accessibilityColumnCountAttribute {
}
@end

@implementation CommonComponentAccessibility
// NSAccessibilityElement protocol implementation
- (NSRect)accessibilityFrame
{
JNIEnv* env = [ThreadUtilities getJNIEnv];
jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent,
fAccessible, fComponent);

NSSize size = getAxComponentSize(env, axComponent, fComponent);
NSPoint point = getAxComponentLocationOnScreen(env, axComponent, fComponent);
(*env)->DeleteLocalRef(env, axComponent);
point.y += size.height;

point.y = [[[[self view] window] screen] frame].size.height - point.y;

NSRect retval = NSMakeRect(point.x, point.y, size.width, size.height);
return retval;
}

- (nullable id)accessibilityParent
{
return [self accessibilityParentAttribute];
}

@end

/*
* Returns Object.equals for the two items
* This may use LWCToolkit.invokeAndWait(); don't call while holding fLock

1 comment on commit 4c09525

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 4c09525 Nov 20, 2020

Please sign in to comment.