Skip to content

Commit 4c09525

Browse files
author
Alexander Zuev
committedNov 20, 2020
8256108: Create implementation for NSAccessibilityElement protocol peer
Reviewed-by: serb
1 parent 6813889 commit 4c09525

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed
 

‎src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m

+44-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -127,6 +127,23 @@ - (NSArray *)accessibilityColumnsAttribute;
127127
@end
128128

129129

130+
// In order to use a new NSAccessibility API and since our components
131+
// are represented as a custom UI elements we need to implement a set
132+
// of custom protocols. Definitions of these protocols will start here.
133+
134+
// This is a root interface in the NSAccessibility* protocols hierarchy
135+
// and all the component-specific protocols should be derived from it.
136+
// It is also a place for the functions that might be exposed by all the
137+
// component accessibility peers.
138+
// Please see https://developer.apple.com/documentation/appkit/nsaccessibilityprotocol
139+
// for more details.
140+
@interface CommonComponentAccessibility : JavaComponentAccessibility <NSAccessibilityElement> {
141+
142+
}
143+
- (NSRect)accessibilityFrame;
144+
- (nullable id)accessibilityParent;
145+
@end
146+
130147
@implementation JavaComponentAccessibility
131148

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

1937+
@implementation CommonComponentAccessibility
1938+
// NSAccessibilityElement protocol implementation
1939+
- (NSRect)accessibilityFrame
1940+
{
1941+
JNIEnv* env = [ThreadUtilities getJNIEnv];
1942+
jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent,
1943+
fAccessible, fComponent);
1944+
1945+
NSSize size = getAxComponentSize(env, axComponent, fComponent);
1946+
NSPoint point = getAxComponentLocationOnScreen(env, axComponent, fComponent);
1947+
(*env)->DeleteLocalRef(env, axComponent);
1948+
point.y += size.height;
1949+
1950+
point.y = [[[[self view] window] screen] frame].size.height - point.y;
1951+
1952+
NSRect retval = NSMakeRect(point.x, point.y, size.width, size.height);
1953+
return retval;
1954+
}
1955+
1956+
- (nullable id)accessibilityParent
1957+
{
1958+
return [self accessibilityParentAttribute];
1959+
}
1960+
1961+
@end
1962+
19201963
/*
19211964
* Returns Object.equals for the two items
19221965
* This may use LWCToolkit.invokeAndWait(); don't call while holding fLock

0 commit comments

Comments
 (0)