|
1 | 1 | /*
|
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. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -127,6 +127,23 @@ - (NSArray *)accessibilityColumnsAttribute;
|
127 | 127 | @end
|
128 | 128 |
|
129 | 129 |
|
| 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 | + |
130 | 147 | @implementation JavaComponentAccessibility
|
131 | 148 |
|
132 | 149 | - (NSString *)description
|
@@ -1917,6 +1934,32 @@ - (id)accessibilityColumnCountAttribute {
|
1917 | 1934 | }
|
1918 | 1935 | @end
|
1919 | 1936 |
|
| 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 | + |
1920 | 1963 | /*
|
1921 | 1964 | * Returns Object.equals for the two items
|
1922 | 1965 | * This may use LWCToolkit.invokeAndWait(); don't call while holding fLock
|
|
0 commit comments