Skip to content

Commit 72215f0

Browse files
authored
feat(accessibility): add modifiers, actions, and focus support (#1117)
1 parent b17d55b commit 72215f0

59 files changed

Lines changed: 8334 additions & 165 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Sources/COpenSwiftUI/Overlay/Accessibility/OpenSwiftUIAccessibilityPrivate.m‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#import "OpenSwiftUIAccessibilityPrivate.h"
99
#import "../Foundation/OpenSwiftUI+NSObject.h"
1010

11-
#if OPENSWIFTUI_TARGET_OS_IOS || OPENSWIFTUI_TARGET_OS_VISION || OPENSWIFTUI_TARGET_OS_OSX
11+
#if OPENSWIFTUI_TARGET_OS_DARWIN
1212

1313
#import <objc/runtime.h>
1414

@@ -55,4 +55,4 @@ - (void)set_accessibilityAllowsAutomationElements:(BOOL)value {
5555
#endif
5656
@end
5757

58-
#endif /* OPENSWIFTUI_TARGET_OS_IOS || OPENSWIFTUI_TARGET_OS_VISION || OPENSWIFTUI_TARGET_OS_OSX */
58+
#endif /* OPENSWIFTUI_TARGET_OS_DARWIN */
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// OpenSwiftUI+NSKeyedUnarchiver.h
3+
// COpenSwiftUI
4+
//
5+
// Audited for 6.5.4
6+
// Status: Complete
7+
8+
#ifndef OpenSwiftUI_NSKeyedUnarchiver_h
9+
#define OpenSwiftUI_NSKeyedUnarchiver_h
10+
11+
#include "OpenSwiftUIBase.h"
12+
13+
#if OPENSWIFTUI_TARGET_OS_DARWIN
14+
15+
#import <Foundation/Foundation.h>
16+
17+
OPENSWIFTUI_ASSUME_NONNULL_BEGIN
18+
19+
@interface NSKeyedUnarchiver (OpenSwiftUI)
20+
// Preserve nil results when no NSError is reported.
21+
+ (NSObject * _Nullable)openswiftui_unarchiveTopLevelLNActionWithData:(NSData *)data
22+
error:(NSError * _Nullable * _Nullable)error
23+
__attribute__((swift_error(nonnull_error)))
24+
NS_SWIFT_NAME(openswiftui_unarchiveTopLevelLNAction(with:));
25+
@end
26+
27+
OPENSWIFTUI_ASSUME_NONNULL_END
28+
29+
#endif /* OPENSWIFTUI_TARGET_OS_DARWIN */
30+
31+
#endif /* OpenSwiftUI_NSKeyedUnarchiver_h */
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// OpenSwiftUI+NSKeyedUnarchiver.m
3+
// COpenSwiftUI
4+
//
5+
// Audited for 6.5.4
6+
// Status: Complete
7+
8+
#import "OpenSwiftUI+NSKeyedUnarchiver.h"
9+
10+
#if OPENSWIFTUI_TARGET_OS_DARWIN
11+
12+
@implementation NSKeyedUnarchiver (OpenSwiftUI)
13+
+ (NSObject * _Nullable)openswiftui_unarchiveTopLevelLNActionWithData:(NSData *)data
14+
error:(NSError * _Nullable * _Nullable)error {
15+
#pragma clang diagnostic push
16+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
17+
return [self unarchiveTopLevelObjectWithData:data error:error];
18+
#pragma clang diagnostic pop
19+
}
20+
@end
21+
22+
#endif /* OPENSWIFTUI_TARGET_OS_DARWIN */

‎Sources/COpenSwiftUI/Shims/AppKit/AppKit_Private.h‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ OPENSWIFTUI_EXTERN_C_BEGIN
2020
OPENSWIFTUI_EXPORT
2121
Class _Nullable AXNSTableViewCellMockElementClass(void);
2222

23+
OPENSWIFTUI_EXPORT
24+
Class _Nullable AXNSTableRowClass(void);
25+
2326
OPENSWIFTUI_EXPORT
2427
void NSAccessibilityBeginInternalAccessors(void);
2528

@@ -29,8 +32,28 @@ void NSAccessibilityEndInternalAccessors(void);
2932
OPENSWIFTUI_EXPORT
3033
id _Nullable NSAccessibilityEntryPointValueForAttribute(id element, NSAccessibilityAttributeName attribute);
3134

35+
OPENSWIFTUI_EXPORT
36+
NSArray * _Nullable NSAccessibilityEntryPointActionNames(id element);
37+
38+
OPENSWIFTUI_EXPORT
39+
NSString * _Nullable NSAccessibilityEntryPointActionDescription(id element, NSAccessibilityActionName action);
40+
41+
OPENSWIFTUI_EXPORT
42+
BOOL NSAccessibilityEntryPointPerformAction(id element, NSAccessibilityActionName action);
43+
44+
OPENSWIFTUI_EXPORT
45+
NSAccessibilityAttributeName const NSAccessibilityIsAccessibilityElementAttribute;
46+
47+
OPENSWIFTUI_EXPORT
48+
NSAccessibilityAttributeName const NSAccessibilityAttributedUserInputLabelsAttribute;
49+
3250
OPENSWIFTUI_EXTERN_C_END
3351

52+
@interface NSObject (OpenSwiftUI_SPI)
53+
- (BOOL)_accessibilitySetOverrideValue:(nullable id)value forAttribute:(NSAccessibilityAttributeName)attribute OPENSWIFTUI_SWIFT_NAME(_accessibilitySetOverrideValue(_:for:));
54+
- (BOOL)_accessibilitySetOverrideHandler:(id _Nullable (^ _Nullable)(void))handler forAttribute:(NSAccessibilityAttributeName)attribute OPENSWIFTUI_SWIFT_NAME(_accessibilitySetOverrideHandler(_:for:));
55+
@end
56+
3457
@interface NSApplication (OpenSwiftUI_SPI)
3558

3659
- (BOOL)_shouldLoadMainNibNamed:(nullable NSString *)name;
@@ -69,6 +92,23 @@ typedef OPENSWIFTUI_ENUM(NSInteger, NSViewVibrantBlendingStyle) {
6992
@property (nullable, copy) NSString *_defaultAccessibilityDescription;
7093
@end
7194

95+
@interface NSWorkspace (OpenSwiftUI_SPI)
96+
@property (readonly, getter=isAccessibilityFullKeyboardAccessEnabled) BOOL accessibilityFullKeyboardAccessEnabled;
97+
@end
98+
99+
@interface NSView (OpenSwiftUI_SPI)
100+
- (nullable id)accessibilityFocusedUIElement;
101+
@end
102+
103+
@interface NSAccessibilityRemoteUIElement : NSObject
104+
+ (BOOL)isRemoteUIApp;
105+
@end
106+
107+
@protocol NSWindowSwiftUIDelegate <NSObject>
108+
@optional
109+
- (nullable id)_accessibilityWindow:(NSWindow *)window focusedUIElementOverrideWithCurrentValue:(nullable id)currentValue;
110+
@end
111+
72112
OPENSWIFTUI_ASSUME_NONNULL_END
73113

74114
#endif /* __has_include(<AppKit/AppKit.h>) */

‎Sources/COpenSwiftUI/Shims/AppKit/AppKit_Private.m‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111

1212
#import <objc/runtime.h>
1313

14+
Class _Nullable AXNSTableRowClass(void) {
15+
static Class tableRowClass;
16+
static dispatch_once_t onceToken;
17+
dispatch_once(&onceToken, ^{
18+
tableRowClass = NSClassFromString(@"NSTableRow");
19+
});
20+
return tableRowClass;
21+
}
22+
1423
Class _Nullable AXNSTableViewCellMockElementClass(void) {
1524
static Class tableViewCellMockElementClass;
1625
static dispatch_once_t onceToken;

‎Sources/COpenSwiftUI/Shims/UIKit/UIKit_Private.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020
OPENSWIFTUI_ASSUME_NONNULL_BEGIN
2121

22+
@interface NSObject (OpenSwiftUIAccessibility)
23+
- (nullable UITextRange *)_textRangeFromNSRange:(NSRange)range OPENSWIFTUI_SWIFT_NAME(_textRange(from:));
24+
- (NSRange)_nsrangeForTextRange:(UITextRange *)range OPENSWIFTUI_SWIFT_NAME(_nsrange(for:));
25+
- (nullable id)_textInputForReveal;
26+
- (NSComparisonResult)accessibilityCompareGeometry:(NSObject *)element;
27+
@end
28+
2229
@interface UIApplication (OpenSwiftUI_SPI)
2330
- (nullable NSString *)_extendLaunchTest;
2431
- (BOOL)_supportsPrintCommand;
@@ -35,6 +42,7 @@ OPENSWIFTUI_ASSUME_NONNULL_BEGIN
3542
@end
3643

3744
@interface UIView (OpenSwiftUI_SPI)
45+
- (nullable id<UILargeContentViewerItem>)_largeContentViewerItemAtPoint:(CGPoint)point OPENSWIFTUI_SWIFT_NAME(_largeContentViewerItem(at:));
3846
- (instancetype)_initWithLayer:(CALayer *)layer;
3947
- (void)_geometryChanged:(const void *)geometry forAncestor:(nullable UIView *)ancestor;
4048
- (void)_registerForGeometryChanges;

0 commit comments

Comments
 (0)